File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Fhaculty \Graph \Algorithm ;
4
+
5
+ use Fhaculty \Graph \Algorithm \BaseSet ;
6
+ use Fhaculty \Graph \Edge \Base as Edge ;
7
+ use Fhaculty \Graph \Vertex ;
8
+
9
+ /**
10
+ * Basic algorithms for working with loop edges
11
+ *
12
+ * A loop (also called a self-loop or a "buckle") is an edge that connects a
13
+ * Vertex to itself. A simple graph contains no loops.
14
+ *
15
+ * @link http://en.wikipedia.org/wiki/Loop_%28graph_theory%29
16
+ */
17
+ class Loop extends BaseSet
18
+ {
19
+ /**
20
+ * checks whether this graph has any loops (edges from vertex to itself)
21
+ *
22
+ * @return boolean
23
+ * @uses Edge::isLoop()
24
+ */
25
+ public function hasLoop ()
26
+ {
27
+ foreach ($ this ->set ->getEdges () as $ edge ) {
28
+ if ($ edge ->isLoop ()) {
29
+ return true ;
30
+ }
31
+ }
32
+
33
+ return false ;
34
+ }
35
+ }
You can’t perform that action at this time.
0 commit comments