networkx 2.8.2 Pypi GitHub Homepage
Other Docs
NotesParametersReturnsBackRef
all_pairs_lowest_common_ancestor(G, pairs=None)

Notes

Only defined on non-null directed acyclic graphs.

Uses the $O(n^3)$ ancestor-list algorithm from: M. A. Bender, M. Farach-Colton, G. Pemmasani, S. Skiena, P. Sumazin. "Lowest common ancestors in trees and directed acyclic graphs." Journal of Algorithms, 57(2): 75-94, 2005.

Parameters

G : NetworkX directed graph
pairs : iterable of pairs of nodes, optional (default: all pairs)

The pairs of nodes of interest. If None, will find the LCA of all pairs of nodes.

Returns

An iterator over ((node1, node2), lca) where (node1, node2) are
the pairs specified and lca is a lowest common ancestor of the pair.
Note that for the default of all pairs in G, we consider
unordered pairs, e.g. you will not get both (b, a) and (a, b).

Compute the lowest common ancestor for pairs of nodes.

See Also

lowest_common_ancestor
tree_all_pairs_lowest_common_ancestor

Examples

See :

Back References

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

networkx.algorithms.lowest_common_ancestors.tree_all_pairs_lowest_common_ancestor networkx.algorithms.lowest_common_ancestors.lowest_common_ancestor

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/lowest_common_ancestors.py#153
type: <class 'function'>
Commit: