Skip to content

Commit

Permalink
#37 Fix Dijkstra tests
Browse files Browse the repository at this point in the history
  • Loading branch information
justcoding121 committed Jul 13, 2022
1 parent b7aec0b commit 868bb42
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Advanced.Algorithms.DataStructures.Graph.AdjacencyList;
using Advanced.Algorithms.Graph;
using Advanced.Algorithms.Graph;
using Microsoft.VisualStudio.TestTools.UnitTesting;


Expand All @@ -9,9 +8,49 @@ namespace Advanced.Algorithms.Tests.Graph
public class BellmanFord_Tests
{
[TestMethod]
public void BellmanFord_Smoke_Test()
public void BellmanFord_AdjacencyList_Smoke_Test()
{
var graph = new WeightedDiGraph<char, int>();
var graph = new Algorithms.DataStructures.Graph.AdjacencyList.WeightedDiGraph<char, int>();

graph.AddVertex('S');
graph.AddVertex('A');
graph.AddVertex('B');
graph.AddVertex('C');
graph.AddVertex('D');
graph.AddVertex('T');

graph.AddEdge('S', 'A', -10);
graph.AddEdge('S', 'C', -5);

graph.AddEdge('A', 'B', 4);
graph.AddEdge('A', 'C', 2);
graph.AddEdge('A', 'D', 8);

graph.AddEdge('B', 'T', 10);

graph.AddEdge('C', 'D', 9);

graph.AddEdge('D', 'B', 6);
graph.AddEdge('D', 'T', 10);

var algorithm = new BellmanFordShortestPath<char, int>(new BellmanFordShortestPathOperators());

var result = algorithm.FindShortestPath(graph, 'S', 'T');

Assert.AreEqual(4, result.Length);

var expectedPath = new char[] { 'S', 'A', 'B', 'T' };
for (int i = 0; i < expectedPath.Length; i++)
{
Assert.AreEqual(expectedPath[i], result.Path[i]);
}

}

[TestMethod]
public void BellmanFord_AdjacencyMatrix_Smoke_Test()
{
var graph = new Algorithms.DataStructures.Graph.AdjacencyMatrix.WeightedDiGraph<char, int>();

graph.AddVertex('S');
graph.AddVertex('A');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class Dijikstras_Tests
[TestMethod]
public void Dijikstra_AdjacencyListGraph_Smoke_Test()
{
var graph = new Algorithms.DataStructures.Graph.AdjacencyMatrix.WeightedDiGraph<char, int>();
var graph = new Algorithms.DataStructures.Graph.AdjacencyList.WeightedDiGraph<char, int>();

graph.AddVertex('S');
graph.AddVertex('A');
Expand Down

0 comments on commit 868bb42

Please sign in to comment.