예제 #1
0
        public void ModifyGraph()
        {
            DirectedGraphImpl <string> gr = CreateAcyclicGraph();

            gr.AddNode("3");
            gr.AddEdge("0", "3");
            gr.AddEdge("1", "3");

            gr.RemoveEdge("1", "2");

            string sExp = "(0 s:(1 2 3 ) p:( )) (1 s:(3 ) p:( 0 2 )) (2 s:(1 ) p:( 0 )) (3 s:() p:( 0 1 )) ";

            string s = DumpGraph(gr);

            Assert.AreEqual(sExp, s);

            gr.RemoveEdge("2", "1");
            gr.RemoveEdge("0", "1");
            gr.RemoveEdge("0", "2");

            sExp = "(0 s:(3 ) p:( )) (1 s:(3 ) p:( )) (2 s:() p:( )) (3 s:() p:( 0 1 )) ";

            s = DumpGraph(gr);
            Assert.AreEqual(sExp, s);
        }
예제 #2
0
 public void EdgeCountAfterRemove()
 {
     DirectedGraphImpl<string> gr = new DirectedGraphImpl<string>();
     gr.AddNode("a");
     gr.AddNode("b");
     Assert.AreEqual(0, gr.Successors("a").Count);
     gr.AddEdge("a", "b");
     gr.RemoveEdge("a", "b");
     Assert.AreEqual(0, gr.Successors("a").Count);
     Assert.AreEqual(0, gr.Predecessors("b").Count);
 }    
예제 #3
0
        public void RemoveCaller(Statement stm)
        {
            if (!graphStms.Nodes.Contains(stm))
            {
                return;
            }
            var callees = this.Callees(stm).ToArray();

            foreach (var callee in callees)
            {
                graphStms.RemoveEdge(stm, callee);
            }
        }
예제 #4
0
 public void EdgeCountAfterRemove()
 {
     DirectedGraphImpl<string> gr = new DirectedGraphImpl<string>();
     gr.AddNode("a");
     gr.AddNode("b");
     Assert.AreEqual(0, gr.Successors("a").Count);
     gr.AddEdge("a", "b");
     gr.RemoveEdge("a", "b");
     Assert.AreEqual(0, gr.Successors("a").Count);
     Assert.AreEqual(0, gr.Predecessors("b").Count);
 }