static void Main(string[] args) { DiGraph dg=new DiGraph(5); dg.addEdge(0, 1); dg.addEdge(1, 2); dg.addEdge(1, 3); dg.addEdge(2, 4); //dg.addEdge(4, 0); //Comment it for topological dg.addEdge(4, 3); Console.WriteLine(dg); dg.ShowMarked(); dg.ShowCycle(); dg.ShowTopological(); Console.WriteLine("{0}-{1} is strongly connected : {2}", 0, 1, dg.isStonglyConnected(0, 1)); Console.WriteLine("{0}-{1} is reachable : {2}", 0, 3, dg.Reachable(0, 3)); Console.ReadKey(); }
static void Main(string[] args) { DiGraph dg = new DiGraph(5); dg.addEdge(0, 1); dg.addEdge(1, 2); dg.addEdge(1, 3); dg.addEdge(2, 4); //dg.addEdge(4, 0); //Comment it for topological dg.addEdge(4, 3); Console.WriteLine(dg); dg.ShowMarked(); dg.ShowCycle(); dg.ShowTopological(); Console.WriteLine("{0}-{1} is strongly connected : {2}", 0, 1, dg.isStonglyConnected(0, 1)); Console.WriteLine("{0}-{1} is reachable : {2}", 0, 3, dg.Reachable(0, 3)); Console.ReadKey(); }
public DiGraph reverse() { DiGraph R = new DiGraph(V); for (int v = 0; v < V; v++) foreach (int w in Adj(v)) R.addEdge(w, v); return R; }
public DiGraph reverse() { DiGraph R = new DiGraph(V); for (int v = 0; v < V; v++) { foreach (int w in Adj(v)) { R.addEdge(w, v); } } return(R); }