networkx 2.8.2 Pypi GitHub Homepage
Other Docs
NotesParametersRaisesReturnsBackRef
transitive_closure_dag(G, topo_order=None)

This function is faster than the function transitive_closure , but fails if the graph has a cycle.

The transitive closure of G = (V,E) is a graph G+ = (V,E+) such that for all v, w in V there is an edge (v, w) in E+ if and only if there is a non-null path from v to w in G.

Notes

This algorithm is probably simple enough to be well-known but I didn't find a mention in the literature.

Parameters

G : NetworkX DiGraph

A directed acyclic graph (DAG)

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

NetworkXUnfeasible

If G has a cycle

Returns

NetworkX DiGraph

The transitive closure of G

Returns the transitive closure of a directed acyclic graph.

Examples

>>> DG = nx.DiGraph([(1, 2), (2, 3)])
... TC = nx.transitive_closure_dag(DG)
... TC.edges() OutEdgeView([(1, 2), (1, 3), (2, 3)])
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

networkx.algorithms.dag.transitive_closure_dag

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#695
type: <class 'function'>
Commit: