How to calculate indirect ties in networkx? Indirect ties are defined as a relationship between two individuals who have no direct relation but are connected through a third person in their social network.
Tried checking some of the existing libraries in Networkx like common neighbors etc. but did not match the definition of indirect ties.
I am putting this edit up top (thanks Mad Physicist for pointing this out).
Here is one possible way using an adjacency matrix method (explanations in comments):
Edit: If you want to get the node names instead of the indices in the output, it's not that different:
While there isn't a specific NetworkX function for it, you can still create your own using NetworkX (I'll explain in the comments– sorry if verbose):
Obviously, you can change this up a bit. I did the dictionary approach to show how you can also store the common neighbors that are responsible for making the nodes indirect. However, you can just as easily modify the code and store only the indirect nodes.