Can I have some edges curved and other straight in Python igraph?

Viewed 35

I am trying to create the graph as shown in Python igraph and I am having trouble displaying some edge straight and others curved. Is this possible, the edge_curved function appears to only take one argument.

enter image description here

enter image description here

# Construct the graph
g = ig.Graph(n=9,
    edges = [(6,7),(6,8),(6,3),(6,0),
             (7,8),(7,4),(7,3),
             (8,2),(8,5), 
             (3,4),(3,0),(4,1),(4,5), (5,2), (5,1),
             (0,1),(0,2), (1,2)])

#g.es["weight"] = [2, 1, 5, 4, 7, 3, 2]
g.es["label"]= ["a","b","c","d", "e", "g", "f", "e", "h", "j","k","m", "l", "o", "n", "p", "q", "r" ]
g.vs["name"] = ["G","H","X","D","E","F","A","B","C"]

print("Is simple ", g.is_simple())
print("Degree ", g.vs.degree())
print(g)

# Plot graph
g.es['width'] = 0.5

fig, ax = plt.subplots()
ig.plot(
    g,
    target=ax,
    layout='grid',
    vertex_color='steelblue',
    vertex_label=g.vs["name"], 
    autocurve=True,
    #vertex_label=range(g.vcount()),
    edge_label=g.es['label'],
    edge_width=g.es['width'],
    edge_curved="0.2",
    #edge_label=g.es["weight"],
    edge_color='#666',
    edge_align_label=False,
    edge_background='white'
)
1 Answers

python-igraph dev here.

autocurve is designed as a global option at present. Per-edge setting would be a little difficult to handle if there are several parallel edges between the same two nodes.

Of course, you could split the graph into two, one with the curved and one with the straight edges, and plot twice.

Related