Added helper functions to test if graph is tree or line.
Resolved merge conflicts.