public static void resize_Network(ref gProAnalyzer.GraphVariables.clsGraph graph, int currentN, int nNode, int nLink) { graph.Network[currentN].nNode = nNode; gProAnalyzer.GraphVariables.clsNode.strNode[] newNode = new gProAnalyzer.GraphVariables.clsNode.strNode[nNode]; for (int i = 0; i < nNode; i++) { newNode[i] = graph.Network[currentN].Node[i]; } graph.Network[currentN].nLink = nLink; gProAnalyzer.GraphVariables.clsEdge.strEdge[] newLink = new gProAnalyzer.GraphVariables.clsEdge.strEdge[nLink]; for (int i = 0; i < nLink; i++) { newLink[i] = graph.Network[currentN].Link[i]; } graph.Network[currentN].Node = newNode; graph.Network[currentN].Link = newLink; }
public static void reduce_IrLoop_Preprocessing(ref gProAnalyzer.GraphVariables.clsGraph graph, int currentN, gProAnalyzer.GraphVariables.clsLoop clsLoop, int workLoop, int currLoop) { //Reduce IL into an OR-join and XOR-split Initialized_All(); int[] calDom = null; for (int k = 0; k < clsLoop.Loop[workLoop].Loop[currLoop].nEntry; k++) { calDom = gProAnalyzer.Ultilities.findIntersection.find_Intersection(graph.Network[currentN].nNode, calDom, graph.Network[currentN].Node[clsLoop.Loop[workLoop].Loop[currLoop].Entry[k]].Dom); } int CID = -1; if (calDom.Length > 0) { for (int i = calDom.Length - 1; i > 0; i--) { if (check_CID_In_Loop(clsLoop, workLoop, currLoop, calDom[i]) == false) { CID = calDom[i]; break; } } if (CID == -1) { return; //error } //Mustcheck CID not belong to any nesting Loop (only belong to parent of IL[x]) (or natural loop header at the same depth - inside current parent also) // // //create 2 node entry_OR and exit_XOR of new reduced IL int[] imNode = new int[graph.Network[currentN].nNode]; int num = 0; imNode[num] = clsLoop.Loop[workLoop].Loop[currLoop].header; num++; for (int j = 0; j < clsLoop.Loop[workLoop].Loop[currLoop].nNode; j++) { graph.Network[currentN].Node[clsLoop.Loop[workLoop].Loop[currLoop].Node[j]].done = true; // header제외한 loop내 노드 축소 imNode[num] = clsLoop.Loop[workLoop].Loop[currLoop].Node[j]; num++; } int entry_OR = clsLoop.Loop[workLoop].Loop[currLoop].header; //Loop[workLoop].Loop[loop].header를 대표 Node 로 graph.Network[currentN].Node[entry_OR].Kind = "OR"; // 대표 Node는 XOR노드로........ graph.Network[currentN].Node[entry_OR].Name = "IL[" + currLoop.ToString() + "]"; graph.Network[currentN].Node[entry_OR].Type_I = ""; graph.Network[currentN].Node[entry_OR].Type_II = ""; graph.Network[currentN].Node[entry_OR].done = false; graph.Network[currentN].Node[entry_OR].header = true; graph.Network[currentN].Node[entry_OR].headerOfLoop = currLoop; graph.Network[currentN].Node[entry_OR].Special = ""; //remove the role as loop-gateways (now it is a normal acyclic nodes) int exit_XOR = clsLoop.Loop[workLoop].Loop[currLoop].Exit[0]; //Loop[workLoop].Loop[loop].header를 대표 Node 로 graph.Network[currentN].Node[exit_XOR].Kind = "XOR"; // 대표 Node는 XOR노드로........ graph.Network[currentN].Node[exit_XOR].Name = "IL[" + currLoop.ToString() + "]"; graph.Network[currentN].Node[exit_XOR].Type_I = ""; graph.Network[currentN].Node[exit_XOR].Type_II = ""; graph.Network[currentN].Node[exit_XOR].done = false; graph.Network[currentN].Node[exit_XOR].header = false; graph.Network[currentN].Node[exit_XOR].Special = ""; int indx_Link = -1; for (int i = 0; i < graph.Network[currentN].nLink; i++) { int fromNode = graph.Network[currentN].Link[i].fromNode; int toNode = graph.Network[currentN].Link[i].toNode; //routing incoming edges of IL to entry_OR for (int j = 0; j < clsLoop.Loop[workLoop].Loop[currLoop].nEntry; j++) { if (toNode == clsLoop.Loop[workLoop].Loop[currLoop].Entry[j] && gProAnalyzer.Ultilities.checkGraph.Node_In_Loop(clsLoop, workLoop, fromNode, currLoop) == false && entry_OR != toNode) { graph.Network[currentN].Link[i].toNode = entry_OR; } } //routing outgoing edges of IL from exit_XOR for (int j = 0; j < clsLoop.Loop[workLoop].Loop[currLoop].nExit; j++) { if (fromNode == clsLoop.Loop[workLoop].Loop[currLoop].Exit[j] && gProAnalyzer.Ultilities.checkGraph.Node_In_Loop(clsLoop, workLoop, toNode, currLoop) == false && exit_XOR != fromNode) { graph.Network[currentN].Link[i].fromNode = exit_XOR; } } //cut-off inner edges with entry_OR for (int j = 0; j < clsLoop.Loop[workLoop].Loop[currLoop].nEntry; j++) { if (toNode == entry_OR && gProAnalyzer.Ultilities.checkGraph.Node_In_Loop(clsLoop, workLoop, fromNode, currLoop) == true) { graph.Network[currentN].Link[i].toNode = graph.Network[currentN].Link[i].fromNode; } if (fromNode == entry_OR && gProAnalyzer.Ultilities.checkGraph.Node_In_Loop(clsLoop, workLoop, toNode, currLoop) == true) { graph.Network[currentN].Link[i].fromNode = graph.Network[currentN].Link[i].toNode; indx_Link = i; } } //cut-off inner edges with exit_XOR for (int j = 0; j < clsLoop.Loop[workLoop].Loop[currLoop].nExit; j++) { if (toNode == exit_XOR && gProAnalyzer.Ultilities.checkGraph.Node_In_Loop(clsLoop, workLoop, fromNode, currLoop) == true) { graph.Network[currentN].Link[i].toNode = graph.Network[currentN].Link[i].fromNode; } if (fromNode == exit_XOR && gProAnalyzer.Ultilities.checkGraph.Node_In_Loop(clsLoop, workLoop, toNode, currLoop) == true) { graph.Network[currentN].Link[i].fromNode = graph.Network[currentN].Link[i].toNode; } } } //connect entry_OR to exit_XOR of new reduced IL graph.Network[currentN].Link[indx_Link].fromNode = entry_OR; graph.Network[currentN].Link[indx_Link].toNode = exit_XOR; //remove duplicated link (could happend when CID directly to all Entries) gProAnalyzer.GraphVariables.clsEdge.strEdge[] imLink = new gProAnalyzer.GraphVariables.clsEdge.strEdge[graph.Network[currentN].nLink]; int imNum = 0; for (int i = 0; i < graph.Network[currentN].nLink; i++) { bool isAdd = true; for (int j = 0; j < imNum; j++) { if (graph.Network[currentN].Link[i].fromNode == imLink[j].fromNode && graph.Network[currentN].Link[i].toNode == imLink[j].toNode) { isAdd = false; break; } } if (isAdd) { imLink[imNum] = graph.Network[currentN].Link[i]; imNum++; } } //transfer LINK to new Graph graph.Network[currentN].nLink = imNum; graph.Network[currentN].Link = new gProAnalyzer.GraphVariables.clsEdge.strEdge[imNum]; for (int i = 0; i < imNum; i++) { graph.Network[currentN].Link[i] = imLink[i]; } //Finally - update node information for (int i = 0; i < graph.Network[currentN].nNode; i++) { if (graph.Network[currentN].Node[i].done) { graph.Network[currentN].Node[i].nPre = 0; graph.Network[currentN].Node[i].nPost = 0; graph.Network[currentN].Node[i].Pre = null; graph.Network[currentN].Node[i].Post = null; } else { //nodeInfo = new gProAnalyzer.Ultilities.clsFindNodeInfo(); gProAnalyzer.Ultilities.clsFindNodeInfo.find_NodeInfo(ref graph, currentN, i); } } } }