Beispiel #1
0
 /**
  * create new Edges instance
  *
  * You can pass in just about anything that can be expressed as a Set of
  * Edges, such as:
  * - an array of Edge instances
  * - any Algorithm that implements the EdgesAggregate interface
  * - a Graph instance or
  * - an existing Set of Edges which will be returned as-is
  *
  * @param array|Edges|EdgesAggregate $edges
  * @return Edges
  */
 public static function factory($edges)
 {
     if ($edges instanceof EdgesAggregate) {
         return $edges->getEdges();
     }
     return new self($edges);
 }
Beispiel #2
0
 private function getEdgeCloneInternal(Edge $edge, Vertex $startVertex, Vertex $targetVertex)
 {
     // Get original vertices from resultgraph
     $residualGraphEdgeStartVertex = $this->getVertex($startVertex->getId());
     $residualGraphEdgeTargetVertex = $this->getVertex($targetVertex->getId());
     // Now get the edge
     $residualEdgeArray = $residualGraphEdgeStartVertex->getEdgesTo($residualGraphEdgeTargetVertex);
     $residualEdgeArray = Edges::factory($residualEdgeArray)->getVector();
     // Check for parallel edges
     if (!$residualEdgeArray) {
         throw new UnderflowException('No original edges for given cloned edge found');
     } elseif (count($residualEdgeArray) !== 1) {
         throw new OverflowException('More than one cloned edge? Parallel edges (multigraph) not supported');
     }
     return $residualEdgeArray[0];
 }
Beispiel #3
0
 public function testIntersectionEmpty()
 {
     $edges1 = new Edges();
     $edges2 = new Edges();
     $edges3 = $edges1->getEdgesIntersection($edges2);
     $this->assertCount(0, $edges3);
 }
Beispiel #4
0
 /**
  *
  * @param Edges $edges
  * @depends testTwo
  * @expectedException UnderflowException
  */
 public function testTwoMatchFail(Edges $edges)
 {
     $edges->getEdgeMatch(array($this, 'returnFalse'));
 }
Beispiel #5
0
 /**
  * get alternating sequence of vertex, edge, vertex, edge, ..., vertex
  *
  * @return array
  */
 public function getAlternatingSequence()
 {
     $edges = $this->edges->getVector();
     $vertices = $this->vertices->getVector();
     $ret = array();
     for ($i = 0, $l = count($this->edges); $i < $l; ++$i) {
         $ret[] = $vertices[$i];
         $ret[] = $edges[$i];
     }
     $ret[] = $vertices[$i];
     return $ret;
 }