networkx.algorithms.connectivity.edge_kcomponents.k_edge_components¶

k_edge_components
(G, k)[source]¶ Generates nodes in each maximal kedgeconnected component in G.
 Parameters
G (NetworkX graph)
k (Integer) – Desired edge connectivity
 Returns
k_edge_components – will have kedgeconnectivity in the graph G.
 Return type
a generator of kedgeccs. 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 kedgeconnectivity.
k_components()
similar to this function, but uses nodeconnectivity instead of edgeconnectivity
 Raises
NetworkXNotImplemented – If the input graph is a multigraph.
ValueError: – If k is less than 1
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
 2
Wang, Tianhao, et al. (2015) A simple algorithm for finding all kedgeconnected components. http://journals.plos.org/plosone/article?id=10.1371/journal.pone.0136264