Improve dependency graph generator

Copies additional fixes from the StackOverflow discussion.
Adds ability to restrict root nodes of graph, to reduce clutter.
Fixes some Javadoc warnings.
(Sorry about the whitespace changes; my editor is configured to automatically drop trailing whitespace...)