Skip to content

Latest commit

 

History

History
 
 

graph-valid-tree

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

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.