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))); }
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); }
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); }
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; }
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()); }
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); }
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; }
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(); }
public VectorBuilder(IServiceProvider services, Program program, DirectedGraphImpl <object> jumpGraph) { this.services = services; this.program = program; this.jumpGraph = jumpGraph; }
public void Setup() { graph = new DirectedGraphImpl<string>(); }
private void CompileTest(DirectedGraphImpl<string> e, string entry) { pdg = new DominatorGraph<string>(e, entry); }
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); }
public void Setup() { graph = new DirectedGraphImpl <string>(); }
private void CompileTest(DirectedGraphImpl <string> e, string entry) { pdg = new DominatorGraph <string>(e, entry); }
private DirectedGraphImpl<object> jumpGraph; //$TODO: public VectorBuilder(IServiceProvider services, Program program, DirectedGraphImpl<object> jumpGraph) { this.services = services; this.program = program; this.jumpGraph = jumpGraph; }
public NodeEnumerator(DirectedGraphImpl <T> graph) { this.graph = graph; }
public NodeCollection(DirectedGraphImpl <T> graph) { this.graph = graph; }
private DirectedGraphImpl<object> jumpGraph; //$TODO: public VectorBuilder(IScanner scanner, Program program, DirectedGraphImpl<object> jumpGraph) { this.scanner = scanner; this.program = program; this.jumpGraph = jumpGraph; }
private DirectedGraphImpl <object> jumpGraph; //$TODO: public VectorBuilder(IScanner scanner, Program program, DirectedGraphImpl <object> jumpGraph) { this.scanner = scanner; this.program = program; this.jumpGraph = jumpGraph; }