Algorithm for edge connectivity of a digraph?
19 visualizaciones (últimos 30 días)
Arif Billah el 27 de Jul. de 2023
What is the best way to compute edge connectivity of a digraph? Is there an algorithm or built-in matlab function I can use?
I don't have much experience with graph theory, and am trying to calculate the edge connectivity of a few digraphs with 50 nodes. Thanks!
Christine Tobler el 27 de Jul. de 2023
Editada: Christine Tobler el 27 de Jul. de 2023
There is no direct method in MATLAB for computing the edge connectivity. Based on the Wikipedia page, you should be able to compute it quite efficiently for small graphs by calling maxflow in a loop:
% Completely connected graph:
g = graph(ones(4));
% Line graph:
g = graph(1:4, 2:5);
% Circle graph:
g = graph(1:4, [2:4 1]);
% Completely connected graph with 50 nodes:
g = graph(ones(50));
function k = edgeConnectivity(g)
% Make sure the graph is unweighted:
if contains("Weight", g.Edges.Properties.VariableNames)
g.Edges.Weight = ;
% Compute the maximum flow from node 1 to every other node
mf = zeros(1, numnodes(g)-1);
mf(ii-1) = maxflow(g, 1, ii);
% The edge connectivity is the minimum of these maximum flows
k = min(mf);
For context, here are the relevant parts of the Wikipedia page:
"A simple algorithm would, for every pair (u,v), determine the maximum flow from u to v with the capacity of all edges in G set to 1 for both directions. A graph is k-edge-connected if and only if the maximum flow from u to v is at least k for any pair (u,v), so k is the least u-v-flow among all (u,v).
An improved algorithm will solve the maximum flow problem for every pair (u,v) where u is arbitrarily fixed while v varies over all vertices. This [...] is sound since, if a cut of capacity less than k exists, it is bound to separate u from some other vertex.
Note this isn't the most efficient implementation in terms of code complexity, but the timing looks quite good for a graph with 50 nodes.
Más respuestas (1)
Mrutyunjaya Hiremath el 27 de Jul. de 2023
- To compute the edge connectivity of a directed graph (digraph) in MATLAB, you can use the built-in function "edgeconncomp". This function calculates the edge connectivity of a graph by finding the minimum number of edges that need to be removed to disconnect the graph.
% Create your directed graph (digraph) using the 'digraph' function or other methods.
% For example:
% G = digraph(edges, nodes); % Replace 'edges' and 'nodes' with your actual graph data.
% Compute the edge connectivity using the 'edgeconncomp' function.
connectivity = edgeconncomp(G);
% 'connectivity' will contain the minimum number of edges that need to be removed to disconnect the graph.
disp(['Edge Connectivity: ', num2str(connectivity)]);