public void OutEdge_Throws()
        {
            var data   = new GraphData <int, Edge <int> >();
            var graph1 = new DelegateVertexAndEdgeListGraph <int, Edge <int> >(
                new[] { 1, 2 },
                data.TryGetEdges);

            OutEdge_Throws_Test(data, graph1);

            // Additional tests
            data.ShouldReturnValue = true;
            var edge32 = new Edge <int>(3, 2);

            data.ShouldReturnEdges = new[] { edge32 };
            // ReSharper disable once ReturnValueOfPureMethodIsNotUsed
            Assert.Throws <VertexNotFoundException>(() => graph1.OutEdge(3, 0));
            data.CheckCalls(0); // Vertex is not in graph so no need to call user code

            var edge14 = new Edge <int>(1, 4);
            var edge12 = new Edge <int>(1, 2);

            data.ShouldReturnEdges = new[] { edge14, edge12 };
            // ReSharper disable once ReturnValueOfPureMethodIsNotUsed
            AssertIndexOutOfRange(() => graph1.OutEdge(1, 1));
            data.CheckCalls(1);

            var graph2 = new DelegateVertexAndEdgeListGraph <TestVertex, Edge <TestVertex> >(
                Enumerable.Empty <TestVertex>(),
                GetEmptyGetter <TestVertex, Edge <TestVertex> >());

            OutEdge_NullThrows_Test(graph2);
        }
Example #2
0
        protected static void TryGetEdges_Test(
            [NotNull] GraphData <int, Edge <int> > data,
            [NotNull] DelegateVertexAndEdgeListGraph <int, Edge <int> > graph)
        {
            data.CheckCalls(0);

            data.ShouldReturnValue = false;
            Assert.IsFalse(graph.TryGetEdges(0, 1, out _));
            data.CheckCalls(0); // Vertex is not in graph so no need to call user code

            data.ShouldReturnValue = true;
            Assert.IsTrue(graph.TryGetEdges(1, 2, out IEnumerable <Edge <int> > edges));
            CollectionAssert.IsEmpty(edges);
            data.CheckCalls(1);

            data.ShouldReturnEdges = new[] { new Edge <int>(1, 2), new Edge <int>(1, 2) };
            Assert.IsTrue(graph.TryGetEdges(1, 2, out edges));
            CollectionAssert.AreEqual(data.ShouldReturnEdges, edges);
            data.CheckCalls(1);

            var edge14    = new Edge <int>(1, 4);
            var edge12    = new Edge <int>(1, 2);
            var edge12Bis = new Edge <int>(1, 2);

            data.ShouldReturnValue = true;
            data.ShouldReturnEdges = new[] { edge14, edge12 };
            Assert.IsTrue(graph.TryGetEdges(1, 2, out edges));
            CollectionAssert.AreEqual(new[] { edge12 }, edges);
            data.CheckCalls(1);

            data.ShouldReturnEdges = new[] { edge14, edge12, edge12Bis };
            Assert.IsTrue(graph.TryGetEdges(1, 2, out edges));
            CollectionAssert.AreEqual(new[] { edge12, edge12Bis }, edges);
            data.CheckCalls(1);

            data.ShouldReturnEdges = new[] { edge14, edge12 };
            Assert.IsTrue(graph.TryGetEdges(2, 1, out edges));
            CollectionAssert.IsEmpty(edges);
            data.CheckCalls(1);

            var edge41 = new Edge <int>(4, 1);

            data.ShouldReturnEdges = new[] { edge14, edge41 };
            Assert.IsTrue(graph.TryGetEdges(1, 4, out edges));
            CollectionAssert.IsEmpty(edges);
            data.CheckCalls(1);

            Assert.IsFalse(graph.TryGetEdges(4, 1, out _));
            data.CheckCalls(0);

            var edge45 = new Edge <int>(4, 5);

            data.ShouldReturnEdges = new[] { edge14, edge41, edge45 };
            Assert.IsFalse(graph.TryGetEdges(4, 5, out _));
            data.CheckCalls(0);
        }
Example #3
0
        protected static void ContainsVertex_Test(
            [NotNull] GraphData <int, Edge <int> > data,
            [NotNull] IImplicitVertexSet <int> graph)
        {
            data.CheckCalls(0);

            data.ShouldReturnValue = false;
            Assert.IsFalse(graph.ContainsVertex(1));
            data.CheckCalls(1);

            data.ShouldReturnValue = true;
            Assert.IsTrue(graph.ContainsVertex(1));
            data.CheckCalls(1);
        }
Example #4
0
        protected static void Degree_Test(
            [NotNull] GraphData <int, Edge <int> > data1,
            [NotNull] GraphData <int, Edge <int> > data2,
            [NotNull] IBidirectionalIncidenceGraph <int, Edge <int> > graph)
        {
            // ReSharper disable ReturnValueOfPureMethodIsNotUsed
            data1.CheckCalls(0);
            data2.CheckCalls(0);

            data1.ShouldReturnValue = false;
            data2.ShouldReturnValue = false;
            Assert.Throws <VertexNotFoundException>(() => graph.Degree(1));
            data1.CheckCalls(0);
            data2.CheckCalls(1);

            data1.ShouldReturnValue = true;
            data2.ShouldReturnValue = false;
            Assert.Throws <VertexNotFoundException>(() => graph.Degree(1));
            data1.CheckCalls(0);
            data2.CheckCalls(1);

            data1.ShouldReturnValue = false;
            data2.ShouldReturnValue = true;
            Assert.Throws <VertexNotFoundException>(() => graph.Degree(1));
            data1.CheckCalls(1);
            data2.CheckCalls(1);
            // ReSharper restore ReturnValueOfPureMethodIsNotUsed

            data1.ShouldReturnValue = true;
            data2.ShouldReturnValue = true;
            Assert.AreEqual(0, graph.Degree(1));

            data1.ShouldReturnEdges = new[] { new Edge <int>(1, 2) };
            data2.ShouldReturnEdges = null;
            Assert.AreEqual(1, graph.Degree(1));

            data1.ShouldReturnEdges = null;
            data2.ShouldReturnEdges = new[] { new Edge <int>(3, 1) };
            Assert.AreEqual(1, graph.Degree(1));

            data1.ShouldReturnEdges = new[] { new Edge <int>(1, 2), new Edge <int>(1, 3) };
            data2.ShouldReturnEdges = new[] { new Edge <int>(4, 1) };
            Assert.AreEqual(3, graph.Degree(1));

            // Self edge
            data1.ShouldReturnEdges = new[] { new Edge <int>(1, 2), new Edge <int>(1, 3), new Edge <int>(1, 1) };
            data2.ShouldReturnEdges = new[] { new Edge <int>(4, 1), new Edge <int>(1, 1) };
            Assert.AreEqual(5, graph.Degree(1));
        }
Example #5
0
        public void AdjacentEdges_Throws()
        {
            var data1  = new GraphData <int, Edge <int> >();
            var graph1 = new DelegateUndirectedGraph <int, Edge <int> >(
                new[] { 1 },
                data1.TryGetEdges);

            AdjacentEdges_Throws_Test(data1, graph1);

            // Additional tests
            data1.ShouldReturnValue = true;
            var edge32 = new Edge <int>(3, 2);

            data1.ShouldReturnEdges = new[] { edge32 };
            // ReSharper disable once ReturnValueOfPureMethodIsNotUsed
            Assert.Throws <VertexNotFoundException>(() => graph1.AdjacentEdges(3));
            data1.CheckCalls(0); // Vertex is not in graph so no need to call user code


            var data2  = new GraphData <TestVertex, Edge <TestVertex> >();
            var graph2 = new DelegateUndirectedGraph <TestVertex, Edge <TestVertex> >(
                Enumerable.Empty <TestVertex>(),
                data2.TryGetEdges);

            AdjacentEdges_NullThrows_Test(graph2);
        }
        public void ContainsVertex()
        {
            var data  = new GraphData <int, Edge <int> >();
            var graph = new DelegateVertexAndEdgeListGraph <int, Edge <int> >(
                Enumerable.Empty <int>(),
                data.TryGetEdges);

            data.CheckCalls(0);

            data.ShouldReturnValue = false;
            Assert.IsFalse(graph.ContainsVertex(1));
            data.CheckCalls(0); // Implementation override

            data.ShouldReturnValue = true;
            Assert.IsFalse(graph.ContainsVertex(1));
            data.CheckCalls(0); // Implementation override


            graph = new DelegateVertexAndEdgeListGraph <int, Edge <int> >(
                new[] { 1, 2 },
                data.TryGetEdges);
            data.ShouldReturnValue = false;
            Assert.IsFalse(graph.ContainsVertex(10));
            data.CheckCalls(0); // Implementation override
            Assert.IsTrue(graph.ContainsVertex(2));
            data.CheckCalls(0); // Implementation override

            data.ShouldReturnValue = true;
            Assert.IsFalse(graph.ContainsVertex(10));
            data.CheckCalls(0); // Implementation override
            Assert.IsTrue(graph.ContainsVertex(2));
            data.CheckCalls(0); // Implementation override
        }
Example #7
0
        protected static void InEdge_Test(
            [NotNull] GraphData <int, Edge <int> > data,
            [NotNull] IBidirectionalIncidenceGraph <int, Edge <int> > graph)
        {
            var edge11 = new Edge <int>(1, 1);
            var edge21 = new Edge <int>(2, 1);
            var edge31 = new Edge <int>(3, 1);

            data.CheckCalls(0);

            data.ShouldReturnValue = true;
            data.ShouldReturnEdges = new[] { edge11, edge21, edge31 };
            Assert.AreSame(edge11, graph.InEdge(1, 0));
            data.CheckCalls(1);

            Assert.AreSame(edge31, graph.InEdge(1, 2));
            data.CheckCalls(1);
        }
Example #8
0
        protected static void InEdges_Throws_Test(
            [NotNull] GraphData <int, Edge <int> > data,
            [NotNull] IBidirectionalIncidenceGraph <int, Edge <int> > graph)
        {
            // ReSharper disable ReturnValueOfPureMethodIsNotUsed
            data.CheckCalls(0);

            data.ShouldReturnValue = false;
            Assert.Throws <VertexNotFoundException>(() => graph.IsInEdgesEmpty(1));
            data.CheckCalls(1);

            Assert.Throws <VertexNotFoundException>(() => graph.InDegree(1));
            data.CheckCalls(1);

            Assert.Throws <VertexNotFoundException>(() => graph.InEdges(1));
            data.CheckCalls(1);
            // ReSharper restore ReturnValueOfPureMethodIsNotUsed
        }
        protected static void AdjacentEdges_Throws_Test(
            GraphData <int, Edge <int> > data,
            IImplicitUndirectedGraph <int, Edge <int> > graph)
        {
            // ReSharper disable ReturnValueOfPureMethodIsNotUsed
            data.CheckCalls(0);

            data.ShouldReturnValue = false;
            Assert.Throws <VertexNotFoundException>(() => graph.IsAdjacentEdgesEmpty(1));
            data.CheckCalls(1);

            Assert.Throws <VertexNotFoundException>(() => graph.AdjacentDegree(1));
            data.CheckCalls(1);

            Assert.Throws <VertexNotFoundException>(() => graph.AdjacentEdges(1));
            data.CheckCalls(1);
            // ReSharper restore ReturnValueOfPureMethodIsNotUsed
        }
Example #10
0
        protected static void AdjacentEdge_Test(
            [NotNull] GraphData <int, Edge <int> > data,
            [NotNull] IImplicitUndirectedGraph <int, Edge <int> > graph)
        {
            var edge11 = new Edge <int>(1, 1);
            var edge12 = new Edge <int>(1, 2);
            var edge13 = new Edge <int>(1, 3);

            data.CheckCalls(0);

            data.ShouldReturnValue = true;
            data.ShouldReturnEdges = new[] { edge11, edge12, edge13 };
            Assert.AreSame(edge11, graph.AdjacentEdge(1, 0));
            data.CheckCalls(1);

            Assert.AreSame(edge13, graph.AdjacentEdge(1, 2));
            data.CheckCalls(1);
        }
        protected static void OutEdge_Test(
            GraphData <int, Edge <int> > data,
            IImplicitGraph <int, Edge <int> > graph)
        {
            var edge11 = new Edge <int>(1, 1);
            var edge12 = new Edge <int>(1, 2);
            var edge13 = new Edge <int>(1, 3);

            data.CheckCalls(0);

            data.ShouldReturnValue = true;
            data.ShouldReturnEdges = new[] { edge11, edge12, edge13 };
            Assert.AreSame(edge11, graph.OutEdge(1, 0));
            data.CheckCalls(1);

            Assert.AreSame(edge13, graph.OutEdge(1, 2));
            data.CheckCalls(1);
        }
Example #12
0
        protected static void AdjacentEdges_Test(
            [NotNull] GraphData <int, Edge <int> > data,
            [NotNull] IImplicitUndirectedGraph <int, Edge <int> > graph)
        {
            data.CheckCalls(0);

            data.ShouldReturnValue = true;
            AssertNoAdjacentEdge(graph, 1);
            data.CheckCalls(3);

            Edge <int>[] edges =
            {
                new Edge <int>(1, 2),
                new Edge <int>(1, 3)
            };
            data.ShouldReturnEdges = edges;
            AssertHasAdjacentEdges(graph, 1, edges);
            data.CheckCalls(3);
        }
Example #13
0
        protected static void InEdges_Test(
            [NotNull] GraphData <int, Edge <int> > data,
            [NotNull] IBidirectionalIncidenceGraph <int, Edge <int> > graph)
        {
            data.CheckCalls(0);

            data.ShouldReturnValue = true;
            AssertNoInEdge(graph, 1);
            data.CheckCalls(3);

            Edge <int>[] edges =
            {
                new Edge <int>(1, 2),
                new Edge <int>(1, 3)
            };
            data.ShouldReturnEdges = edges;
            AssertHasInEdges(graph, 1, edges);
            data.CheckCalls(3);
        }
        protected static void OutEdges_Test(
            [NotNull] GraphData <int, Edge <int> > data,
            [NotNull] IImplicitGraph <int, Edge <int> > graph)
        {
            data.CheckCalls(0);

            data.ShouldReturnValue = true;
            AssertNoOutEdge(graph, 1);
            data.CheckCalls(3);

            var edges = new[]
            {
                new Edge <int>(1, 2),
                new Edge <int>(1, 3)
            };

            data.ShouldReturnEdges = edges;
            AssertHasOutEdges(graph, 1, edges);
            data.CheckCalls(3);
        }
Example #15
0
        protected static void TryGetInEdges_Test(
            [NotNull] GraphData <int, Edge <int> > data,
            [NotNull] IBidirectionalIncidenceGraph <int, Edge <int> > graph)
        {
            data.CheckCalls(0);

            data.ShouldReturnValue = false;
            Assert.IsFalse(graph.TryGetInEdges(1, out _));
            data.CheckCalls(1);

            data.ShouldReturnValue = true;
            Assert.IsTrue(graph.TryGetInEdges(1, out IEnumerable <Edge <int> > edges));
            CollectionAssert.IsEmpty(edges);
            data.CheckCalls(1);

            data.ShouldReturnEdges = new[] { new Edge <int>(4, 1), new Edge <int>(2, 1) };
            Assert.IsTrue(graph.TryGetInEdges(1, out edges));
            CollectionAssert.AreEqual(data.ShouldReturnEdges, edges);
            data.CheckCalls(1);
        }
Example #16
0
        protected static void TryGetAdjacentEdges_Test(
            [NotNull] GraphData <int, Edge <int> > data,
            [NotNull] DelegateImplicitUndirectedGraph <int, Edge <int> > graph)
        {
            data.CheckCalls(0);

            data.ShouldReturnValue = false;
            Assert.IsFalse(graph.TryGetAdjacentEdges(1, out _));
            data.CheckCalls(1);

            data.ShouldReturnValue = true;
            Assert.IsTrue(graph.TryGetAdjacentEdges(1, out IEnumerable <Edge <int> > edges));
            CollectionAssert.IsEmpty(edges);
            data.CheckCalls(1);

            data.ShouldReturnEdges = new[] { new Edge <int>(1, 4), new Edge <int>(1, 2) };
            Assert.IsTrue(graph.TryGetAdjacentEdges(1, out edges));
            CollectionAssert.AreEqual(data.ShouldReturnEdges, edges);
            data.CheckCalls(1);
        }
Example #17
0
        protected static void InEdge_Throws_Test(
            [NotNull] GraphData <int, Edge <int> > data,
            [NotNull] IBidirectionalIncidenceGraph <int, Edge <int> > graph)
        {
            // ReSharper disable ReturnValueOfPureMethodIsNotUsed
            data.CheckCalls(0);

            data.ShouldReturnValue = false;
            Assert.Throws <VertexNotFoundException>(() => graph.InEdge(1, 0));
            data.CheckCalls(1);

            data.ShouldReturnValue = true;
            AssertIndexOutOfRange(() => graph.InEdge(1, 0));
            data.CheckCalls(1);

            data.ShouldReturnEdges = new[] { new Edge <int>(1, 2) };
            AssertIndexOutOfRange(() => graph.InEdge(1, 1));
            data.CheckCalls(1);
            // ReSharper restore ReturnValueOfPureMethodIsNotUsed
        }
        protected static void AdjacentEdge_Throws_Test(
            GraphData <int, Edge <int> > data,
            IImplicitUndirectedGraph <int, Edge <int> > graph)
        {
            // ReSharper disable ReturnValueOfPureMethodIsNotUsed
            data.CheckCalls(0);

            data.ShouldReturnValue = false;
            Assert.Throws <VertexNotFoundException>(() => graph.AdjacentEdge(1, 0));
            data.CheckCalls(1);

            data.ShouldReturnValue = true;
            AssertIndexOutOfRange(() => graph.AdjacentEdge(1, 0));
            data.CheckCalls(1);

            data.ShouldReturnEdges = new[] { new Edge <int>(1, 2) };
            AssertIndexOutOfRange(() => graph.AdjacentEdge(1, 1));
            data.CheckCalls(1);
            // ReSharper restore ReturnValueOfPureMethodIsNotUsed
        }
        public void OutEdge()
        {
            var data  = new GraphData <int, Edge <int> >();
            var graph = new DelegateVertexAndEdgeListGraph <int, Edge <int> >(
                new[] { 1, 2, 3 },
                data.TryGetEdges);

            OutEdge_Test(data, graph);

            // Additional tests
            var edge14 = new Edge <int>(1, 4);
            var edge12 = new Edge <int>(1, 2);

            data.ShouldReturnValue = true;
            data.ShouldReturnEdges = new[] { edge14, edge12 };
            Assert.AreSame(edge12, graph.OutEdge(1, 0));
            data.CheckCalls(1);
        }
Example #20
0
        protected static void TryGetAdjacentEdges_Test(
            [NotNull] GraphData <int, Edge <int> > data,
            [NotNull] DelegateUndirectedGraph <int, Edge <int> > graph)
        {
            data.CheckCalls(0);

            data.ShouldReturnValue = false;
            Assert.IsFalse(graph.TryGetAdjacentEdges(5, out _));
            data.CheckCalls(0); // Vertex is not in graph so no need to call user code

            data.ShouldReturnValue = true;
            Assert.IsTrue(graph.TryGetAdjacentEdges(1, out IEnumerable <Edge <int> > edges));
            CollectionAssert.IsEmpty(edges);
            data.CheckCalls(1);

            data.ShouldReturnEdges = new[] { new Edge <int>(1, 4), new Edge <int>(1, 2) };
            Assert.IsTrue(graph.TryGetAdjacentEdges(1, out edges));
            CollectionAssert.AreEqual(data.ShouldReturnEdges, edges);
            data.CheckCalls(1);

            data.ShouldReturnEdges = null;
            Assert.IsTrue(graph.TryGetAdjacentEdges(1, out IEnumerable <Edge <int> > adjacentEdges));
            CollectionAssert.IsEmpty(adjacentEdges);
            data.CheckCalls(1);

            var edge12 = new Edge <int>(1, 2);
            var edge13 = new Edge <int>(1, 3);
            var edge15 = new Edge <int>(1, 5);
            var edge21 = new Edge <int>(2, 1);
            var edge23 = new Edge <int>(2, 3);

            data.ShouldReturnEdges = new[] { edge12, edge13, edge15, edge21, edge23 };
            Assert.IsTrue(graph.TryGetAdjacentEdges(1, out adjacentEdges));
            CollectionAssert.AreEqual(
                new[] { edge12, edge13, edge21 },
                adjacentEdges);
            data.CheckCalls(1);

            var edge52 = new Edge <int>(5, 2);

            data.ShouldReturnEdges = new[] { edge15, edge52 };
            Assert.IsFalse(graph.TryGetAdjacentEdges(5, out _));
            data.CheckCalls(0); // Vertex is not in graph so no need to call user code
        }
        public void OutEdges()
        {
            var data  = new GraphData <int, Edge <int> >();
            var graph = new DelegateVertexAndEdgeListGraph <int, Edge <int> >(
                new[] { 1, 2, 3 },
                data.TryGetEdges);

            OutEdges_Test(data, graph);

            // Additional tests
            var edge12 = new Edge <int>(1, 2);
            var edge13 = new Edge <int>(1, 3);
            var edge14 = new Edge <int>(1, 4);
            var edge21 = new Edge <int>(2, 1);

            data.ShouldReturnValue = true;
            data.ShouldReturnEdges = new[] { edge12, edge13, edge14, edge21 };
            // ReSharper disable once ReturnValueOfPureMethodIsNotUsed
            AssertHasOutEdges(graph, 1, new[] { edge12, edge13 });
            data.CheckCalls(3);
        }
Example #22
0
        protected static void ContainsEdge_Test(
            [NotNull] GraphData <int, Edge <int> > data,
            [NotNull] IEdgeSet <int, Edge <int> > graph)
        {
            data.CheckCalls(0);

            data.ShouldReturnValue = false;
            var edge12 = new Edge <int>(1, 2);
            var edge21 = new Edge <int>(2, 1);

            Assert.IsFalse(graph.ContainsEdge(edge12));
            data.CheckCalls(1);
            Assert.IsFalse(graph.ContainsEdge(edge21));
            data.CheckCalls(1);

            data.ShouldReturnValue = true;
            Assert.IsFalse(graph.ContainsEdge(edge12));
            data.CheckCalls(1);
            Assert.IsFalse(graph.ContainsEdge(edge21));
            data.CheckCalls(1);

            var edge13 = new Edge <int>(1, 3);

            data.ShouldReturnEdges = new[] { edge12, edge13, edge21 };
            Assert.IsTrue(graph.ContainsEdge(edge12));
            data.CheckCalls(1);
            Assert.IsTrue(graph.ContainsEdge(edge21));
            data.CheckCalls(1);

            var edge15 = new Edge <int>(1, 5);
            var edge51 = new Edge <int>(5, 1);
            var edge56 = new Edge <int>(5, 6);

            Assert.IsFalse(graph.ContainsEdge(edge15));
            Assert.IsFalse(graph.ContainsEdge(edge51));
            Assert.IsFalse(graph.ContainsEdge(edge56));
        }
Example #23
0
        private static void ContainsEdge_SourceTarget_GenericTest(
            [NotNull] GraphData <int, Edge <int> > data,
            [NotNull, InstantHandle] Func <int, int, bool> hasEdge,
            bool isDirected = true)
        {
            data.CheckCalls(0);

            data.ShouldReturnValue = false;
            Assert.IsFalse(hasEdge(1, 2));
            data.CheckCalls(1);
            Assert.IsFalse(hasEdge(2, 1));
            data.CheckCalls(1);

            data.ShouldReturnValue = true;
            Assert.IsFalse(hasEdge(1, 2));
            data.CheckCalls(1);
            Assert.IsFalse(hasEdge(2, 1));
            data.CheckCalls(1);

            data.ShouldReturnEdges = new[] { new Edge <int>(1, 3), new Edge <int>(1, 2) };
            Assert.IsTrue(hasEdge(1, 2));
            data.CheckCalls(1);
            if (isDirected)
            {
                Assert.IsFalse(hasEdge(2, 1));
            }
            else
            {
                Assert.IsTrue(hasEdge(2, 1));
            }
            data.CheckCalls(1);

            Assert.IsFalse(hasEdge(1, 5));
            Assert.IsFalse(hasEdge(5, 1));
            Assert.IsFalse(hasEdge(5, 6));
        }
        public void ContainsEdge_SourceTarget()
        {
            var data  = new GraphData <int, Edge <int> >();
            var graph = new DelegateVertexAndEdgeListGraph <int, Edge <int> >(
                Enumerable.Empty <int>(),
                data.TryGetEdges);

            data.CheckCalls(0);

            data.ShouldReturnValue = false;
            Assert.IsFalse(graph.ContainsEdge(1, 2));
            data.CheckCalls(0); // Vertex is not in graph so no need to call user code
            Assert.IsFalse(graph.ContainsEdge(2, 1));
            data.CheckCalls(0); // Vertex is not in graph so no need to call user code

            data.ShouldReturnValue = true;
            Assert.IsFalse(graph.ContainsEdge(1, 2));
            data.CheckCalls(0); // Vertex is not in graph so no need to call user code
            Assert.IsFalse(graph.ContainsEdge(2, 1));
            data.CheckCalls(0); // Vertex is not in graph so no need to call user code

            data.ShouldReturnEdges = new[] { new Edge <int>(1, 3), new Edge <int>(1, 2) };
            Assert.IsFalse(graph.ContainsEdge(1, 2)); // Vertices 1 and 2 are not part or the graph
            data.CheckCalls(0);                       // Vertex is not in graph so no need to call user code
            Assert.IsFalse(graph.ContainsEdge(2, 1));
            data.CheckCalls(0);                       // Vertex is not in graph so no need to call user code


            graph = new DelegateVertexAndEdgeListGraph <int, Edge <int> >(
                new[] { 1, 3 },
                data.TryGetEdges);

            data.ShouldReturnValue = false;
            Assert.IsFalse(graph.ContainsEdge(1, 2));
            data.CheckCalls(1);
            Assert.IsFalse(graph.ContainsEdge(2, 1));
            data.CheckCalls(0); // Vertex is not in graph so no need to call user code

            data.ShouldReturnValue = true;
            Assert.IsFalse(graph.ContainsEdge(1, 2));
            data.CheckCalls(1);
            Assert.IsFalse(graph.ContainsEdge(2, 1));
            data.CheckCalls(0); // Vertex is not in graph so no need to call user code

            data.ShouldReturnEdges = new[] { new Edge <int>(1, 2), new Edge <int>(1, 3) };
            Assert.IsFalse(graph.ContainsEdge(1, 2));   // Vertices 2 is not part or the graph
            data.CheckCalls(1);
            Assert.IsFalse(graph.ContainsEdge(2, 1));
            data.CheckCalls(0); // Vertex is not in graph so no need to call user code

            Assert.IsTrue(graph.ContainsEdge(1, 3));
            data.CheckCalls(1);
            Assert.IsFalse(graph.ContainsEdge(3, 1));
            data.CheckCalls(1);
        }