Exemple #1
0
        VfGraph SetupGraph()
        {
            var graph = new Graph();

            Assert.AreEqual(0, graph.InsertVertex());
            Assert.AreEqual(1, graph.InsertVertex());
            Assert.AreEqual(2, graph.InsertVertex());
            Assert.AreEqual(3, graph.InsertVertex());
            Assert.AreEqual(4, graph.InsertVertex());
            Assert.AreEqual(5, graph.InsertVertex());
            graph.AddEdge(0, 1);
            graph.AddEdge(1, 2);
            graph.AddEdge(2, 3);
            graph.AddEdge(3, 4);
            graph.AddEdge(4, 5);
            graph.AddEdge(5, 0);
            graph.DeleteVertex(0);
            graph.DeleteVertex(1);
            graph.AddEdge(5, 2);
            graph.AddEdge(2, 4);

            return(new VfGraph(graph));
        }
Exemple #2
0
        public void TestDeleteVertex()
        {
            var gr = new Graph();

            Assert.AreEqual(0, gr.InsertVertex());
            Assert.AreEqual(1, gr.InsertVertex());
            Assert.AreEqual(2, gr.InsertVertex());
            gr.AddEdge(0, 1);
            gr.AddEdge(1, 2);
            gr.AddEdge(2, 0);
            gr.DeleteVertex(0);

            Assert.AreEqual(1, gr.OutEdgeCount(1));
            Assert.AreEqual(0, gr.OutEdgeCount(2));

            // Trigger the exception - shouldn't be a zero vertex any more...
            Assert.Throws(typeof(VfException), () => gr.FindVertex(0));
        }