Beispiel #1
0
 public function testFactory()
 {
     $graph = new Graph();
     $vertex = $graph->createVertex();
     $verticesFromArray = $this->createVertices(array($vertex));
     $this->assertInstanceOf('Fhaculty\\Graph\\Set\\Vertices', $verticesFromArray);
     $this->assertSame($vertex, $verticesFromArray->getVertexFirst());
     $verticesFromVertices = Vertices::factory($verticesFromArray);
     $this->assertSame($verticesFromArray, $verticesFromVertices);
 }
Beispiel #2
0
 public function testFactoryEmptyArray()
 {
     $vertices = Vertices::factory(array());
     $this->assertInstanceOf('Fhaculty\\Graph\\Set\\Vertices', $vertices);
     $this->assertTrue($vertices->isEmpty());
 }
Beispiel #3
0
 /**
  * create a new clone/copy of this graph - copy all attributes and given vertices and its edges
  *
  * @param  Vertices $vertices set of vertices to keep
  * @return Graph
  * @uses Graph::createGraphClone() to create a complete clone
  * @uses Vertex::destroy() to remove unneeded vertices again
  */
 public function createGraphCloneVertices($vertices)
 {
     $verticesKeep = Vertices::factory($vertices);
     $graph = $this->createGraphClone();
     foreach ($graph->getVertices()->getMap() as $vid => $vertex) {
         if (!$verticesKeep->hasVertexId($vid)) {
             $vertex->destroy();
         }
     }
     return $graph;
 }
Beispiel #4
0
 protected function __construct($vertices, $edges)
 {
     $this->vertices = Vertices::factory($vertices);
     $this->edges = Edges::factory($edges);
 }