Fixed minor error in finding out if graph is connected