protected function getLayoutVertex(Vertex $vertex) { $layout = $vertex->getLayout(); $balance = $vertex->getBalance(); if ($balance !== NULL) { if ($balance > 0) { $balance = '+' . $balance; } if (!isset($layout['label'])) { $layout['label'] = $vertex->getId(); } $layout['label'] .= ' (' . $balance . ')'; } return $layout; }
/** * 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->setLayout($originalVertex->getLayout()); $newVertex->setBalance($originalVertex->getBalance()); $newVertex->setGroup($originalVertex->getGroup()); return $newVertex; }