I keep hearing about people who are having problems with their dungeon generator not connecting a bunch of rooms. So, here's an easy way to make sure that everything connects. First, you'll need an array of integers the size of the dungeon. Fill this array with the number -1 to start. Number every tile the player can walk on sequentially using the array, such that every tile that the player can walk on has a different number in the array.
Then loop over the array repeatedly. Any location in the array where one number is next to a different number, change the location's number to the different number. Further, change all places in the array that contain the location's old number to the new number. Don't change any numbers to -1 under any circumstances, ever.
Once that's done, find any two different numbers on the map, and connect those two locations. Then change every tile that contains the first number to the second number. Do this until there are no different numbers on the map. If you want a really good map, I suggest always picking the two closest different numbers, instead of picking two at random. Again, never pick any tile that has a -1.
Congratulations, every tile on your map is now guaranteed to connect. Here's a small example of how this goes:
Starting with:
#...#
#.###
#.#.#
###.#
First we number all the empty tiles, and place -1 anywhere we can't walk (On all the #s in this case). To make things look nice, I'm going to leave those as # instead of -1. Here's what we have after:
#123#
#4###
#5#6#
###7#
Now anywhere where a number is next to a different number the old number is changed to the new one. Here's an example in a number of steps:
#123#
#4###
#5#6#
###7#
#113#
#4###
#4#7#
###7#
#111#
#4###
#4#7#
###7#
#444#
#4###
#4#7#
###7#
Now we chose any two different numbers and connect them with some kind of hall, anything will work as long as those two spots are guaranteed to be connected.
#444#
#4#.#
#4#4#
###4#
And viola! All parts of the map are connected :)