networkx.algorithms.dag.dag_longest_path_length

dag_longest_path_length(G, weight='weight', default_weight=1)[source]

Returns the longest path length in a DAG

Parameters
GNetworkX DiGraph

A directed acyclic graph (DAG)

weightstring, optional

Edge data key to use for weight

default_weightint, optional

The weight of edges that do not have a weight attribute

Returns
int

Longest path length

Raises
NetworkXNotImplemented

If G is not directed

See also

dag_longest_path