public static void MainTest(string[] args) { TextInput input = new TextInput(args[0]); Graph G = new Graph(input); int s = int.Parse(args[1]); BreadthFirstPaths bfs = new BreadthFirstPaths(G, s); for (int v = 0; v < G.V; v++) { if (bfs.HasPathTo(v)) { Console.Write("{0} to {1} ({2}): ", s, v, bfs.DistTo(v)); foreach (int x in bfs.PathTo(v)) { if (x == s) { Console.Write(x); } else { Console.Write("-" + x); } } Console.WriteLine(); } else { Console.Write("{0} to {1} (-): not connected\n", s, v); } } }
public static void MainTest(string[] args) { string filename = args[0]; string delimiter = args[1]; string source = args[2]; SymbolGraph sg = new SymbolGraph(filename, delimiter); Graph G = sg.G; if (!sg.Contains(source)) { Console.WriteLine(source + " not in database."); return; } int s = sg.Index(source); BreadthFirstPaths bfs = new BreadthFirstPaths(G, s); TextInput StdIn = new TextInput(); while (!StdIn.IsEmpty) { string sink = StdIn.ReadLine(); if (sg.Contains(sink)) { int t = sg.Index(sink); if (bfs.HasPathTo(t)) { foreach (int v in bfs.PathTo(t)) { Console.WriteLine(" " + sg.Name(v)); } } else { Console.WriteLine("Not connected"); } } else { Console.WriteLine(" Not in database."); } } }