networkx.algorithms.dag.dag_longest_path¶
-
dag_longest_path(G, weight='weight', default_weight=1, topo_order=None)[source]¶ Returns the longest path in a directed acyclic graph (DAG).
If
Ghas edges withweightattribute the edge data are used as weight values.- Parameters
G (
NetworkX DiGraph) – A directed acyclic graph (DAG)weight (
str, optional) – Edge data key to use for weightdefault_weight (
int, optional) – The weight of edges that do not have a weight attributetopo_order (
listortuple, optional) – A topological order for G (if None, the function will compute one)
- Returns
Longest path
- Return type
- Raises
NetworkXNotImplemented – If
Gis not directed
See also