-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathKCentersGreedyApproximationTests.cs
More file actions
42 lines (37 loc) · 1.45 KB
/
Copy pathKCentersGreedyApproximationTests.cs
File metadata and controls
42 lines (37 loc) · 1.45 KB
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
using AlgorithmsAndDataStructures.Algorithms.Graph.KCenters;
using Xunit;
namespace AlgorithmsAndDataStructures.Tests.Algorithm.Graph.KCenters;
public class KCentersGreedyApproximationTests
{
[Fact]
public void BaselineForTwoCenters()
{
var sut = new KCentersGreedyApproximation();
var graph = new int[4][];
graph[0] = new[] { 0, 10, 6, 7 };
graph[1] = new[] { 10, 0, 8, 5 };
graph[2] = new[] { 6, 8, 0, 12 };
graph[3] = new[] { 7, 5, 12, 0 };
#pragma warning disable HAA0101 // Array allocation for params parameter
Assert.Collection(sut.GetKCenters(graph, 2),
arg => Assert.Equal(0, arg),
arg => Assert.Equal(1, arg));
#pragma warning restore HAA0101 // Array allocation for params parameter
}
[Fact]
public void BaselineForThreeCenters()
{
var sut = new KCentersGreedyApproximation();
var graph = new int[4][];
graph[0] = new[] { 0, 10, 6, 7 };
graph[1] = new[] { 10, 0, 8, 5 };
graph[2] = new[] { 6, 8, 0, 12 };
graph[3] = new[] { 7, 5, 12, 0 };
#pragma warning disable HAA0101 // Array allocation for params parameter
Assert.Collection(sut.GetKCenters(graph, 3),
arg => Assert.Equal(0, arg),
arg => Assert.Equal(1, arg),
arg => Assert.Equal(2, arg));
#pragma warning restore HAA0101 // Array allocation for params parameter
}
}