public void Ctor_ShouldInitializeAdjacencyLists() { var graph = new MixedWeightedGraph <int, int>(); Assert.NotNull(graph.AdjacencyLists); Assert.Empty(graph.AdjacencyLists); }
public void Ctor_ShouldInitializeAdjacencyListsWithVertices() { var vertices = new List <int> { 0, 1, 2, 3 }; var graph = new MixedWeightedGraph <int, int>(vertices); Assert.Equal(vertices, graph.AdjacencyLists.Keys); Assert.All(graph.AdjacencyLists.Values, list => { Assert.Empty(list); }); }
public void Ctor_ShouldInitializeAdjacencyListsWithVerticesAndEdgesWithDefaultWeights() { var vertices = new List <int> { 0, 1, 2, 3 }; var directedEdges = new List <Edge <int> > { new Edge <int>(0, 1), new Edge <int>(0, 2) }; var undirectedEdges = new List <Edge <int> > { new Edge <int>(1, 3), new Edge <int>(2, 1) }; var edges = directedEdges.Concat(undirectedEdges); var expectedAdjacencyLists = new Dictionary <int, IReadOnlyList <int> >() { [0] = new List <int>() { 1, 2 }, [1] = new List <int>() { 3, 2 }, [2] = new List <int>() { 1 }, [3] = new List <int>() { 1 }, }; var graph = new MixedWeightedGraph <int, int>(vertices, directedEdges, undirectedEdges); Assert.Equal(expectedAdjacencyLists, graph.AdjacencyLists); Assert.All(edges, edge => { Assert.Equal(default, graph.Weights[edge]);