示例#1
0
        public void RemoveNodeNotInGraphFromGraph()
        {
            Graph graph = new Graph(1);

            Node a = new Node("a");
            Node b = new Node("b");

            graph.AddNode(a);
            
            Assert.IsFalse(graph.RemoveNode(b));
        }
示例#2
0
        public void RemoveNodeInGraphFromGraph()
        {
            Graph actual = new Graph(1);
            Graph expected = new Graph(1);

            Node a = new Node("a");
            Node b = new Node("b");

            actual.AddNode(a);
            actual.AddNode(b);
            actual.RemoveNode(b);

            expected.AddNode(a);

            Assert.IsTrue(actual.Equals(expected));
        }
示例#3
0
        public void RemoveNodeWithEdgesInGraphFromGraph()
        {
            Graph actual = new Graph(1);
            Graph expected = new Graph(1);

            Node a = new Node("a");
            Node b = new Node("b");

            Edge ab = new Edge(2);

            actual.AddNode(a);
            actual.AddNode(b);

            actual.AddUndirectedEdge(new Tuple<Node, int>(a, 0), new Tuple<Node, int>(b, 0), ab);

            actual.RemoveNode(b);

            expected.AddNode(a);

            Assert.IsTrue(actual.Equals(expected));
        }
示例#4
0
        public void TwoGraphWithTwoNodeOneRemoved()
        {
            Graph g1 = new Graph(1);
            Graph g2 = new Graph(2);

            Node a = new Node("a");
            Node b = new Node("b");
            Node c = new Node("b");

            g1.AddNode(a);
            g1.AddNode(b);
            g1.AddNode(c);
            g1.RemoveNode(c);

            g2.AddNode(a);
            g2.AddNode(b);
            g2.AddNode(c);
            g2.RemoveNode(c);

            Assert.IsFalse(g1.Equals(g2));
        }