k_edge_augmentation#
- graph_tool.flow.k_edge_augmentation(g, k, avail=None, weight=None, partial=False)[git][source]#
Find a set of edges whose addition makes the graph \(k\)-edge-connected.
- Parameters:
- g
Graph Undirected graph to be used.
- k
int Required edge connectivity.
- availiterable of pairs or triples (optional, default:
None) Edges that may be added, given as pairs of vertices, or as triples with their weights. If not supplied, every edge that is not yet in the graph may be added, with unit weight.
- weightiterable of
float(optional, default:None) Weights of the edges in
avail, if they are given as pairs. If not supplied, every available edge has unit weight.- partial
bool(optional, default:False) If
Trueand no augmentation exists, a partial augmentation is returned (see below) instead of raising aValueError.
- g
- Returns:
- edges
numpy.ndarray Array of shape
(M, 2)with the edges to be added.
- edges
See also
is_k_edge_connectedTest for k-edge-connectivity
edge_connectivityEdge connectivity
graph_tool.structure.make_connectedEdges that make the graph connected
Notes
A \(k\)-edge augmentation is a set of edges that, once added to the graph, gives it edge connectivity at least \(k\) (see
edge_connectivity()andis_k_edge_connected()). The aim is an augmentation of minimum total weight. Available edges that are already in the graph or are self-loops are ignored, and of those that are repeated only the lightest is considered. The parallel edges of the graph count with their multiplicities. Different methods are used:For \(k=1\), the components are joined in a chain, if all edges are available, or by a minimum spanning tree of the graph of the components (see
minimum_spanning_tree()), with the lightest available edge between each pair. Both are optimal.For \(k=2\), if all edges are available, the algorithm of Eswaran and Tarjan [eswaran-augmentation-1976] is used, which contracts the bridge components (see
label_bridge_components()) into a forest with \(p\) leaves and \(q\) isolated nodes, and adds the optimal number \(\lceil p/2\rceil + q\) of edges (unless the graph is already 2-edge-connected), in time \(O(V + E)\). With a set of available edges, the graph is first connected as for \(k=1\), and then the problem is reduced to a minimum spanning arborescence (seeminimum_spanning_arborescence()) of a directed graph on the tree of bridge components, following Khuller and Thurimella [khuller-approximation-1993], which gives at most twice the optimal weight.For \(k \ge 3\), where the problem is NP-hard, a greedy method is used: the available edges are added in increasing order of weight (and of the degree sum of their endpoints), skipping those whose endpoints are already \(k\)-edge-connected, until the graph is \(k\)-edge-connected; the added edges are then visited in random order, and each is removed if the graph remains \(k\)-edge-connected without it. The result is minimal, i.e. no edge can be removed from it, but there is no guarantee on its weight. Each step involves a test of
is_k_edge_connected(), so that this is practical only for small graphs; if all edges are available, the \(O(V^2)\) missing edges are the candidates.
No augmentation exists if the graph has fewer than \(k+1\) vertices and is not \(k\)-edge-connected, or if the available edges do not suffice. In this case, if
partial == True, all missing edges are returned ifavailis not given; otherwise, the graph with all available edges added is split into its maximal \(k\)-edge-connected subgraphs (seelabel_k_edge_subgraphs()), each of them is augmented with the available edges inside it, and all available edges between different subgraphs are added.References
[eswaran-augmentation-1976]Kapali P. Eswaran and R. Endre Tarjan, “Augmentation problems”, SIAM Journal on Computing 5, 653-665 (1976), DOI: 10.1137/0205044 [sci-hub, @tor]
[khuller-approximation-1993]Samir Khuller and Ramakrishna Thurimella, “Approximation algorithms for graph augmentation”, Journal of Algorithms 14, 214-225 (1993), DOI: 10.1006/jagm.1993.1010 [sci-hub, @tor]
Examples
>>> g = gt.collection.data["karate"] >>> print(gt.k_edge_augmentation(g, 2)) [[11 9]] >>> print(len(gt.k_edge_augmentation(g, 3))) 11
The edges of an augmentation can be highlighted in a drawing of the network to which they are added:
>>> es = gt.k_edge_augmentation(g, 3) >>> u = g.copy() >>> new = u.new_ep("bool", val=False) >>> u.add_edge_list(np.column_stack((es, np.ones(len(es)))), eprops=[new]) >>> ecolor = u.new_ep("string", vals=np.where(new.a, "#e41a1c", "#999999")) >>> ewidth = u.new_ep("double", vals=np.where(new.a, 2.5, 1)) >>> gt.graph_draw(u, u.vp.pos, vertex_fill_color="#cccccc", ... edge_color=ecolor, edge_pen_width=ewidth, ... output="k_edge_augmentation-karate.pdf") <...>
Zachary’s karate club network with the edges of a 3-edge augmentation added, in red.#