Skip to content
Advertisement

How to connect two nodes if they are disconnected

I use a python NetworkX graph. How to check if 2 nodes are disconnected and then get a new version of the graph where these 2 nodes are connected.

The difference between 2 graphs should have min edit distance (Levenshtein distance)

Before and after for nodes=[1,2]:

enter image description here | enter image description here

Advertisement

Answer

JavaScript

you can also have a condition to check for an edge of either direction with:

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