For checkConnected method (1st solution), the default source used is 0. Does that mean for a tree, the mother vertex must be 0? becuase for the following scenario, the first solution will not work if the mother vertex is not 0.
edge(1, 0)
edge(1, 2)