public void AddEdges_throws_on_verticies_not_in_the_graph() { var vertexOne = new Vertex { Id = 1 }; var vertexTwo = new Vertex { Id = 2 }; var edgeOne = new Edge { Id = 1 }; var graph = new Multigraph <Vertex, Edge>(); graph.AddVertex(vertexOne); Assert.Equal( CoreStrings.GraphDoesNotContainVertex(vertexTwo), Assert.Throws <InvalidOperationException>(() => graph.AddEdges(vertexOne, vertexTwo, new[] { edgeOne })).Message); Assert.Equal( CoreStrings.GraphDoesNotContainVertex(vertexTwo), Assert.Throws <InvalidOperationException>(() => graph.AddEdges(vertexTwo, vertexOne, new[] { edgeOne })).Message); }
public void AddEdges_adds_multiple_edges() { var vertexOne = new Vertex { Id = 1 }; var vertexTwo = new Vertex { Id = 2 }; var edgeOne = new Edge { Id = 1 }; var edgeTwo = new Edge { Id = 2 }; var edgeThree = new Edge { Id = 3 }; var graph = new Multigraph <Vertex, Edge>(); graph.AddVertices(new[] { vertexOne, vertexTwo }); graph.AddEdges(vertexOne, vertexTwo, new[] { edgeOne }); graph.AddEdges(vertexOne, vertexTwo, new[] { edgeTwo, edgeThree }); Assert.Equal(0, graph.GetEdges(vertexTwo, vertexOne).Count()); Assert.Equal(3, graph.GetEdges(vertexOne, vertexTwo).Count()); Assert.Equal(3, graph.GetEdges(vertexOne, vertexTwo).Intersect(new[] { edgeOne, edgeTwo, edgeThree }).Count()); }