/** * create new clone/copy of this graph - copy all attributes and vertices, but do NOT copy edges * * using this method is faster than creating a new graph and calling createEdgeClone() yourself * * @return Graph */ public function createGraphCloneEdgeless() { $graph = new Graph(); $graph->getAttributeBag()->setAttributes($this->getAttributeBag()->getAttributes()); // TODO: set additional graph attributes foreach ($this->getVertices() as $originalVertex) { $vertex = $graph->createVertexClone($originalVertex); // $graph->vertices[$vid] = $vertex; } return $graph; }
/** * test to make sure vertex can not be cloned into same graph (due to duplicate id) * * @expectedException RuntimeException */ public function testInvalidVertexClone() { $graph = new Graph(); $vertex = $graph->createVertex(123); $graph->createVertexClone($vertex); }