dag_longest_path

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

Returns the longest path in a DAG If G has edges with ‘weight’ attribute the edge data are used as weight values.

Parameters:
  • G (NetworkX DiGraph) – Graph
  • weight (string (default ‘weight’)) – Edge data key to use for weight
  • default_weight (integer (default 1)) – The weight of edges that do not have a weight attribute
Returns:

path – Longest path

Return type:

list

Raises:

NetworkXNotImplemented – If G is not directed