Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 868bb42

Browse files
#37 Fix Dijkstra tests
1 parent b7aec0b commit 868bb42

File tree

2 files changed

+44
-5
lines changed

2 files changed

+44
-5
lines changed

‎tests/Advanced.Algorithms.Tests/Graph/ShortestPath/BellmanFord_Tests.cs

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using Advanced.Algorithms.DataStructures.Graph.AdjacencyList;
2-
using Advanced.Algorithms.Graph;
1+
using Advanced.Algorithms.Graph;
32
using Microsoft.VisualStudio.TestTools.UnitTesting;
43

54

@@ -9,9 +8,49 @@ namespace Advanced.Algorithms.Tests.Graph
98
public class BellmanFord_Tests
109
{
1110
[TestMethod]
12-
public void BellmanFord_Smoke_Test()
11+
public void BellmanFord_AdjacencyList_Smoke_Test()
1312
{
14-
var graph = new WeightedDiGraph<char, int>();
13+
var graph = new Algorithms.DataStructures.Graph.AdjacencyList.WeightedDiGraph<char, int>();
14+
15+
graph.AddVertex('S');
16+
graph.AddVertex('A');
17+
graph.AddVertex('B');
18+
graph.AddVertex('C');
19+
graph.AddVertex('D');
20+
graph.AddVertex('T');
21+
22+
graph.AddEdge('S', 'A', -10);
23+
graph.AddEdge('S', 'C', -5);
24+
25+
graph.AddEdge('A', 'B', 4);
26+
graph.AddEdge('A', 'C', 2);
27+
graph.AddEdge('A', 'D', 8);
28+
29+
graph.AddEdge('B', 'T', 10);
30+
31+
graph.AddEdge('C', 'D', 9);
32+
33+
graph.AddEdge('D', 'B', 6);
34+
graph.AddEdge('D', 'T', 10);
35+
36+
var algorithm = new BellmanFordShortestPath<char, int>(new BellmanFordShortestPathOperators());
37+
38+
var result = algorithm.FindShortestPath(graph, 'S', 'T');
39+
40+
Assert.AreEqual(4, result.Length);
41+
42+
var expectedPath = new char[] { 'S', 'A', 'B', 'T' };
43+
for (int i = 0; i < expectedPath.Length; i++)
44+
{
45+
Assert.AreEqual(expectedPath[i], result.Path[i]);
46+
}
47+
48+
}
49+
50+
[TestMethod]
51+
public void BellmanFord_AdjacencyMatrix_Smoke_Test()
52+
{
53+
var graph = new Algorithms.DataStructures.Graph.AdjacencyMatrix.WeightedDiGraph<char, int>();
1554

1655
graph.AddVertex('S');
1756
graph.AddVertex('A');

‎tests/Advanced.Algorithms.Tests/Graph/ShortestPath/Dijikstras_Tests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public class Dijikstras_Tests
99
[TestMethod]
1010
public void Dijikstra_AdjacencyListGraph_Smoke_Test()
1111
{
12-
var graph = new Algorithms.DataStructures.Graph.AdjacencyMatrix.WeightedDiGraph<char, int>();
12+
var graph = new Algorithms.DataStructures.Graph.AdjacencyList.WeightedDiGraph<char, int>();
1313

1414
graph.AddVertex('S');
1515
graph.AddVertex('A');

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /