How to add an additional edge between nodes that already have edges?

Viewed 57

I have a Graph object and between each pair of nodes that already has an edge, I would like to add an additional edge? Is there a way to do this without brute force looping through all the edges?

1 Answers

A simple way to do this is:

temp = nx.Graph(our_graph)
new_graph = nx.MultiGraph(temp)
new_graph.add_edges_from(temp.edges)
Related