Skip to content
Advertisement

How can I connect two portion of my graph? in python

Hi all I have a graph which is split in two portion, like I am showing in the photo, I would like to connect the two portion by adding a red edges like I am showing in the photo. Someone know a networkx function to do that? enter image description here

Advertisement

Answer

If you do not have to calculate anything else (meaning the nodes to be connected are fixed – in the example 4 an 6) a simple

G.add_edge(4, 6)

will do. (documentation)

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement