Skip to content

Commit 2e5a1b4

Browse files
committed
Fix Walk::isCycle() by rejecting walks with no edges
1 parent 1fbfa9a commit 2e5a1b4

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/Property/WalkProperty.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,16 @@ public function __construct(Walk $walk)
2323
/**
2424
* checks whether walk is a cycle (i.e. source vertex = target vertex)
2525
*
26+
* A walk with no edges is not considered a cycle. The shortest possible
27+
* cycle is a single loop edge.
28+
*
2629
* @return bool
2730
* @link http://en.wikipedia.org/wiki/Cycle_%28graph_theory%29
2831
*/
2932
public function isCycle()
3033
{
3134
$vertices = $this->walk->getVerticesSequence();
32-
return (reset($vertices) === end($vertices));
35+
return (reset($vertices) === end($vertices) && $this->walk->getEdges());
3336
}
3437

3538
/**

0 commit comments

Comments
 (0)