Warning

This documents an unmaintained version of NetworkX. Please upgrade to a maintained version and see the current NetworkX documentation.

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:
  • G (NetworkX DiGraph) – A directed acyclic graph (DAG)
  • weight (string, optional) – Edge data key to use for weight
  • default_weight (int, optional) – The weight of edges that do not have a weight attribute
Returns:

Longest path length

Return type:

int

Raises:

NetworkXNotImplemented – If G is not directed