Exemplo n.º 1
0
        public DirectedBFS(DiGraph graph,int v)
        {
            this.v = v;
            this.graph = graph;
            edgeTo = Enumerable.Repeat(-1, graph.V()).ToArray<int>();

            visited = new bool[graph.V()];
            distTo = new int[graph.V()];
            breadthFirstSearch (v);
        }
Exemplo n.º 2
0
        public TopologicalSort(DiGraph graph)
        {
            this.graph = graph;
            stack = new Stack<int> ();
            visited = new bool[graph.V ()];

            for (int i = 0; i < graph.V(); i++) {
                if (!visited[i]) {
                    depthFirstSearch (i);
                }
            }
        }