networkx 2.8.2 Pypi GitHub Homepage
Other Docs
NotesParametersReturnsBackRef
node_connectivity(G, s=None, t=None)

Node connectivity is equal to the minimum number of nodes that must be removed to disconnect G or render it trivial. By Menger's theorem, this is equal to the number of node independent paths (paths that share no nodes other than source and target).

If source and target nodes are provided, this function returns the local node connectivity: the minimum number of nodes that must be removed to break all paths from source to target in G.

This algorithm is based on a fast approximation that gives an strict lower bound on the actual number of node independent paths between two nodes . It works for both directed and undirected graphs.

Notes

This algorithm finds node independents paths between two nodes by computing their shortest path using BFS, marking the nodes of the path found as 'used' and then searching other shortest paths excluding the nodes marked as used until no more paths exist. It is not exact because a shortest path could use nodes that, if the path were longer, may belong to two different node independent paths. Thus it only guarantees an strict lower bound on node connectivity.

Parameters

G : NetworkX graph

Undirected graph

s : node

Source node. Optional. Default value: None.

t : node

Target node. Optional. Default value: None.

Returns

K : integer

Node connectivity of G, or local node connectivity if source and target are provided.

Returns an approximation for node connectivity for a graph or digraph G.

See Also

all_pairs_node_connectivity
local_node_connectivity

Examples

>>> # Platonic octahedral graph is 4-node-connected
... from networkx.algorithms import approximation as approx
... G = nx.octahedral_graph()
... approx.node_connectivity(G) 4
See :

Back References

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

networkx.algorithms.approximation.connectivity.node_connectivity networkx.algorithms.approximation.connectivity.local_node_connectivity networkx.algorithms.approximation.connectivity.all_pairs_node_connectivity

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/approximation/connectivity.py#110
type: <class 'function'>
Commit: