The positions of the nodes are defined in a dictionary, with key the name of the node and value a tuple with the x and y coords.
You can see this by printing the pos
variable once created:
pos=nt.graphviz_layout(graph,prog='dot')
print pos
# EXAMPLE RESULT
{'A': (51.5, 15.3), 'B': (20.0, 60.4)}
A higher value in the y coordinate will place the node higher in the graph. So if you want the root nodes to be at the top (lower time stamp value), just use the negative of the time stamps as -1 will be higher than -2.
To automate the process of placing the nodes, you need some equation based on time.
pos = {}
for key, value in graph.node.items():
height = value['time'] # Time value as defined when adding the node `key`
pos[key] = (50, -height)
This will place the nodes vertically, based on their time stamps. So the distance between two nodes created at times 1 and 4 and will be twice as large than two nodes created at times 1 and 2. In this example I kept the horizontal component static (50) and all nodes will end up in a vertical line. You should be able to vary that according to your needs.