Suppose I have a directed graph G in Network X such that:
- G has multiple trees in it
- Every node N in G has exactly 1 or 0 parent's.
For a particular node N1, I want to find the root node of the tree it resides in (its ancestor that has a degree of 0). Is there an easy way to do this in network x?
I looked at: Getting the root (head) of a DiGraph in networkx (Python) But there are multiple root nodes in my graph. Just only one root node that happens to be in the same tree as N1.