public void UpdateShortestPath() { // Arrange var shortestPath = new DijkstrasShortestPath(Graph()); shortestPath.Reset(); var index_u = 1; var index_v = 0; // Pre-act 1 this.AssertResults1(shortestPath); // Manipulate data for testing purposes. // These values will be set in the loop shortestPath.ResetDistanceOfSourceVertex(sourceVertexIndex: index_u); shortestPath.SetShortestDistance(index_u, value: 2); shortestPath.SetShortestDistance(index_v, value: 9); // Pre-act 2 this.AssertResults2(shortestPath); // Act shortestPath.Update(index_u, index_v); // Assert this.AssertResults3(shortestPath); this.AssertVerticesThatAreInShortestDistance(shortestPath); }
public void DoesNotUpdatePath() { // Arrange var shortestPath = new DijkstrasShortestPath(Graph()); shortestPath.Reset(); var index_u = 1; var index_v = 0; // Pre-act 1 this.AssertResults1(shortestPath); // Manipulate data for testing purposes. // These values will be set in the loop shortestPath.ResetDistanceOfSourceVertex(sourceVertexIndex: index_u); shortestPath.SetShortestDistance(index_u, value: 2); shortestPath.SetShortestDistance(index_v, value: 4); // v=4 is the reason to not to update // Pre-act 2 Assert.Equal(4, shortestPath.shortestDistances[0]); Assert.Equal(2, shortestPath.shortestDistances[1]); Assert.Equal(2147483647, shortestPath.shortestDistances[2]); // Act shortestPath.Update(index_u, index_v); // Assert Assert.Equal(4, shortestPath.shortestDistances[0]); Assert.Equal(2, shortestPath.shortestDistances[1]); Assert.Equal(2147483647, shortestPath.shortestDistances[2]); }