Ejemplo n.º 1
0
 private void DFSBuild(DFSTNode currentNode)
 {
     dummyVar0 = this.traversedNodes.Add(currentNode);
     dummyVar1 = this.currentPath.Add(currentNode);
     V_0       = LogicalFlowUtilities.GetTraversableSuccessors(currentNode.get_Construct()).GetEnumerator();
     try
     {
         while (V_0.MoveNext())
         {
             V_1 = V_0.get_Current();
             if (!this.constructToNodeMap.TryGetValue(V_1, out V_2))
             {
                 continue;
             }
             if (this.traversedNodes.Contains(V_2))
             {
                 if (!this.currentPath.Contains(V_2))
                 {
                     if (!this.IsAncestor(V_2, currentNode))
                     {
                         dummyVar10 = V_2.get_CrossEdgePredecessors().Add(currentNode);
                         dummyVar11 = currentNode.get_CrossEdgeSuccessors().Add(V_2);
                         dummyVar12 = this.theTree.get_CrossEdges().Add(new DFSTEdge(currentNode, V_2));
                     }
                     else
                     {
                         dummyVar7 = V_2.get_ForwardEdgePredecessors().Add(currentNode);
                         dummyVar8 = currentNode.get_ForwardEdgeSucessors().Add(V_2);
                         dummyVar9 = this.theTree.get_ForwardEdges().Add(new DFSTEdge(currentNode, V_2));
                     }
                 }
                 else
                 {
                     dummyVar4 = V_2.get_BackEdgePredecessors().Add(currentNode);
                     dummyVar5 = currentNode.get_BackEdgeSuccessors().Add(V_2);
                     dummyVar6 = this.theTree.get_BackEdges().Add(new DFSTEdge(currentNode, V_2));
                 }
             }
             else
             {
                 V_2.set_Predecessor(currentNode);
                 dummyVar2 = currentNode.get_TreeEdgeSuccessors().Add(V_2);
                 dummyVar3 = this.theTree.get_TreeEdges().Add(new DFSTEdge(currentNode, V_2));
                 this.DFSBuild(V_2);
             }
         }
     }
     finally
     {
         if (V_0 != null)
         {
             V_0.Dispose();
         }
     }
     dummyVar13 = this.currentPath.Remove(currentNode);
     this.theTree.get_ReversePostOrder().Add(currentNode);
     return;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Recursively traverses the nodes and adds them to the tree. Also determines the type of each edge.
        /// </summary>
        /// <param name="currentNode"></param>
        private void DFSBuild(DFSTNode currentNode)
        {
            traversedNodes.Add(currentNode);

            //The current path is the set of all nodes on the DFS tree path from the root to the current node.
            currentPath.Add(currentNode);

            foreach (ISingleEntrySubGraph successorConstruct in LogicalFlowUtilities.GetTraversableSuccessors(currentNode.Construct))
            {
                DFSTNode successor;
                if (!constructToNodeMap.TryGetValue(successorConstruct, out successor))
                {
                    //Special case for interval constructs
                    continue;
                }

                if (!traversedNodes.Contains(successor))
                {
                    //If the successor is not traversed then the edge between the two nodes is a tree edge.
                    successor.Predecessor = currentNode;
                    currentNode.TreeEdgeSuccessors.Add(successor);
                    theTree.TreeEdges.Add(new DFSTEdge(currentNode, successor));

                    //We continue the build from this successor.
                    DFSBuild(successor);
                }
                else if (currentPath.Contains(successor))
                {
                    //If the successor is traversed and is on the current path then the edge between the nodes is a back edge.
                    successor.BackEdgePredecessors.Add(currentNode);
                    currentNode.BackEdgeSuccessors.Add(successor);
                    theTree.BackEdges.Add(new DFSTEdge(currentNode, successor));
                }
                else if (IsAncestor(successor, currentNode))
                {
                    //If the successor is traversed and the current node is its ancestor, then the edge is a forward edge.
                    successor.ForwardEdgePredecessors.Add(currentNode);
                    currentNode.ForwardEdgeSucessors.Add(successor);
                    theTree.ForwardEdges.Add(new DFSTEdge(currentNode, successor));
                }
                else
                {
                    //Otherwise the edge between the nodes is a cross edge.
                    successor.CrossEdgePredecessors.Add(currentNode);
                    currentNode.CrossEdgeSuccessors.Add(successor);
                    theTree.CrossEdges.Add(new DFSTEdge(currentNode, successor));
                }
            }

            currentPath.Remove(currentNode);

            //Adding the nodes in post order.
            theTree.ReversePostOrder.Add(currentNode);
        }