Ejemplo n.º 1
0
 /**
  * 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);
 }
Ejemplo n.º 2
0
 /**
  * @covers ::computeImmediatePredecessors
  * @covers ::findAllSuccessors
  */
 public function testComputeImmediatePredecessorsWithCycle()
 {
     $this->graph->ensureArc($this->v[4], $this->v[1]);
     $pred = Helper::computeImmediatePredecessors($this->graph);
     $this->assertSame([], $pred[$this->v[0]]);
     $this->assertSame([$this->v[0], $this->v[4]], $pred[$this->v[1]]);
     $this->assertSame([$this->v[1]], $pred[$this->v[2]]);
     $this->assertSame([$this->v[1]], $pred[$this->v[3]]);
     $this->assertSame([$this->v[2], $this->v[3]], $pred[$this->v[4]]);
     $this->assertSame([$this->v[4]], $pred[$this->v[5]]);
 }