Skip to content

Commit

Permalink
Update general_k_edge_subgraphs docstring. (networkx#7254)
Browse files Browse the repository at this point in the history
  • Loading branch information
rossbar authored and cvanelteren committed Apr 22, 2024
1 parent 8471e2f commit ba4e559
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions networkx/algorithms/connectivity/edge_kcomponents.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,17 +505,24 @@ def _high_degree_components(G, k):

@nx._dispatchable
def general_k_edge_subgraphs(G, k):
"""General algorithm to find all maximal k-edge-connected subgraphs in G.
"""General algorithm to find all maximal k-edge-connected subgraphs in `G`.
Returns
-------
k_edge_subgraphs : a generator of nx.Graphs that are k-edge-subgraphs
Each k-edge-subgraph is a maximal set of nodes that defines a subgraph
of G that is k-edge-connected.
Parameters
----------
G : nx.Graph
Graph in which all maximal k-edge-connected subgraphs will be found.
k : int
Yields
------
k_edge_subgraphs : Graph instances that are k-edge-subgraphs
Each k-edge-subgraph contains a maximal set of nodes that defines a
subgraph of `G` that is k-edge-connected.
Notes
-----
Implementation of the basic algorithm from _[1]. The basic idea is to find
Implementation of the basic algorithm from [1]_. The basic idea is to find
a global minimum cut of the graph. If the cut value is at least k, then the
graph is a k-edge-connected subgraph and can be added to the results.
Otherwise, the cut is used to split the graph in two and the procedure is
Expand All @@ -524,7 +531,7 @@ def general_k_edge_subgraphs(G, k):
a single node or a subgraph of G that is k-edge-connected.
This implementation contains optimizations for reducing the number of calls
to max-flow, but there are other optimizations in _[1] that could be
to max-flow, but there are other optimizations in [1]_ that could be
implemented.
References
Expand All @@ -547,7 +554,7 @@ def general_k_edge_subgraphs(G, k):
... (14, 101, 24),
... ]
>>> G = nx.Graph(it.chain(*[pairwise(path) for path in paths]))
>>> sorted(map(len, k_edge_subgraphs(G, k=3)))
>>> sorted(len(k_sg) for k_sg in k_edge_subgraphs(G, k=3))
[1, 1, 1, 4, 4]
"""
if k < 1:
Expand Down

0 comments on commit ba4e559

Please sign in to comment.