Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

So I wrote a few lines that do what I wanted:

def angle(x):
    return sign(x[1])*(x[0])/(x.norm())
def get_rotation_system(H):
    if not(H.get_pos()):
        return 'no positions known'
    rotation_system=dict()
    for v in H.vertex_iterator():
        anglelist=[[angle(vector(H.get_pos()[w])-(vector(H.get_pos()[v]))),w] for w in H[v]]
        anglelist.sort()
        rotation_system[v]=[w for a,w in anglelist]
    H.set_embedding(rotation_system)

This can be used as follows:

G = Graph({0:[1,5,3,4],1:[2,0,3],2:[1,4,5],3:[0,1],4:[0,2,5],5:[0,2,4]})
G.set_pos({0:[213,281],1:[93,171],2:[189,35],3:[35,315],4:[315,146],5:[197,158]})
get_rotation_system(G)
G.show(layout='planar')

Anyhow I think this would be a handy function to have, especially in combination with the graph editor. I will open a trac ticket soon.

So I wrote a few lines that do what I wanted:

def angle(x):
    return sign(x[1])*(x[0])/(x.norm())
arccos(sign(x[1])*(x[0])/(x.norm()))
def get_rotation_system(H):
    if not(H.get_pos()):
        return 'no positions known'
    rotation_system=dict()
    for v in H.vertex_iterator():
        anglelist=[[angle(vector(H.get_pos()[w])-(vector(H.get_pos()[v]))),w] for w in H[v]]
        anglelist.sort()
        rotation_system[v]=[w for a,w in anglelist]
    H.set_embedding(rotation_system)

This can be used as follows:

G = Graph({0:[1,5,3,4],1:[2,0,3],2:[1,4,5],3:[0,1],4:[0,2,5],5:[0,2,4]})
G.set_pos({0:[213,281],1:[93,171],2:[189,35],3:[35,315],4:[315,146],5:[197,158]})
get_rotation_system(G)
G.show(layout='planar')

Anyhow I think this would be a handy function to have, especially in combination with the graph editor. I will open a trac ticket soon.