예제 #1
0
 public static IEnumerable <int> GetExitNodes(this IGraph graph)
 {
     for (int i = 0; i < graph.NodeCount; i++)
     {
         if (!graph.IsNodeActive(i) || graph.Children(i).Count != 0)
         {
             continue;
         }
         yield return(i);
     }
 }
예제 #2
0
    public static int GetExitNode(this IGraph graph)
    {
        // Should be the only node with outdegree 0
        int result = -1;

        for (int i = 0; i < graph.NodeCount; i++)
        {
            if (!graph.IsNodeActive(i) || graph.Children(i).Count != 0)
            {
                continue;
            }
            if (result != -1)
            {
                throw new ControlFlowGraphException("Multiple exit nodes were found in graph!", graph);
            }
            result = i;
            // return result;
        }

        return(result);
    }
예제 #3
0
 public static int OutDegree(this IGraph graph, int node) => graph.Children(node).Count;