// Constructor from CFGraph public DepthSpanningTree(CFGraph cfg) { visited = new HashSet <CFGNode>(); Tree = new BidirectionalGraph <CFGNode, Edge <CFGNode> >(); Numbers = new Dictionary <CFGNode, int>(); var root = cfg.GetRoot(); int start = 0; BuildTree(root, ref start); }
public DepthSpanningTree(CFGraph cfg) { int numberOfVertices = cfg.NumberOfVertices() - 1; visited = new HashSet <CFGNode>(); SpanningTree = new BidirectionalGraph <CFGNode, Edge <CFGNode> >(); Numbers = new Dictionary <CFGNode, int>(); var root = cfg.GetRoot(); BuildTree(root, ref numberOfVertices); }
public static CFGraph Build(List <IBaseBlock> blocks) { CFGNode root = new CFGNode(blocks.First()); var currentNode = root; foreach (var block in blocks.Skip(1)) { var directChild = new CFGNode(block); currentNode.SetDirectChild(directChild); var lastOp = currentNode.Value.Enumerate().Last(); if (lastOp.IsGoto()) { var gotoBlock = blocks.First(b => b.Enumerate().First().Label.Equals(lastOp.Destination)); var gotoChild = new CFGNode(gotoBlock); currentNode.SetGotoChild(gotoChild); } currentNode = directChild; } var graph = new CFGraph(blocks); return(graph); }
public NaturalCycleGraph(CFGraph cfg) { this.cfGraph = cfg; }