README Algorithm A graph is a tree if: No cycle Connected So we are going to check no cycle and all nodes have been visited. We can test hasCycle from any node since any node in a tree can be the root. So we can start from any node.