Exemplo n.º 1
0
        public void testRemoveEdgeSimple()
        {
            AdjacencyListGraph <string, string> g = graph(n1, n2);

            g.AddEdge(e1);
            Assert.IsTrue(g.ContainsEdge(e1));
            Assert.IsTrue(g.RemoveEdge(e1));
            Assert.IsFalse(g.ContainsEdge(e1));
            Assert.IsFalse(g.EdgeExists(n1, n2));
        }
Exemplo n.º 2
0
        public void testSetEdgeDataNoDuplicate()
        {
            AdjacencyListGraph <string, string> g = graph(n1, n2);

            g.AddEdge(e1);

            g.ReplaceEdge(e1, "new");
            Assert.IsFalse(g.ContainsEdge(e1));
            Assert.IsTrue(g.ContainsEdge(new Edge <string, string>(e1.Source, e1.Destination, "new")));
        }
Exemplo n.º 3
0
        public void testContainsMultipleEdge()
        {
            AdjacencyListGraph <string, string> g = graph(n1, n2, n3, n4);

            g.AddEdge(e1); g.AddEdge(e2); g.AddEdge(e3); g.AddEdge(e4);
            Assert.IsTrue(g.ContainsEdge(e1));
            Assert.IsTrue(g.ContainsEdge(e2));
            Assert.IsTrue(g.ContainsEdge(e3));
            Assert.IsTrue(g.ContainsEdge(e4));
        }
Exemplo n.º 4
0
        public void testRemovestringWithParentsAndAddAgain()
        {
            AdjacencyListGraph <string, string> g = graph(n1, n2);

            g.AddEdge(e1);

            g.RemoveNode(n2);
            g.AddNode(n2);
            Assert.IsTrue(g.ContainsNode(n2));
            Assert.IsFalse(g.ContainsEdge(e1));
            g.AddEdge(e1);
            Assert.IsTrue(g.ContainsEdge(e1));
        }
Exemplo n.º 5
0
        public void testContainsMultigraphEdge()
        {
            AdjacencyListGraph <string, string> g = graph(n1, n2);
            Edge <string, string> e1 = new Edge <string, string>(n1, n2, "label");
            Edge <string, string> e2 = new Edge <string, string>(n2, n1, "label");
            Edge <string, string> e3 = new Edge <string, string>(n1, n2, "label2");
            Edge <string, string> e4 = new Edge <string, string>(n2, n1, "label2");

            g.AddEdge(e1); g.AddEdge(e2); g.AddEdge(e3); g.AddEdge(e4);
            Assert.IsTrue(g.ContainsEdge(e1));
            Assert.IsTrue(g.ContainsEdge(e2));
            Assert.IsTrue(g.ContainsEdge(e3));
            Assert.IsTrue(g.ContainsEdge(e4));
        }
Exemplo n.º 6
0
        public void testContainsNoEdge()
        {
            AdjacencyListGraph <string, string> g = graph(n1, n2);
            Edge <string, string> e = new Edge <string, string>(n1, n3, "label");

            Assert.IsFalse(g.ContainsEdge(e));
        }
Exemplo n.º 7
0
        public void testContainsSingleEdge()
        {
            AdjacencyListGraph <string, string> g = graph(n1, n2);
            Edge <string, string> e = new Edge <string, string>(n1, n2, "label");

            g.AddEdge(e);
            Assert.IsTrue(g.ContainsEdge(e));
        }
Exemplo n.º 8
0
        public void testRemovestringWithParents()
        {
            AdjacencyListGraph <string, string> g = graph(n1, n2);

            g.AddEdge(e1);

            Assert.IsTrue(g.RemoveNode(n2));
            Assert.IsFalse(g.ContainsNode(n2));
            Assert.IsFalse(g.EdgeExists(n1, n2));
            Assert.IsNull(g.GetEdges(n1, n2));
            Assert.IsFalse(g.ContainsEdge(e1));
        }
Exemplo n.º 9
0
        public void testContainsEdgeNull()
        {
            AdjacencyListGraph <string, string> g = graph();

            g.ContainsEdge <string, string>(null);
        }