Skip to content

Commit e1ad5b4

Browse files
committed
Add WalkProperty::hasLoop() alias (completeness)
1 parent 9bd6d16 commit e1ad5b4

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/Property/WalkProperty.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Fhaculty\Graph\Walk;
66
use Fhaculty\Graph\Algorithm\Base as BaseAlgorithm;
7+
use Fhaculty\Graph\Algorithm\Loop as AlgorithmLoop;
78

89
/**
910
* Simple algorithms for working with Walk properties
@@ -57,16 +58,31 @@ public function hasCycle()
5758
}
5859

5960
/**
60-
* checks whether this walk is a loop (single edge connecting vertex A with vertex A again)
61+
* checks whether this walk IS a loop (single edge connecting vertex A with vertex A again)
6162
*
6263
* @return boolean
6364
* @uses self::isCycle()
65+
* @see self::hasLoop()
6466
*/
6567
public function isLoop()
6668
{
6769
return ($this->walk->getNumberOfEdges() === 1 && $this->isCycle());
6870
}
6971

72+
/**
73+
* checks whether this walk HAS a look (single edge connecting vertex A with vertex A again)
74+
*
75+
* @return boolean
76+
* @uses AlgorithmLoop::hasLoop()
77+
* @see self::isLoop()
78+
*/
79+
public function hasLoop()
80+
{
81+
$alg = new AlgorithmLoop($this->walk);
82+
83+
return $alg->hasLoop();
84+
}
85+
7086
/**
7187
* checks whether this walk is a digon (a pair of parallel edges in a multigraph or a pair of antiparallel edges in a digraph)
7288
*

0 commit comments

Comments
 (0)