Exemplo n.º 1
0
 /**
  * Filters the graph so that only entities connected to the root are left
  *
  * Should be run after you've added some set of associations with from()
  *
  * @return void
  */
 public function filterConnected()
 {
     $alg = new BreadthFirst($this->graph->getVertex($this->root));
     $alg->setDirection(BreadthFirst::DIRECTION_REVERSE);
     $vertices = $alg->getVertices();
     $this->graph = $this->graph->createGraphCloneVertices($vertices);
 }
Exemplo n.º 2
0
 public function testCreateGraphCloneVertices()
 {
     // 1 -- 2 -- 3
     $graph = new Graph();
     $v1 = $graph->createVertex(1);
     $v2 = $graph->createVertex(2);
     $v3 = $graph->createVertex(3);
     $e1 = $v1->createEdgeTo($v2);
     $e2 = $v2->createEdgeTo($v3);
     $graphClone = $graph->createGraphCloneVertices(array(1 => $v1, 2 => $v2));
     $this->assertEquals(2, count($graphClone->getVertices()));
     $this->assertEquals(1, count($graphClone->getEdges()));
 }