Is there anything within NetworkX that will combine the functionality of ancestors and provide the depth of each object?
I want to get a dictionary of all ancestors in NetworkX, and get the depth from the source for each of those. Right now the function returns a set, but I'd like to know how deep each item is in the dependencies of an object.
My source is a sql table that has the input and output of a pipeline, which I then turn into a directed graph. Example:
input output
b a
c a
x b
y b
z b
w b
l c
m c
and after running ancestors I have the set of everything that is in the chain, but I need a way to also be able to say that x is a level 3 or depth 3 object.
I've been looking through the various functions like traversal, but nothing jumps out at me as providing this functionality. Do I need to create my own loop to recreate ancestors with depth at this point?
question from:
https://stackoverflow.com/questions/65910085/networkx-get-ancestors-with-depth 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…