Performs a topological sort on the provided graph.
public static toposort ( Gliph\Graph\Digraph $graph, object | SplDoublyLinkedList $start = NULL ) : array | ||
$graph | Gliph\Graph\Digraph | |
$start | object | SplDoublyLinkedList | The starting point(s) for the toposort. @see DepthFirst::traverse() |
return | array | A valid topologically sorted list for the provided graph. |
/** * @covers \Gliph\Traversal\DepthFirst::toposort * @expectedException Gliph\Exception\RuntimeException * Thrown by the visitor after adding a cycle to the graph. */ public function testToposort() { extract($this->v); $this->assertEquals(array($c, $d, $b, $a), DepthFirst::toposort($this->g, $a)); $this->g->addDirectedEdge($d, $a); DepthFirst::toposort($this->g, $a); }