dag_longest_path_length(G, weight='weight', default_weight=1)
A directed acyclic graph (DAG)
Edge data key to use for weight
The weight of edges that do not have a weight attribute
If G
is not directed
Longest path length
Returns the longest path length in a DAG
>>> DG = nx.DiGraph([(0, 1, {'cost':1}), (1, 2, {'cost':1}), (0, 2, {'cost':42})])
... list(nx.all_simple_paths(DG, 0, 2)) [[0, 1, 2], [0, 2]]
>>> nx.dag_longest_path_length(DG) 2
>>> nx.dag_longest_path_length(DG, weight="cost") 42See :
The following pages refer to to this document either explicitly or contain code examples using this.
networkx.algorithms.dag.dag_longest_path_length
networkx.algorithms.dag.dag_longest_path
Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.
Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)
SVG is more flexible but power hungry; and does not scale well to 50 + nodes.
All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them