/** * @param Vertex $vertex * @return array */ private function extractVertex(Vertex $vertex) { $locations = $this->extractEntities($vertex->getAttribute('locations', array())); return array('name' => $vertex->getId(), 'usedByCount' => $vertex->getEdgesIn()->count(), 'adt' => $vertex->getAttribute('adt', array()), 'location' => array_shift($locations), 'group' => $vertex->getGroup()); }
/** * create a new Vertex in this Graph from the given input Vertex of another graph * * @param Vertex $originalVertex * @return Vertex new vertex in this graph * @throws RuntimeException if vertex with this ID already exists */ public function createVertexClone(Vertex $originalVertex) { $id = $originalVertex->getId(); if ($this->vertices->hasVertexId($id)) { throw new RuntimeException('Id of cloned vertex already exists'); } $newVertex = new Vertex($this, $id); // TODO: properly set attributes of vertex $newVertex->getAttributeBag()->setAttributes($originalVertex->getAttributeBag()->getAttributes()); $newVertex->setBalance($originalVertex->getBalance()); $newVertex->setGroup($originalVertex->getGroup()); return $newVertex; }