fixed the case of the unconnected graph.