networkx 2.8.2 Pypi GitHub Homepage
Other Docs
ParametersRaisesReturnsBackRef
dag_longest_path(G, weight='weight', default_weight=1, topo_order=None)

If G has edges with :None:None:`weight` attribute 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 weight

default_weight : int, optional

The weight of edges that do not have a weight attribute

topo_order: list or tuple, optional :

A topological order for G (if None, the function will compute one)

Raises

NetworkXNotImplemented

If G is not directed

Returns

list

Longest path

Returns the longest path in a directed acyclic graph (DAG).

See Also

dag_longest_path_length

Examples

>>> 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(DG)
[0, 1, 2]
>>> nx.dag_longest_path(DG, weight="cost")
[0, 2]
See :

Back References

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

Local connectivity graph

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


GitHub : /networkx/algorithms/dag.py#889
type: <class 'function'>
Commit: