Example #1
0
        public static void removing_disconnectedNode(ref GraphVariables.clsGraph graph, int currentN)
        {
            int[] nodeList = new int[graph.Network[currentN].nNode];
            for (int i = 0; i < nodeList.Length; i++)
            {
                nodeList[i] = i;
            }

            gProAnalyzer.GraphVariables.clsNode.strNode[] imNode = new gProAnalyzer.GraphVariables.clsNode.strNode[graph.Network[currentN].nNode];
            int nImNode = 0;

            for (int i = 0; i < graph.Network[currentN].nNode; i++)
            {
                if (graph.Network[currentN].Node[i].done == false)
                {
                    imNode[nImNode] = graph.Network[currentN].Node[i];

                    if (nImNode != i)
                    {
                        nodeList[i] = nImNode;
                    }

                    nImNode++;
                }
            }

            for (int i = 0; i < nodeList.Length; i++)
            {
                if (nodeList[i] != i)
                {
                    int newIndx  = nodeList[i];
                    int oldIndex = i;
                    for (int j = 0; j < graph.Network[currentN].nLink; j++)
                    {
                        if (graph.Network[currentN].Link[j].fromNode == oldIndex)
                        {
                            graph.Network[currentN].Link[j].fromNode = newIndx;
                        }
                        if (graph.Network[currentN].Link[j].toNode == oldIndex)
                        {
                            graph.Network[currentN].Link[j].toNode = newIndx;
                        }
                    }
                }
            }

            graph.Network[currentN].nNode = nImNode;
            graph.Network[currentN].Node  = new gProAnalyzer.GraphVariables.clsNode.strNode[graph.Network[currentN].nNode];
            for (int i = 0; i < graph.Network[currentN].nNode; i++)
            {
                graph.Network[currentN].Node[i] = imNode[i];
            }
        }
Example #2
0
 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;
 }