示例#1
0
 /**
  * @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);
 }
 /**
  * {@inheritdoc}
  */
 public function isAcyclic()
 {
     // The DepthFirstToposortVisitor throws an exception on cycles.
     try {
         DepthFirst::traverse($this, new DepthFirstToposortVisitor());
         return TRUE;
     } catch (RuntimeException $e) {
         return FALSE;
     }
 }
 public function testReachableExceptionOnUnknownVertex()
 {
     DepthFirst::traverse($this->g, $this->vis, $this->v['a']);
     $this->assertFalse($this->vis->getReachable($this->v['e']));
 }