Node Placement in Graphs

Our initial Graph plugin node placement algorithm shows that for small graphs placement can usefully reflect order in markup.

for name, children of graph if not node = placed[name] placed[name] = node = [x, y] x += 100 for child in children if not more = placed[child] placed[child] = more = [x-50, node[1]+75]

# Redesign

Here we consider a redesigned algorithm. We started coding with this approach and found it to be flawed in many ways. Bummer.

Fill the first rank with nodes unreferenced by any other node. These tend to be the first encounter as above.

Oops. All nodes may be child of another.

Advance breadth first through children of one rank filling the next lower rank.

Register rank height and maximum file width. Distribute each rank's nodes evenly to file width.

Stager nodes of each rank vertically so as to minimize overlap of overflowing labels.

Stager back referencing nodes of each rank horizontally to minimize overlap of arcs.