Skip to content
DeepForgeby svx
All problems
MediumGraph Algorithmsgraph-076

Edge Connectivity Min Cut Lite

Problem

Compute the edge connectivity of a small undirected graph: the minimum number of edges whose removal disconnects it.

Try every non-trivial vertex subset and count the edges crossing the cut, or return 0 when the graph or a single node case applies. edges is a list of [u, v] pairs and n is at most about 12.

Hint

Every cut is defined by a vertex subset, so brute force over all subsets for small n.

Test cases

case 1
in: [3,[[0,1],[1,2]]]
expected: 1
case 2
in: [3,[[0,1],[1,2],[2,0]]]
expected: 2
case 3
in: [4,[[0,1],[0,2],[0,3],[1,2],[1,3],[2,3]]]
expected: 3
case 4
in: [4,[[0,1],[2,3]]]
expected: 0
case 5
in: [4,[[0,1],[0,2],[0,3]]]
expected: 1
Starter codePython
def edge_connectivity(n, edges):
    # Your code here
    pass

5 test cases · run your code against them in the editor