@@ -37,7 +37,21 @@ public function __construct(Walk $walk)
37
37
* also known as an open path.
38
38
*
39
39
* A walk with no edges is not considered a cycle. The shortest possible
40
- * cycle is a single loop edge.
40
+ * cycle is a single loop edge:
41
+ *
42
+ * 1--\
43
+ * ^ |
44
+ * \--/
45
+ *
46
+ * The following Walk is also considered a valid cycle:
47
+ *
48
+ * /->3--\
49
+ * | |
50
+ * 1 -> 2 -\ |
51
+ * ^ ^ | |
52
+ * | \--/ |
53
+ * | |
54
+ * \----------/
41
55
*
42
56
* @return bool
43
57
* @link http://en.wikipedia.org/wiki/Cycle_%28graph_theory%29
@@ -106,9 +120,11 @@ public function isPath()
106
120
/**
107
121
* checks whether walk contains a cycle (i.e. contains a duplicate vertex)
108
122
*
109
- * a walk that CONTAINS a cycle does not neccessarily have to BE a cycle
123
+ * A walk that CONTAINS a cycle does not neccessarily have to BE a cycle.
124
+ * Conversely, a Walk that *is* a cycle, automatically always *contains* a
125
+ * cycle.
110
126
*
111
- * The following Walk is NOT a cycle, but it contains a valid cycle:
127
+ * The following Walk is NOT a cycle, but it * contains* a valid cycle:
112
128
*
113
129
* /->4
114
130
* |
@@ -128,6 +144,17 @@ public function hasCycle()
128
144
/**
129
145
* checks whether this walk IS a loop (single edge connecting vertex A with vertex A again)
130
146
*
147
+ * A loop is the simplest possible cycle. As such, each loop is also a
148
+ * cycle. Accordingly, every Walk that *is* a loop, automatically also *is*
149
+ * a cycle and automatically *contains* a loop and automatically *contains*
150
+ * a cycle.
151
+ *
152
+ * The following Walk represents a simple (directed) loop:
153
+ *
154
+ * 1--\
155
+ * ^ |
156
+ * \--/
157
+ *
131
158
* @return boolean
132
159
* @uses self::isCycle()
133
160
* @see self::hasLoop()
@@ -172,7 +199,7 @@ public function hasLoop()
172
199
* \--/
173
200
*
174
201
* The following Graph represents a digon as a set of antiparallel directed
175
- * Edges in directed Graph:
202
+ * Edges in a directed Graph:
176
203
*
177
204
* 1 -> 2
178
205
* ^ |
@@ -225,9 +252,44 @@ public function isTriangle()
225
252
*
226
253
* A simple Walk is also known as a chain.
227
254
*
255
+ * The term "simple walk" is somewhat related to a walk with no cycles. If
256
+ * a Walk has a cycle, it is not simple - with one single exception: a Walk
257
+ * that IS a cycle automatically also contains a cycle, but if it contains
258
+ * no "further" additional cycles, it is considered a simple cycle.
259
+ *
260
+ * The following Graph represents a (very) simple Walk:
261
+ *
262
+ * 1 -- 2
263
+ *
264
+ * The following Graph IS a cycle and is simple:
265
+ *
266
+ * 1 -> 2
267
+ * ^ |
268
+ * \----/
269
+ *
270
+ * The following Graph contains a cycle and is NOT simple:
271
+ *
272
+ * /->4
273
+ * |
274
+ * 1 -> 2 -> 3 -\
275
+ * ^ |
276
+ * \-------/
277
+ *
278
+ * The following Graph IS a cycle and thus automatically contains a cycle.
279
+ * Due to the additional "inner" cycle (loop at vertex 2), it is NOT simple:
280
+ *
281
+ * /->3--\
282
+ * | |
283
+ * 1 -> 2 -\ |
284
+ * ^ ^ | |
285
+ * | \--/ |
286
+ * | |
287
+ * \----------/
288
+ *
228
289
* @return boolean
229
290
* @uses self::isCycle()
230
291
* @uses self::hasArrayDuplicates()
292
+ * @see self::hasCycle()
231
293
*/
232
294
public function isSimple ()
233
295
{
0 commit comments