/** * {@inheritdoc} */ public function add(VertexInterface $vertex) { if (array_key_exists($vertex->getId(), $this->getVertices())) { throw new Exception('Unable to insert multiple Vertices with the same ID in a Graph'); } $this->vertices[$vertex->getId()] = $vertex; return $this; }