taken from https://github.com/bobbydavid/dag-visualization at 6/22/13.
The algorithm is:
Create a random DAG (topographically sorted).
Determine X-positions. For each node, find it's minimum X-position. Then, in reverse order, find the maximum X-position of nodes that can be moved forward.
Determine Y-positions. For each node, place it as near as possible to the mean Y-position of its parents. Give preference to placing nodes that have a single parent with a single child (a 1-1 relationship), so that these will always be shown in a straight line.
Modified http://d3js.org/d3.v3.js to a secure url
https://d3js.org/d3.v3.js