networkx 2.8.2 Pypi GitHub Homepage
Other Docs
NotesParametersReturnsBackRef
lowest_common_ancestor(G, node1, node2, default=None)

Notes

Only defined on non-null directed acyclic graphs. Takes n log(n) time in the size of the graph. See all_pairs_lowest_common_ancestor when you have more than one pair of nodes of interest.

Parameters

G : NetworkX directed graph
node1, node2 : nodes in the graph.
default : object

Returned if no common ancestor between :None:None:`node1` and :None:None:`node2`

Returns

The lowest common ancestor of node1 and node2,
or default if they have no common ancestors.

Compute the lowest common ancestor of the given pair of nodes.

See Also

all_pairs_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.all_pairs_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#114
type: <class 'function'>
Commit: