When I did something like this five years ago, I used Graph and the shortest path algorithms it provides. You can have the vertices be your tables and the edges describe the joins. That will preserve all the information you need.
My criteria for good software:
Does it work?
Can someone else come in, make a change, and be reasonably certain no bugs were introduced?