Gliph\Graph\Digraph::predecessorsOf PHP Method

predecessorsOf() public method

A vertex (B) is a predecessor to another vertex (A) if an arc points from B to A. In such an arc, B is considered the 'tail', A is considered the 'head', as it would be visually represented with an arrow: B -> A Note that, in set terms, g.adjacentTo(x) == g.successorsOf(x) ∪ g.predecessorsOf(x)
public predecessorsOf ( object $vertex ) : Generator
$vertex object The vertex whose predecessor vertices should be enumerated.
return Generator A generator that yields predecessor vertices as values.
    public function predecessorsOf($vertex);

Usage Example

Beispiel #1
0
 public static function insertBefore(Vertex $old, Vertex $new, Digraph $graph)
 {
     $toRemove = array();
     foreach ($graph->predecessorsOf($old) as $node) {
         $graph->ensureArc($node, $new);
         $toRemove[] = $node;
     }
     $graph->ensureArc($new, $old);
     foreach ($toRemove as $node) {
         $graph->removeArc($node, $old);
     }
 }