Пример #1
0
        private DerivedGraph BuildNextOrderGraph(DerivedGraph gr)
        {
            DirectedGraph <StructureNode> newGraph = new DirectedGraphImpl <StructureNode>();
            StructureNode newEntry = gr.Intervals[0];

            foreach (Interval interval in gr.Intervals)
            {
                newGraph.Nodes.Add(interval);
            }

            foreach (Interval interval in gr.Intervals)
            {
                foreach (StructureNode node in interval.Nodes)
                {
                    foreach (StructureNode succ in gr.Graph.Successors(node))
                    {
                        if (succ.Interval != interval && !newGraph.ContainsEdge(interval, succ.Interval))
                        {
                            newGraph.AddEdge(interval, succ.Interval);
                        }
                    }
                }
            }
            return(new DerivedGraph(newGraph, newEntry, ib.BuildIntervals(newGraph, newEntry)));
        }
Пример #2
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);
        }
Пример #3
0
        public void SimpleGraph()
        {
            DirectedGraphImpl <string> gr = CreateAcyclicGraph();
            string sExp = "(0 s:(1 2 ) p:( )) (1 s:(2 ) p:( 0 2 )) (2 s:(1 ) p:( 0 1 )) ";
            string s    = DumpGraph(gr);

            Assert.AreEqual(sExp, s);
        }
Пример #4
0
 public EdgeCollection(DirectedGraphImpl <T> graph, int iNode, bool fSuccessor)
 {
     if (iNode < 0)
     {
         throw new ArgumentException("Invalid node.");
     }
     this.graph      = graph;
     this.iNode      = iNode;
     this.fSuccessor = fSuccessor;
 }
Пример #5
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());
        }
Пример #6
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);
        }
Пример #7
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;
		}
Пример #8
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;
		}
Пример #9
0
		private string DumpGraph(DirectedGraphImpl<string> gr)
		{
			StringBuilder sb = new StringBuilder();
			foreach (string n in gr.Nodes)
			{
				sb.AppendFormat("({0} s:(", n);
				foreach (string i in gr.Successors(n))
				{
					sb.AppendFormat("{0} ", i);
				}
				sb.Append(") p:( ");
				foreach (string p in gr.Predecessors(n))
				{
					sb.AppendFormat("{0} ", p);
				}
				sb.Append(")) ");
			}
			return sb.ToString();
		}
Пример #10
0
		private string DumpGraph(DirectedGraphImpl<string> gr)
		{
			StringBuilder sb = new StringBuilder();
			foreach (string n in gr.Nodes)
			{
				sb.AppendFormat("({0} s:(", n);
				foreach (string i in gr.Successors(n))
				{
					sb.AppendFormat("{0} ", i);
				}
				sb.Append(") p:( ");
				foreach (string p in gr.Predecessors(n))
				{
					sb.AppendFormat("{0} ", p);
				}
				sb.Append(")) ");
			}
			return sb.ToString();
		}
Пример #11
0
 public VectorBuilder(IServiceProvider services, Program program, DirectedGraphImpl <object> jumpGraph)
 {
     this.services  = services;
     this.program   = program;
     this.jumpGraph = jumpGraph;
 }
Пример #12
0
        public void Setup()
        {
            graph = new DirectedGraphImpl<string>();

        }
Пример #13
0
 private void CompileTest(DirectedGraphImpl<string> e, string entry)
 {
     pdg = new DominatorGraph<string>(e, entry);
 }
Пример #14
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);
 }    
Пример #15
0
 public void Setup()
 {
     graph = new DirectedGraphImpl <string>();
 }
Пример #16
0
 private void CompileTest(DirectedGraphImpl <string> e, string entry)
 {
     pdg = new DominatorGraph <string>(e, entry);
 }
Пример #17
0
        private DirectedGraphImpl<object> jumpGraph;        //$TODO:

        public VectorBuilder(IServiceProvider services, Program program, DirectedGraphImpl<object> jumpGraph)
        {
            this.services = services;
            this.program = program;
            this.jumpGraph = jumpGraph;
        }
Пример #18
0
 public NodeEnumerator(DirectedGraphImpl <T> graph)
 {
     this.graph = graph;
 }
Пример #19
0
 public NodeCollection(DirectedGraphImpl <T> graph)
 {
     this.graph = graph;
 }
Пример #20
0
        private DirectedGraphImpl<object> jumpGraph;        //$TODO:

        public VectorBuilder(IScanner scanner, Program program, DirectedGraphImpl<object> jumpGraph)
        {
            this.scanner = scanner;
            this.program = program;
            this.jumpGraph = jumpGraph;
        }
Пример #21
0
        private DirectedGraphImpl <object> jumpGraph;        //$TODO:

        public VectorBuilder(IScanner scanner, Program program, DirectedGraphImpl <object> jumpGraph)
        {
            this.scanner   = scanner;
            this.program   = program;
            this.jumpGraph = jumpGraph;
        }