static void Main(string[] args) { Graph1 g = new Graph1(); g.AddNode("c1"); g.AddNode("c2"); g.AddNode("c3"); g.AddNode("c4"); g.AddNode("c5"); g.AddNode("c6"); g.AddNode("c7"); g.AddLink("c1", "c2", 3); g.AddLink("c1", "c3", 4); g.AddLink("c2", "c6", 4); g.AddLink("c3", "c5", 8); g.AddLink("c4", "c7", 5); g.AddLink("c5", "c2", 6); g.AddLink("c5", "c4", 8); Console.WriteLine(g); foreach (string item in g.Way("c1", "c1")) { Console.Write(item + " "); } Console.ReadLine(); }
public void ToString_error() { Graph1 g = new Graph1(); g.AddNode("Kyiv"); g.AddNode("Lviv"); Assert.AreEqual("Kyiv Lviv ", g.ToString()); }
public void AddNode_error() { Graph1 g = new Graph1(); g.AddNode("Kyiv"); g.AddNode("Lviv"); g.AddNode("Donetsk"); Assert.AreEqual(3, g.nodes.Length); }
//static void Main(string[] args) //{ // //Read the graph details // // it will be line sepearted with each edge represented in a line // string filePath = @"C:\Users\raghuvg\Documents\dharma\Graphs\Graphs\Data\DFS.txt"; // Graph graph = new Graph(filePath); // //Print Number of Vertices // Console.WriteLine(" Number of Nodes {0}" , graph.Vertices); // //Print Edges // Console.WriteLine("Number of Edges .. {0}", graph.Edges); // //Print Graph // graph.PrintGraph(); // //DFS // //graph.DFS(); // //Topological Sort // //graph.TopologicalSort(); // //BFS // graph.BFS(); // //bool edgeExists = graph.EdgeExists(1, 4); // //Console.WriteLine("Does edge exist between {0},{1}:{2}", 1, 4, edgeExists); // Console.ReadLine(); //} static void Main(string[] args) { //Read the graph details // it will be line sepearted with each edge represented in a line string filePath = @"C:\Users\raghuvg\Documents\dharma\Graphs\Graphs\Data\topological.txt"; Graph1 graph = new Graph1(filePath, 6, 6); //Print Graph graph.PrintGraph(); //DFS //graph.DepthFirstTraversal(); graph.TopologicalSort(); Console.ReadLine(); }
public void AddNode_exception_error() { Graph1 g = new Graph1(); Assert.Throws(typeof(ArgumentException), () => g.AddNode("")); }
public void ToStringEmpty_error() { Graph1 g = new Graph1(); Assert.Throws(typeof(InvalidOperationException), () => g.ToString()); }