1 | initial version |
Alternate solution:
sage: G=Graph([[0,u] for u in (1..7)])
sage: G.add_edges([[u,4] for u in (1..3)])
sage: G.add_edges([[u,4] for u in (5..7)])
sage: D={0:[4,2]}
sage: D.update({4:[4,0]})
sage: for u in (1..3): D.update({u:[u,1]})
sage: for u in (5..7): D.update({u:[u,1]})
sage: G.plot(pos=D)
2 | No.2 Revision |
Alternate solution:
sage: G=Graph([[0,u] for u in (1..7)])
sage: G.add_edges([[u,4] for u in (1..3)])
sage: G.add_edges([[u,4] for u in (5..7)])
sage: D={0:[4,2]}
sage: D.update({4:[4,0]})
sage: for u in (1..3): D.update({u:[u,1]})
sage: for u in (5..7): D.update({u:[u,1]})
sage: G.plot(pos=D)
EDIT : If you insist on the order of the nodes:
sage: Dpos=[4, 3, 5, 2, 4, 6, 1, 7]
sage: G.plot(pos={u:[Dpos[u], 1+(u==0)-(u==4)] for u in (0..7)})