/** * get set of all Edges parallel to this edge (excluding self) * * @param Edge $edge * @return Edges * @throws LogicException */ public function getEdgesParallelEdge(Edge $edge) { if ($edge instanceof DirectedEdge) { // get all edges between this edge's endpoints $edges = $edge->getVertexStart()->getEdgesTo($edge->getVertexEnd())->getVector(); } else { // edge points into both directions (undirected/bidirectional edge) // also get all edges in other direction $ends = $edge->getVertices(); $edges = $ends->getVertexFirst()->getEdges()->getEdgesIntersection($ends->getVertexLast()->getEdges())->getVector(); } $pos = array_search($edge, $edges, true); if ($pos === false) { // @codeCoverageIgnoreStart throw new LogicException('Internal error: Current edge not found'); // @codeCoverageIgnoreEnd } // exclude current edge from parallel edges unset($edges[$pos]); return new Edges(array_values($edges)); }
public function testEdgeVertices() { $this->assertEquals(array($this->v1, $this->v2), $this->edge->getVertices()->getVector()); $this->assertEquals(array(1, 2), $this->edge->getVertices()->getIds()); $this->assertSame($this->graph, $this->edge->getGraph()); }
/** * Extracts inverted edge from this graph * * @param Edge $edge * @return Edge * @throws UnderflowException if no edge was found * @throws OverflowException if multiple edges match */ public function getEdgeCloneInverted(Edge $edge) { // Extract endpoints from edge $vertices = $edge->getVertices()->getVector(); return $this->getEdgeCloneInternal($edge, $vertices[1], $vertices[0]); }