Topological sort using d3.js.