#

Note

This documents the development version of NetworkX. Documentation for the current release can be found here.

#

networkx.algorithms.connectivity.edge_kcomponents.k_edge_components

k_edge_components(G, k)[source]

Generates nodes in each maximal k-edge-connected component in G.

Parameters
  • G (NetworkX graph)

  • k (Integer) – Desired edge connectivity

Returns

k_edge_components – will have k-edge-connectivity in the graph G.

Return type

a generator of k-edge-ccs. Each set of returned nodes

See also

local_edge_connectivity()

k_edge_subgraphs()

similar to this function, but the subgraph defined by the nodes must also have k-edge-connectivity.

k_components()

similar to this function, but uses node-connectivity instead of edge-connectivity

Raises

Notes

Attempts to use the most efficient implementation available based on k. If k=1, this is simply simply connected components for directed graphs and connected components for undirected graphs. If k=2 on an efficient bridge connected component algorithm from _[1] is run based on the chain decomposition. Otherwise, the algorithm from _[2] is used.

Example

>>> import itertools as it
>>> from networkx.utils import pairwise
>>> paths = [
...     (1, 2, 4, 3, 1, 4),
...     (5, 6, 7, 8, 5, 7, 8, 6),
... ]
>>> G = nx.Graph()
>>> G.add_nodes_from(it.chain(*paths))
>>> G.add_edges_from(it.chain(*[pairwise(path) for path in paths]))
>>> # note this returns {1, 4} unlike k_edge_subgraphs
>>> sorted(map(sorted, nx.k_edge_components(G, k=3)))
[[1, 4], [2], [3], [5, 6, 7, 8]]

References

1

https://en.wikipedia.org/wiki/Bridge_%28graph_theory%29

2

Wang, Tianhao, et al. (2015) A simple algorithm for finding all k-edge-connected components. http://journals.plos.org/plosone/article?id=10.1371/journal.pone.0136264