Reputation: 5345
I can't believe I'm having a hard time with this, but here we are... This should be straight forward, here's my code:
i = random.choice(ER.vs)
j = random.choice(ER.vs)
if t < 1:
ER.add_edge(i,j)
else:
ER.delete_edges(ER.get_eid(i.index,j.index))
The last line doesn't work. I've tried different ways to delete the edge between i and j, but I can't seem to figure out the function. Could anyone help?
Cheers!
Upvotes: 2
Views: 3703
Reputation: 1882
For me it works with igraph0.6:
import random
import igraph
N = 10
g = igraph.Graph.Full(N)
i, j = random.sample(range(g.vcount()), 2)
g.delete_edges([(i,j)])
print(g.ecount(), N*(N-1)/2)
From the output can be concluded, it has deleted one edge:
44 45.0
Upvotes: 6