public void Find_FromVertexDisconnectedFromToVertex_EmptyPath() { var graph = AdjacencyListFactory.CreateDirected(); graph.AddVertex("a") .AddEdge("b") .AddEdge("c") .AddEdge("g"); graph.AddVertex("c") .AddEdge("d") .AddEdge("e") .AddEdge("f"); graph.AddVertex("f") .AddEdge("g"); //path of graph not connected with others graph.AddVertex("m") .AddEdge("n"); graph.AddVertex("n") .AddEdge("o"); var search = new DepthFirstSearch(graph); var result = search.BuildPath("a").GetPathString("n"); result.Should().Be(""); }
public void Find_ValidInputUsingStringStructure_ShouldFindPath() { var graph = AdjacencyListFactory.CreateUndirectedFromStructure("1-[14]6-[9]3-[7]2,6-[9]5-[2]3,2-[10]3-[15]4,3-[11]4,4-[6]5"); var search = new DijkstraAlgorithm(graph); var result = search.BuildPath("1").GetPathString("5"); result.Should().Be("1365"); }
public void Find_ValidInput_ShouldFindPath() { var graph = AdjacencyListFactory.CreateDirected(); graph.AddVertex("a") .AddEdge("b") .AddEdge("c") .AddEdge("g"); graph.AddVertex("c") .AddEdge("d") .AddEdge("e") .AddEdge("f"); graph.AddVertex("f") .AddEdge("g"); var search = new DepthFirstSearch(graph); var result = search.BuildPath("a").GetPathString("e"); (result == "ace" || result == "agfce").Should().BeTrue(); }
public void Find_ValidInput_ShouldFindPath() { var graph = AdjacencyListFactory.CreateUndirected(); graph.AddVertex("a") .AddEdge("b", 5) .AddEdge("d", 10) .AddEdge("e", 19); graph.AddVertex("b") .AddEdge("c", 1) .AddEdge("d", 8); graph.AddVertex("d") .AddEdge("c", 1) .AddEdge("e", 9); var search = new DijkstraAlgorithm(graph); var result = search.BuildPath("a").GetPathString("e"); result.Should().Be("abcde"); }