Beispiel #1
0
            public void TestDeleteEdge()
            {
                Graph gr = new Graph();

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

                // Trigger the exception - no edge from 1 to 0...
                gr.DeleteEdge(1, 0);
            }
Beispiel #2
0
        public void TestDeleteEdge()
        {
            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.DeleteEdge(1, 2);
            Assert.AreEqual(1, gr.OutEdgeCount(0));
            Assert.AreEqual(0, gr.OutEdgeCount(1));
            Assert.AreEqual(1, gr.OutEdgeCount(2));

            // Trigger the exception - no edge from 1 to 0...
            Assert.Throws(typeof(VfException), () => gr.DeleteEdge(1, 0));
        }
Beispiel #3
0
            public void TestMatchComplex()
            {
                VfState vfs = VfsTest();

                Assert.IsTrue(vfs.FMatch());
                Graph graph2 = VfsTestGraph2();

                graph2.DeleteEdge(1, 4);
                graph2.InsertEdge(2, 4);
                vfs = new VfState(VfsTestGraph1(), graph2);
                Assert.IsFalse(vfs.FMatch());

                Graph graph1 = new Graph();

                graph1.InsertNodes(11);
                graph2 = new Graph();
                graph2.InsertNodes(11);

                graph1.InsertEdge(0, 2);
                graph1.InsertEdge(0, 1);
                graph1.InsertEdge(2, 4);
                graph1.InsertEdge(2, 5);
                graph1.InsertEdge(1, 5);
                graph1.InsertEdge(1, 3);
                graph1.InsertEdge(4, 7);
                graph1.InsertEdge(5, 7);
                graph1.InsertEdge(5, 8);
                graph1.InsertEdge(5, 6);
                graph1.InsertEdge(3, 6);
                graph1.InsertEdge(7, 10);
                graph1.InsertEdge(6, 9);
                graph1.InsertEdge(10, 8);
                graph1.InsertEdge(8, 9);

                graph2.InsertEdge(0, 1);
                graph2.InsertEdge(0, 9);
                graph2.InsertEdge(1, 2);
                graph2.InsertEdge(1, 10);
                graph2.InsertEdge(9, 10);
                graph2.InsertEdge(9, 8);
                graph2.InsertEdge(2, 3);
                graph2.InsertEdge(10, 3);
                graph2.InsertEdge(10, 5);
                graph2.InsertEdge(10, 7);
                graph2.InsertEdge(8, 7);
                graph2.InsertEdge(3, 4);
                graph2.InsertEdge(7, 6);
                graph2.InsertEdge(4, 5);
                graph2.InsertEdge(5, 6);

                vfs = new VfState(graph1, graph2, true);
                Assert.IsTrue(vfs.FMatch());
            }