There are many ways to acomplish what you need, here is some technical stuff you can read: document
And you can also find some implementations in rougue basin.
The most easy algorithm is BINARY SPACE PARTITIONING, of course the dungeon area is simple and not "organic".