Find the Cycles
Collapse Content
Show Content
Both Trees and Graphs consist of Nodes pointing to each other. In fact, a tree is just a type of graph that contains no cycles. A cycle means you can leave a node along one path and return to it on a different path. Given a Graph in the original format, can you determine if there are any cycles in it?
No Cycles in this Graph:
But there are multiple Cycles in this Graph:
Challenge
Print true if the graph has a cycle and false otherwise.
Please sign in or sign up to submit answers.
Alternatively, you can try out Learneroo before signing up.