dag2dot: Add better transitive reduction algorithm

This version reduces the memory usage a lot on large workflows.