public static void MainTest(string[] args) { int V = int.Parse(args[0]); int E = int.Parse(args[1]); // Eulerian cycle Digraph G1 = DigraphGenerator.EulerianCycle(V, E); DirectedEulerianPath.UnitTest(G1, "Eulerian cycle"); // Eulerian path Digraph G2 = DigraphGenerator.EulerianPath(V, E); DirectedEulerianPath.UnitTest(G2, "Eulerian path"); // add one random edge Digraph G3 = new Digraph(G2); G3.AddEdge(StdRandom.Uniform(V), StdRandom.Uniform(V)); DirectedEulerianPath.UnitTest(G3, "one random edge added to Eulerian path"); // self loop Digraph G4 = new Digraph(V); int v4 = StdRandom.Uniform(V); G4.AddEdge(v4, v4); DirectedEulerianPath.UnitTest(G4, "single self loop"); // single edge Digraph G5 = new Digraph(V); G5.AddEdge(StdRandom.Uniform(V), StdRandom.Uniform(V)); DirectedEulerianPath.UnitTest(G5, "single edge"); // empty digraph Digraph G6 = new Digraph(V); DirectedEulerianPath.UnitTest(G6, "empty digraph"); // random digraph Digraph G7 = DigraphGenerator.Simple(V, E); DirectedEulerianPath.UnitTest(G7, "simple digraph"); // 4-vertex digraph //Digraph G8 = new Digraph(new TextInput("eulerianD.txt")); //DirectedEulerianPath.UnitTest(G8, "4-vertex Eulerian digraph"); }
internal static void UnitTest(Digraph G, String description) { Console.WriteLine(description); Console.WriteLine("-------------------------------------"); Console.Write(G); DirectedEulerianPath euler = new DirectedEulerianPath(G); Console.Write("Eulerian path: "); if (euler.HasEulerianPath) { foreach (int v in euler.Path()) { Console.Write(v + " "); } Console.WriteLine(); } else { Console.WriteLine("none"); } Console.WriteLine(); }