/** * Build the dominator tree, and initialize it * * @param DirectedAdjacencyList $graph The graph to build the tree for * @param Vertex $start The start node of the dominator */ public function __construct(Digraph $graph, Vertex $start) { $this->dominator = new \SplObjectStorage(); $this->graph = $graph; $this->predecessors = Helper::computePredecessors($this->graph); $this->iPredecessors = Helper::computeImmediatePredecessors($this->graph); $this->build($start); }
/** * @covers ::computePredecessors * @covers ::findAllSuccessors */ public function testComputePredecessorsWithCycle() { $this->graph->ensureArc($this->v[4], $this->v[1]); $pred = Helper::computePredecessors($this->graph); $this->assertSame([$this->v[0], $this->v[4], $this->v[2], $this->v[1], $this->v[3]], $pred[$this->v[1]]); }