public void Test_Graph_DFS_SeperatedEdge() { DSGraph dSGraph = new DSGraph(); dSGraph.AddVertex("San Fransisco"); dSGraph.AddVertex("Las Vegas"); dSGraph.AddVertex("Seattle"); dSGraph.AddVertex("Atlanta"); dSGraph.AddVertex("Dallas"); dSGraph.AddVertex("Denver"); dSGraph.AddVertex("Delhi"); dSGraph.AddEdge("San Fransisco", "Seattle"); dSGraph.AddEdge("San Fransisco", "Dallas"); dSGraph.AddEdge("San Fransisco", "Denver"); dSGraph.AddEdge("Dallas", "Atlanta"); dSGraph.AddEdge("Dallas", "Denver"); dSGraph.AddEdge("Dallas", "Las Vegas"); var actual = dSGraph.DFS("Delhi"); var expected = new List <string>() { "Delhi" }; for (int i = 0; i < actual.Count; i++) { Assert.AreEqual(actual[i], expected[i]); } }
public void Test_Graph_BFS_Positive() { DSGraph dSGraph = new DSGraph(); dSGraph.AddVertex("San Fransisco"); dSGraph.AddVertex("Las Vegas"); dSGraph.AddVertex("Seattle"); dSGraph.AddVertex("Atlanta"); dSGraph.AddVertex("Dallas"); dSGraph.AddVertex("Denver"); dSGraph.AddVertex("Delhi"); dSGraph.AddEdge("San Fransisco", "Seattle"); dSGraph.AddEdge("San Fransisco", "Dallas"); dSGraph.AddEdge("San Fransisco", "Denver"); dSGraph.AddEdge("Dallas", "Atlanta"); dSGraph.AddEdge("Dallas", "Denver"); dSGraph.AddEdge("Dallas", "Las Vegas"); var actual = dSGraph.BFS("San Fransisco"); var expected = new List <string>() { "San Fransisco", "Seattle", "Dallas", "Denver", "Atlanta", "Las Vegas" }; Assert.IsNotNull(actual); Assert.AreEqual(expected.Count, actual.Count); for (int i = 0; i < actual.Count; i++) { Assert.AreEqual(actual[i], expected[i]); } }
public void FindRoute_Test_No_Route() { DSGraph obj = new DSGraph(); obj.AddVertex("San Fransisco"); obj.AddVertex("Las Vegas"); obj.AddVertex("Seattle"); obj.AddVertex("Atlanta"); obj.AddVertex("Dallas"); obj.AddVertex("Denver"); obj.AddVertex("Delhi"); obj.AddDirectedEdge("San Fransisco", "Seattle"); obj.AddDirectedEdge("San Fransisco", "Dallas"); obj.AddDirectedEdge("San Fransisco", "Denver"); obj.AddDirectedEdge("Dallas", "Atlanta"); obj.AddDirectedEdge("Dallas", "Denver"); obj.AddDirectedEdge("Dallas", "Las Vegas"); var actual = obj.FindRoute("Seattle", "Las Vegas"); Assert.IsFalse(actual); }