public function testGraphDirectedLoop() { // 1 -> 1 $graph = new Graph(); $graph->createVertex(1)->createEdgeTo($v1 = $graph->getVertex(1)); $alg = new AlgorithmLoop($graph); $this->assertTrue($alg->hasLoop()); $this->assertTrue($alg->hasLoopVertex($v1)); }
/** * checks whether this walk HAS a loop (single edge connecting vertex A with vertex A again) * * The following Walk is NOT a valid loop, but it contains a valid loop: * * /->3 * | * 1 -> 2 -\ * ^ | * \--/ * * @return boolean * @uses AlgorithmLoop::hasLoop() * @see self::isLoop() */ public function hasLoop() { $alg = new AlgorithmLoop($this->walk); return $alg->hasLoop(); }