Пример #1
0
        public void AddEdge(Statement stmCaller, Procedure callee)
        {
            graphProcs.AddNode(stmCaller.Block.Procedure);
            graphProcs.AddNode(callee);
            graphProcs.AddEdge(stmCaller.Block.Procedure, callee);

            graphStms.AddNode(stmCaller);
            graphStms.AddNode(callee);
            graphStms.AddEdge(stmCaller, callee);
        }
Пример #2
0
        public void PostOrderGraph2()
        {
            DirectedGraphImpl <string> graph = new DirectedGraphImpl <string>();

            graph.AddNode("a");
            graph.AddNode("b");
            graph.AddEdge("a", "a");
            graph.AddEdge("a", "b");
            DumpPostOrderIterator("a", CreateGraphIterator <string>(graph));
            Assert.AreEqual("b,a", sb.ToString());
        }
Пример #3
0
        public void EdgeCountAfterAdd()
        {
            DirectedGraphImpl <string> gr = new DirectedGraphImpl <string>();

            gr.AddNode("a");
            gr.AddNode("b");
            Assert.AreEqual(0, gr.Successors("a").Count);
            gr.AddEdge("a", "b");
            Assert.AreEqual(1, gr.Successors("a").Count);
            Assert.AreEqual(1, gr.Predecessors("b").Count);
        }
Пример #4
0
		private DirectedGraphImpl<string> CreateAcyclicGraph()
		{
			DirectedGraphImpl<string> gr = new DirectedGraphImpl<string>();
			gr.AddNode("0");
			gr.AddNode("1");
			gr.AddNode("2");

			gr.AddEdge("0", "1");
			gr.AddEdge("0", "2");
			gr.AddEdge("1", "2");
			gr.AddEdge("2", "1");
		
			return gr;
		}
Пример #5
0
		private DirectedGraphImpl<string> CreateAcyclicGraph()
		{
			DirectedGraphImpl<string> gr = new DirectedGraphImpl<string>();
			gr.AddNode("0");
			gr.AddNode("1");
			gr.AddNode("2");

			gr.AddEdge("0", "1");
			gr.AddEdge("0", "2");
			gr.AddEdge("1", "2");
			gr.AddEdge("2", "1");
		
			return gr;
		}
Пример #6
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);
        }
Пример #7
0
        public void SingleItem()
        {
            graph.AddNode("a");
            CompileTest(graph, "a");

            Assert.AreEqual(null, pdg.ImmediateDominator("a"));
        }
Пример #8
0
 public void Add(T node)
 {
     graph.AddNode(node);
 }
Пример #9
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);
 }