//Processing here private void mnuMakeNetwork_Click(object sender, EventArgs e) { int count_Loop = 0; int count_total = 0; int count_newGraph = 0; for (int run = 0; run < sFileNames.Length; run++) { //m_Network = new clsAnaysisNetwork(); //m_Network.Load_Data_ForBreakModel(m_Network.orgNet, sFilePaths[run], true); loadGraph.Load_Data_ForBreakModel(ref graph, graph.orgNet, sFilePaths[run], true); string saveFilePath = txtSaveFolder.Text + @"\" + sFileNames[run]; //Check Disconnected model int CCs = 0; int[] mark = null; Ultilities.checkGraph.find_ConnectedComponents(graph, graph.baseNet, ref CCs, ref mark); //We calculate on base net only.!!. check_SyntaxError(graph, graph.orgNet); gProAnalyzer.Functionalities.NodeSplittingType1.Run_Split_Type1(ref graph, graph.orgNet, graph.midNet); gProAnalyzer.Functionalities.LoopIdentification.Run_FindLoop(ref graph, graph.midNet, ref clsLoop, clsLoop.orgLoop, ref clsLoop.IrreducibleError); graph.Network[graph.finalNet] = graph.Network[graph.midNet]; gProAnalyzer.Functionalities.NodeSplittingType2.Run_Split_Type2(ref graph, graph.midNet, graph.finalNet, ref clsLoop, clsLoop.orgLoop); gProAnalyzer.Functionalities.DominanceIdentification.find_Dom(ref graph, graph.finalNet); gProAnalyzer.Functionalities.DominanceIdentification.find_Pdom(ref graph, graph.finalNet); gProAnalyzer.Functionalities.DominanceIdentification.find_DomEI(ref graph, graph.finalNet, -2); gProAnalyzer.Functionalities.DominanceIdentification.find_PdomEI(ref graph, graph.finalNet); gProAnalyzer.Functionalities.SESEIdentification.find_SESE_Dummy(ref graph, graph.finalNet, ref clsLoop, clsLoop.orgLoop, ref clsSESE, clsSESE.finalSESE, -2); gProAnalyzer.Functionalities.NodeSplittingType3.Run_Split_Type3(ref graph, graph.finalNet, ref clsLoop, clsLoop.orgLoop, ref clsSESE, clsSESE.finalSESE, true); gProAnalyzer.Functionalities.PolygonIdentification.polygonIdentification(ref graph, graph.finalNet, ref clsSESE, clsSESE.finalSESE); gProAnalyzer.Ultilities.makeNestingForest.make_NestingForest(ref graph, graph.finalNet, ref clsHWLS, ref clsLoop, clsLoop.orgLoop, ref clsSESE, clsSESE.finalSESE); gProAnalyzer.Functionalities.VerificationG.Initialize_Verification(ref graph, ref clsError, ref clsLoop, ref clsSESE, ref clsHWLS); //Verification checking runVerification.count_Bonds_Rigids(ref graph, graph.finalNet, ref clsSESE, clsSESE.finalSESE, ref clsLoop, clsLoop.orgLoop, ref clsHWLS); //label B,R,P //#B, R, P int curDepth = clsHWLS.FBLOCK.maxDepth; graph.Network[graph.reduceNet] = graph.Network[graph.finalNet]; gProAnalyzer.Ultilities.extendGraph.full_extentNetwork(ref graph, graph.reduceNet, 0, 0); gProAnalyzer.Ultilities.copyLoop.copy_Loop(ref clsLoop, clsLoop.orgLoop, clsLoop.reduceLoop); //count_Loop = 0; count_total = 0; if (SyntaxError_GW) { continue; } //if (gProAnalyzer.Functionalities.VerificationG.iL_concurrency_Error == true) continue; //if (CCs > 1) continue; do { for (int hw = 0; hw < clsHWLS.FBLOCK.nFBlock; hw++) { if (clsHWLS.FBLOCK.FBlock[hw].depth != curDepth) { continue; } int curr = clsHWLS.FBLOCK.FBlock[hw].refIndex; if (clsHWLS.FBLOCK.FBlock[hw].type == "R" && clsHWLS.FBLOCK.FBlock[hw].SESE == true) //Split model and store it { //count++; count_newGraph++; count_total++; saveFilePath = txtSaveFolder.Text + @"\" + sFileNames[run].Replace(".net", "") + @"_" + count_total + @".net"; //if (clsHWLS.FBLOCK.FBlock[hw].SESE == false) // gProAnalyzer.Ultilities.makeSubNetwork.make_AcyclicSubGraph gProAnalyzer.Ultilities.makeSubNetwork.make_subNetwork(ref graph, graph.reduceNet, graph.subNet, ref clsLoop, clsSESE.finalSESE, curr, ref clsSESE, "SESE", -1); int[] nodeList = new int[graph.Network[graph.subNet].nNode * 2]; int nNodeList = 0; //get node list for (int j = 0; j < graph.Network[graph.subNet].nNode; j++) { nodeList[nNodeList] = j; nNodeList++; } //get edge list clsAnaysisNetwork.strLink[] LinkList = new clsAnaysisNetwork.strLink[graph.Network[graph.subNet].nLink * 2]; int nLinkList = 0; for (int j = 0; j < graph.Network[graph.subNet].nLink; j++) { for (int k = 0; k < nNodeList; k++) { if (nodeList[k] == graph.Network[graph.subNet].Link[j].fromNode) { for (int m = 0; m < nNodeList; m++) { if (nodeList[m] == graph.Network[graph.subNet].Link[j].toNode) { LinkList[nLinkList].fromNode = k; LinkList[nLinkList].toNode = m; nLinkList++; } } } } } //Save temporary to file Save_Network_1(graph.subNet, nodeList, nNodeList, LinkList, nLinkList, saveFilePath, false, ""); string[] tempLines = File.ReadAllLines(saveFilePath); } if (clsHWLS.FBLOCK.FBlock[hw].SESE == false) { count_Loop++; //count_newGraph++; count_total++; if (clsLoop.Loop[clsLoop.orgLoop].Loop[curr].nEntry == 1) { gProAnalyzer.Ultilities.makeSubNetwork.make_CyclicSubGraph(ref graph, graph.reduceNet, graph.subNet, ref clsLoop, clsLoop.reduceLoop, curr, "NL", ref clsSESE); saveFilePath = txtSaveFolder.Text + @"\" + "NL_" + sFileNames[run].Replace(".net", "") + @"_" + count_total + @".net"; } if (clsLoop.Loop[clsLoop.orgLoop].Loop[curr].nEntry > 1) { gProAnalyzer.Ultilities.makeSubNetwork.make_CyclicSubGraph(ref graph, graph.reduceNet, graph.subNet, ref clsLoop, clsLoop.reduceLoop, curr, "IL", ref clsSESE); saveFilePath = txtSaveFolder.Text + @"\" + "IL_" + sFileNames[run].Replace(".net", "") + @"_" + count_total + @".net"; } int[] nodeList = new int[graph.Network[graph.subNet].nNode * 2]; int nNodeList = 0; //get node list for (int j = 0; j < graph.Network[graph.subNet].nNode; j++) { nodeList[nNodeList] = j; nNodeList++; } //get edge list clsAnaysisNetwork.strLink[] LinkList = new clsAnaysisNetwork.strLink[graph.Network[graph.subNet].nLink * 2]; int nLinkList = 0; for (int j = 0; j < graph.Network[graph.subNet].nLink; j++) { for (int k = 0; k < nNodeList; k++) { if (nodeList[k] == graph.Network[graph.subNet].Link[j].fromNode) { for (int m = 0; m < nNodeList; m++) { if (nodeList[m] == graph.Network[graph.subNet].Link[j].toNode) { LinkList[nLinkList].fromNode = k; LinkList[nLinkList].toNode = m; nLinkList++; } } } } } //Save temporary to file Save_Network_1(graph.subNet, nodeList, nNodeList, LinkList, nLinkList, saveFilePath, false, ""); string[] tempLines = File.ReadAllLines(saveFilePath); } //reduce Bond - Rigids - NL - IL if (clsHWLS.FBLOCK.FBlock[hw].type != "P" && clsHWLS.FBLOCK.FBlock[hw].SESE == true) //reduce nested rigids (if any) { gProAnalyzer.Ultilities.reduceGraph.reduce_SESE(ref graph, graph.reduceNet, clsSESE, clsSESE.finalSESE, curr); } if (clsHWLS.FBLOCK.FBlock[hw].SESE == false && clsLoop.Loop[clsLoop.orgLoop].Loop[curr].nEntry == 1) { gProAnalyzer.Ultilities.reduceGraph.reduce_Loop(ref graph, graph.reduceNet, ref clsLoop, clsLoop.reduceLoop, curr, "", true); } if (clsHWLS.FBLOCK.FBlock[hw].SESE == false && clsLoop.Loop[clsLoop.orgLoop].Loop[curr].nEntry > 1) { gProAnalyzer.Ultilities.reduceGraph.reduce_IrLoop_Preprocessing(ref graph, graph.reduceNet, clsLoop, clsLoop.reduceLoop, curr); } } curDepth--; } while (curDepth > 0); } MessageBox.Show(count_Loop.ToString(), "Loop"); MessageBox.Show(count_newGraph.ToString(), "Rigids"); }
//Processing here private void mnuMakeNetwork_Click(object sender, EventArgs e) { int count = 0; int count_newGraph = 0; for (int run = 0; run < sFileNames.Length; run++) { m_Network = new clsAnaysisNetwork(); m_Network.Load_Data_ForBreakModel(m_Network.orgNet, sFilePaths[run], true); string saveFilePath = txtSaveFolder.Text + @"\" + sFileNames[run]; //Check Disconnected model int CCs = 0; int[] mark = null; m_Network.find_ConnectedComponents(m_Network.baseNet, ref CCs, ref mark); //We calculate on base net only.!!. if (CCs > 1) //Split model and store it { count++; for (int CC = 1; CC <= CCs; CC++) { count_newGraph++; saveFilePath = txtSaveFolder.Text + @"\" + sFileNames[run].Replace(".net", "") + @"_" + CC + @".net"; int[] nodeList = new int[m_Network.Network[m_Network.orgNet].nNode]; int nNodeList = 0; //get node list for (int j = 0; j < mark.Length; j++) { if (mark[j] == CC) { nodeList[nNodeList] = j; nNodeList++; } } //get edge list clsAnaysisNetwork.strLink[] LinkList = new clsAnaysisNetwork.strLink[m_Network.Network[m_Network.orgNet].nLink]; int nLinkList = 0; for (int j = 0; j < m_Network.Network[m_Network.orgNet].nLink; j++) { for (int k = 0; k < nNodeList; k++) { if (nodeList[k] == m_Network.Network[m_Network.orgNet].Link[j].fromNode) { for (int m = 0; m < nNodeList; m++) { if (nodeList[m] == m_Network.Network[m_Network.orgNet].Link[j].toNode) { LinkList[nLinkList].fromNode = k; LinkList[nLinkList].toNode = m; nLinkList++; } } } } } //Save temporary to file Save_Network_1(m_Network.baseNet, nodeList, nNodeList, LinkList, nLinkList, saveFilePath, false, "ADD --- Original Network ---"); string[] tempLines = File.ReadAllLines(saveFilePath); //Transfer to nodeList_S string[] nodeList_S = new string[m_Network.Network[m_Network.orgNet].nNode]; int nNodeList_S = nNodeList; for (int j = 0; j < nNodeList; j++) { nodeList_S[nNodeList] = nodeList[nNodeList].ToString(); } //build Original Network //find SS int[] SS_List = new int[nNodeList]; int nSS = 0; for (int j = 0; j < nNodeList; j++) { int count_Pre = 0; for (int k = 0; k < nLinkList; k++) { if (j == LinkList[k].toNode) { count_Pre++; } } if (count_Pre == 0) { SS_List[nSS] = j; nSS++; } } //find EE int[] EE_List = new int[nNodeList]; int nEE = 0; for (int j = 0; j < nNodeList; j++) { int count_Post = 0; for (int k = 0; k < nLinkList; k++) { if (j == LinkList[k].fromNode) { count_Post++; } } if (count_Post == 0) { EE_List[nEE] = j; nEE++; } } // SS -> -1; START -> -2; EE -> -3; END -> -4 //Create SS and EE links if (nSS > 1) { //Create node SS nodeList[nNodeList] = -1; nNodeList++; for (int j = 0; j < nSS; j++) { LinkList[nLinkList].fromNode = nNodeList - 1; LinkList[nLinkList].toNode = SS_List[j]; nLinkList++; } //Create START link to SS nodeList[nNodeList] = -2; //START node nNodeList++; LinkList[nLinkList].fromNode = nNodeList - 1; LinkList[nLinkList].toNode = nNodeList - 2; nLinkList++; } else { //Create START link to the only start EVENT nodeList[nNodeList] = -2; //START node nNodeList++; LinkList[nLinkList].fromNode = nNodeList - 1; LinkList[nLinkList].toNode = SS_List[nSS - 1]; nLinkList++; } if (nEE > 1) { //Create node EE nodeList[nNodeList] = -3; nNodeList++; for (int j = 0; j < nEE; j++) { LinkList[nLinkList].fromNode = EE_List[j]; LinkList[nLinkList].toNode = nNodeList - 1; nLinkList++; } //Create END to be linked by EE nodeList[nNodeList] = -4; //START node nNodeList++; LinkList[nLinkList].fromNode = nNodeList - 2; LinkList[nLinkList].toNode = nNodeList - 1; nLinkList++; } else { //Create END to be linked by the only end EVENT nodeList[nNodeList] = -4; //END node nNodeList++; LinkList[nLinkList].fromNode = EE_List[nEE - 1]; LinkList[nLinkList].toNode = nNodeList - 1; nLinkList++; } //build convert Network //save file "abc.net" to "abc_CCs.net" Save_Network_2(m_Network.baseNet, nodeList_S, nNodeList_S, nodeList, nNodeList, LinkList, nLinkList, saveFilePath, false, ""); //add more line in current IO File StreamWriter sw = new StreamWriter(saveFilePath, true); for (int i = 0; i < tempLines.Length; i++) { sw.WriteLine(tempLines[i]); } sw.Close(); } } else { System.IO.File.Copy(sFilePaths[run], saveFilePath, true); } m_Network = null; } MessageBox.Show(count.ToString(), "Disconnected Component Count"); MessageBox.Show(count_newGraph.ToString(), "New Graph Created"); }