I think the idea is that he's already got the rooms connected in the way that he wants them to be connected, through some special algorithm. The problem is that that algorithm does not guarantee that there aren't separated components of the map.
In this case, again, the easiest way would be to simply flood-fill from one point and see if all rooms are connected. If you just connected rooms, you can probably have some kind of data-structure which tells you which rooms are connected to which other rooms. You should work over this structure instead of flood-filling, as it will surely be easier. Here's some pseudo-code:
ConnectAll(Map<Room, Set<Room>> connections){ // For each room, connections this tells you all other rooms that it's connected to.
while(true) {
InitialRoom = getRandomFrom(connections.keys()); // Get some random room
Set<Room> itStart = {}; // Set of rooms at the start of the iteration
Set<Room> itEnd = {InitialRoom}; // Set of rooms at the start of the iteration
while(itStart != itEnd) { // We'll stop once there are no more differences
Set<Room> newAdded = itEnd - itStart; // These are newly added rooms to the component
itStart = itEnd;
forEach(i: newAdded)
itEnd.addAll(connections[i]);
}
if(itStart.size < connections.size){
Room connectionStart = getRandomFrom(itStart); // Get a random room from the totally connected component we just calculated
Room connectionEnd = getRandomFrom(connections.getSetOfKeys() - itStart); // get a random room that does NOT belong to the component we calculated
connections[connectionStart].add(connectionEnd); // connect them!
} else {
return;
}
}
}
Sheesh, "pseudo-code" is harder to write than actual code. Bleh. I hope it gets the idea through though.