public void AddUndirectedEdge_ShouldAddConnectedVertexToAdjacencyLists_WhenExistingKeysSpecified() { var graph = UndirectedGraphTestData.GenerateTestGraph(); var expectedAdjacencyLists = new Dictionary <int, IReadOnlyList <int> >() { [0] = new List <int>() { 1, 2 }, [1] = new List <int>() { 0, 2, 3 }, [2] = new List <int>() { 0, 1 }, [3] = new List <int>() { 1 }, }; graph.AddUndirectedEdge(3, 1); Assert.Equal(expectedAdjacencyLists, graph.AdjacencyLists); }
public void RemoveVertex_ShouldRemoveVertexWithAllRelatedEdges_WhenTargetVertexExists() { var graph = UndirectedGraphTestData.GenerateTestGraph(); var expectedAdjacencyLists = new Dictionary <int, IReadOnlyList <int> >() { [1] = new List <int>() { 2 }, [2] = new List <int>() { 1 }, [3] = new List <int>(), }; graph.RemoveVertex(0); Assert.Equal(expectedAdjacencyLists, graph.AdjacencyLists); }