See https://networkx.org/documentation/stable/reference/algorithms/generated/networkx.algorithms.dag.transitive_closure.html though it's kind of vague.
At runtime:
from __future__ import annotations import networkx as nx G: nx.DiGraph[int] = nx.DiGraph([(1, 2), (2, 3)]) G_plus = nx.transitive_closure(G) print(G_plus)
prints this:
DiGraph with 3 nodes and 3 edges
Activity