First page Back Continue Last page Graphics
Cycles
If a graph contains cycles then it is possible for simple traversal algorithms to loop indefinitely; visiting the same node(s) repeatedly.
To prevent this nodes are “marked” when they are first visited and the traversal never visits a marked node.
- Nodes can be marked by setting true in an array or by the presence of the Node as a key in some Hash or Tree map.