Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

This "works", for some value of "works".

G = my_cool_graph
u = my_special_vertex
HL = []  # height list
for h in range(G.diameter()+1): # for height in the range
    HL.append([(v,h) for v in G if G.distance(u,v)==h])
# enumerate makes this work, but don't flatten the whole thing
HL = flatten([list(enumerate(hl)) for hl in HL],max_level=1)  
HL = [(v[0], (i,3*v[1])) for i, v in HL] # rearrange in an ugly way and make the heights visible
HD = dict(HL) # need a dict to make a position dict
G.set_pos(HD) # here we go
G.show(figsize=15)  # acceptable but needs centering of each row to be really nice

Do you think this would be worth adding as an option for positioning or something? It seems so ugly to me.