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); }
public function testFactoryEmptyArray() { $vertices = Vertices::factory(array()); $this->assertInstanceOf('Fhaculty\\Graph\\Set\\Vertices', $vertices); $this->assertTrue($vertices->isEmpty()); }
/** * 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; }
protected function __construct($vertices, $edges) { $this->vertices = Vertices::factory($vertices); $this->edges = Edges::factory($edges); }