Ask Your Question

Revision history [back]

click to hide/show revision 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)

The required graph (approximately...)

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)

The required graph (approximately...)

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)})

A better approximation