-
Notifications
You must be signed in to change notification settings - Fork 1.6k
/
Copy pathFloydWarshallTests.cs
55 lines (37 loc) · 1.24 KB
/
FloydWarshallTests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
using Algorithms.Graph;
using DataStructures.Graph;
using NUnit.Framework;
using FluentAssertions;
namespace Algorithms.Tests.Graph;
public class FloydWarshallTests
{
[Test]
public void CorrectMatrixTest()
{
var graph = new DirectedWeightedGraph<int>(10);
var vertex1 = graph.AddVertex(1);
var vertex2 = graph.AddVertex(2);
var vertex3 = graph.AddVertex(3);
var vertex4 = graph.AddVertex(4);
var vertex5 = graph.AddVertex(5);
graph.AddEdge(vertex1, vertex2, 3);
graph.AddEdge(vertex1, vertex5, -4);
graph.AddEdge(vertex1, vertex3, 8);
graph.AddEdge(vertex2, vertex5, 7);
graph.AddEdge(vertex2, vertex4, 1);
graph.AddEdge(vertex3, vertex2, 4);
graph.AddEdge(vertex4, vertex3, -5);
graph.AddEdge(vertex4, vertex1, 2);
graph.AddEdge(vertex5, vertex4, 6);
var actualDistances = new double[,]
{
{ 0, 1, -3, 2, -4 },
{ 3, 0, -4, 1, -1 },
{ 7, 4, 0, 5, 3 },
{ 2, -1, -5, 0, -2 },
{ 8, 5, 1, 6, 0 },
};
var floydWarshaller = new FloydWarshall<int>();
floydWarshaller.Run(graph).Should().BeEquivalentTo(actualDistances);
}
}