Algorithm - Checking if an unconnected graph is cyclical
As part of the cycle checking, you already need to keep track of which vertices have been visited. So just restart at the first unvisited vertex each time you exhaust a component.