/** * create new clone of the given edge between adjacent vertices * * @param Edge $originalEdge original edge from old graph * @param int $ia index of start vertex * @param int $ib index of end vertex * @return Edge new edge in this graph * @uses Edge::getVertices() * @uses Graph::getVertex() * @uses Vertex::createEdge() to create a new undirected edge if given edge was undrected * @uses Vertex::createEdgeTo() to create a new directed edge if given edge was directed * @uses Edge::getWeight() * @uses Edge::setWeight() * @uses Edge::getFlow() * @uses Edge::setFlow() * @uses Edge::getCapacity() * @uses Edge::setCapacity() */ private function createEdgeCloneInternal(Edge $originalEdge, $ia, $ib) { $ends = $originalEdge->getVertices()->getIds(); // get start vertex from old start vertex id $a = $this->getVertex($ends[$ia]); // get target vertex from old target vertex id $b = $this->getVertex($ends[$ib]); if ($originalEdge instanceof EdgeDirected) { $newEdge = $a->createEdgeTo($b); } else { // create new edge between new a and b $newEdge = $a->createEdge($b); } // TODO: copy edge attributes $newEdge->getAttributeBag()->setAttributes($originalEdge->getAttributeBag()->getAttributes()); $newEdge->setWeight($originalEdge->getWeight()); $newEdge->setFlow($originalEdge->getFlow()); $newEdge->setCapacity($originalEdge->getCapacity()); return $newEdge; }