protected static void TryGetInEdges_Test( [NotNull] IMutableBidirectionalGraph <int, Edge <int> > graph) { TryGetInEdges_Test( graph, edges => graph.AddVerticesAndEdgeRange(edges)); }
protected static void InEdges_Test( IMutableBidirectionalGraph <int, Edge <int> > graph) { var edge12 = new Edge <int>(1, 2); var edge13 = new Edge <int>(1, 3); var edge14 = new Edge <int>(1, 4); var edge24 = new Edge <int>(2, 4); var edge32 = new Edge <int>(3, 2); var edge33 = new Edge <int>(3, 3); graph.AddVertex(1); AssertNoInEdge(graph, 1); AssertNoOutEdge(graph, 1); graph.AddVerticesAndEdgeRange(new[] { edge12, edge13, edge14, edge24, edge32, edge33 }); AssertHasOutEdges(graph, 1, new[] { edge12, edge13, edge14 }); AssertHasOutEdges(graph, 2, new[] { edge24 }); AssertHasOutEdges(graph, 3, new[] { edge32, edge33 }); AssertNoOutEdge(graph, 4); AssertNoInEdge(graph, 1); AssertHasInEdges(graph, 2, new[] { edge12, edge32 }); AssertHasInEdges(graph, 3, new[] { edge13, edge33 }); AssertHasInEdges(graph, 4, new[] { edge14, edge24 }); }
protected static void InEdge_Test( IMutableBidirectionalGraph <int, Edge <int> > graph) { var edge11 = new Edge <int>(1, 1); var edge13 = new Edge <int>(1, 3); var edge21 = new Edge <int>(2, 1); var edge41 = new Edge <int>(4, 1); graph.AddVerticesAndEdgeRange(new[] { edge11, edge13, edge21, edge41 }); Assert.AreSame(edge11, graph.InEdge(1, 0)); Assert.AreSame(edge41, graph.InEdge(1, 2)); Assert.AreSame(edge13, graph.InEdge(3, 0)); }
protected static void Degree_Test( [NotNull] IMutableBidirectionalGraph <int, Edge <int> > graph) { var edge1 = new Edge <int>(1, 2); var edge2 = new Edge <int>(1, 3); var edge3 = new Edge <int>(1, 4); var edge4 = new Edge <int>(2, 4); var edge5 = new Edge <int>(3, 2); var edge6 = new Edge <int>(3, 3); graph.AddVerticesAndEdgeRange(new[] { edge1, edge2, edge3, edge4, edge5, edge6 }); graph.AddVertex(5); Assert.AreEqual(3, graph.Degree(1)); Assert.AreEqual(3, graph.Degree(2)); Assert.AreEqual(4, graph.Degree(3)); // Self edge Assert.AreEqual(2, graph.Degree(4)); Assert.AreEqual(0, graph.Degree(5)); }