Example #1
0
        public void UndirectGraphDeleteVertexTest()
        {
            UndirectGraph<int> graph = new UndirectGraph<int>();
            graph.AddEdge(0, 1);
            graph.AddEdge(2, 0);
            graph.AddVertex(3);

            graph.DeleteVertex(3);
            graph.DeleteVertex(2);

            string t1 = String.Format("{0} -> {1}{2}{1} -> {0}{2}", 0, 1, Environment.NewLine);
            Assert.AreEqual(t1, graph.ToString());

            graph.DeleteVertex(0);
            graph.DeleteVertex(0);

            string t2 = String.Format("{0}{1}", 1, Environment.NewLine);
            Assert.AreEqual(t2, graph.ToString());

            graph.DeleteVertex(1);
            Assert.AreEqual("", graph.ToString());
            Assert.AreEqual(0, graph.CountVertices);
            Assert.AreEqual(0, graph.CountEdges);
        }