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); }
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); } } }
public DiGraph Reverse() { DiGraph result = new DiGraph (this.numOfNodes); for (int i = 0; i < this.numOfNodes; i++) { foreach (var item in this.Adj(i)) { result.AddEdge (item, i); } } return result; }