A k-connected graph is a type of graph where removing k-1 vertices (and edges) from the graph does not disconnect it.
- In other words, there are at least k distinct paths between any two vertices in the graph, and the graph remains connected even if k-1 vertices or edges are removed.
- The parameter k is known as the connectivity of the graph. The higher the connectivity of a graph, the more robust it is against failures or attacks.

Properties of k-connected Graph:
- Robustness: A k-connected graph is more robust against vertex or edge failures than a graph with lower connectivity. Removing k-1 vertices or edges from a k-connected graph does not disconnect it.
- Minimum degree: In a k-connected graph, every vertex has a degree of at least k. This means that the graph is densely connected and has many paths between its vertices.
- Separability: A graph is k-connected if and only if it is not separable into two disconnected subgraphs by removing k-1 vertices.
- Augmentation: Every k-connected graph can be augmented to a (k+1)-connected graph by adding edges between any two sets of k vertices that are not already connected.
- Planarity: In a planar k-connected graph, the number of vertices is at least 2k, and the number of edges is at least 3k - 6.
How to identify a k-connected Graph?
- Brute force approach: One way to identify if a graph is k-connected is to remove all possible subsets of k-1 vertices (or edges) and check if the graph remains connected after each removal. This approach is not efficient for large graphs, but it can be used for small graphs.
- Max-flow min-cut theorem: According to the Max-flow min-cut theorem, the maximum flow in a graph is equal to the minimum cut in the graph. Therefore, we can use a max-flow algorithm to find the minimum cut of a graph, and if the minimum cut is greater than or equal to k, then the graph is k-connected.
- Connectivity algorithm: We can use a connectivity algorithm such as Tarjan's algorithm or Hopcroft–Karp algorithm to find all the cut-vertices and cut-edges in a graph. If there are no cut-vertices and cut-edges of size less than k-1, then the graph is k-connected.
- DFS Algorithm: To check whether a graph is K-connected using DFS, first ensure that K is less than the total number of vertices n, since a graph cannot be K-connected if K≥n. Then, consider all possible ways of removing K−1 vertices from the graph. For each such removal, perform a DFS traversal on the remaining graph while ignoring the removed vertices. After the traversal, verify whether all the remaining vertices are still reachable, i.e., the graph remains connected. If the graph becomes disconnected for any removal, it is not K-connected. If it remains connected for all possible removals, then the graph is K-connected.
#include <iostream>
using namespace std;
vector<vector<int>> adj;
vector<bool> removed, visited;
void DFS(int u) {
visited[u] = true;
for (int v : adj[u]) {
if (!visited[v] && !removed[v]) {
DFS(v);
}
}
}
// check if graph is connected ignoring removed nodes
bool isConnected(int n) {
visited.assign(n, false);
int start = -1;
// find a non-removed node to start DFS
for (int i = 0; i < n; i++) {
if (!removed[i]) {
start = i;
break;
}
}
if (start == -1) return true;
DFS(start);
// check all non-removed nodes are visited
for (int i = 0; i < n; i++) {
if (!removed[i] && !visited[i]) {
return false;
}
}
return true;
}
// generate all combinations of (k-1) vertices to remove
bool solve(int idx, int taken, int k, int n) {
if (taken == k - 1) {
return isConnected(n);
}
if (idx == n) return true;
// choose this node
removed[idx] = true;
if (!solve(idx + 1, taken + 1, k, n)) return false;
// don't choose this node
removed[idx] = false;
if (!solve(idx + 1, taken, k, n)) return false;
return true;
}
bool isKConnected(int n, int k) {
if (k >= n) return false;
removed.assign(n, false);
return solve(0, 0, k, n);
}
int main() {
int n = 5, k = 2;
adj.resize(n);
// undirected graph
adj[0] = {1, 2};
adj[1] = {0, 2, 3};
adj[2] = {0, 1, 3, 4};
adj[3] = {1, 2, 4};
adj[4] = {2, 3};
if (isKConnected(n, k)) {
cout << "Graph is K-connected\n";
} else {
cout << "Graph is not K-connected\n";
}
return 0;
}
import java.util.*;
public class GfG {
static List<List<Integer>> adj;
static boolean[] removed, visited;
static void DFS(int u) {
visited[u] = true;
for (int v : adj.get(u)) {
if (!visited[v] && !removed[v]) {
DFS(v);
}
}
}
static boolean isConnected(int n) {
Arrays.fill(visited, false);
int start = -1;
for (int i = 0; i < n; i++) {
if (!removed[i]) {
start = i;
break;
}
}
if (start == -1) return true;
DFS(start);
for (int i = 0; i < n; i++) {
if (!removed[i] && !visited[i]) return false;
}
return true;
}
static boolean solve(int idx, int taken, int k, int n) {
if (taken == k - 1) {
return isConnected(n);
}
if (idx == n) return true;
removed[idx] = true;
if (!solve(idx + 1, taken + 1, k, n)) return false;
removed[idx] = false;
if (!solve(idx + 1, taken, k, n)) return false;
return true;
}
static boolean isKConnected(int n, int k) {
if (k >= n) return false;
removed = new boolean[n];
visited = new boolean[n];
return solve(0, 0, k, n);
}
public static void main(String[] args) {
int n = 5, k = 2;
adj = new ArrayList<>();
for (int i = 0; i < n; i++) adj.add(new ArrayList<>());
adj.get(0).addAll(Arrays.asList(1, 2));
adj.get(1).addAll(Arrays.asList(0, 2, 3));
adj.get(2).addAll(Arrays.asList(0, 1, 3, 4));
adj.get(3).addAll(Arrays.asList(1, 2, 4));
adj.get(4).addAll(Arrays.asList(2, 3));
System.out.println(isKConnected(n, k) ? "Graph is K-connected" : "Graph is not K-connected");
}
}
adj = []
removed = []
visited = []
def DFS(u):
visited[u] = True
for v in adj[u]:
if not visited[v] and not removed[v]:
DFS(v)
def isConnected(n):
global visited
visited = [False] * n
start = -1
for i in range(n):
if not removed[i]:
start = i
break
if start == -1:
return True
DFS(start)
for i in range(n):
if not removed[i] and not visited[i]:
return False
return True
def solve(idx, taken, k, n):
if taken == k - 1:
return isConnected(n)
if idx == n:
return True
removed[idx] = True
if not solve(idx + 1, taken + 1, k, n):
return False
removed[idx] = False
if not solve(idx + 1, taken, k, n):
return False
return True
def isKConnected(n, k):
global removed
if k >= n:
return False
removed = [False] * n
return solve(0, 0, k, n)
n, k = 5, 2
adj = [
[1, 2],
[0, 2, 3],
[0, 1, 3, 4],
[1, 2, 4],
[2, 3]
]
print("Graph is K-connected" if isKConnected(n, k) else "Graph is not K-connected")
using System;
using System.Collections.Generic;
class GfG {
static List<int>[] adj;
static bool[] removed, visited;
static void DFS(int u) {
visited[u] = true;
foreach (int v in adj[u]) {
if (!visited[v] && !removed[v]) {
DFS(v);
}
}
}
static bool IsConnected(int n) {
Array.Fill(visited, false);
int start = -1;
for (int i = 0; i < n; i++) {
if (!removed[i]) {
start = i;
break;
}
}
if (start == -1) return true;
DFS(start);
for (int i = 0; i < n; i++) {
if (!removed[i] && !visited[i]) return false;
}
return true;
}
static bool Solve(int idx, int taken, int k, int n) {
if (taken == k - 1) {
return IsConnected(n);
}
if (idx == n) return true;
removed[idx] = true;
if (!Solve(idx + 1, taken + 1, k, n)) return false;
removed[idx] = false;
if (!Solve(idx + 1, taken, k, n)) return false;
return true;
}
static bool IsKConnected(int n, int k) {
if (k >= n) return false;
removed = new bool[n];
visited = new bool[n];
return Solve(0, 0, k, n);
}
static void Main() {
int n = 5, k = 2;
adj = new List<int>[n];
for (int i = 0; i < n; i++) adj[i] = new List<int>();
adj[0].AddRange(new int[] {1, 2});
adj[1].AddRange(new int[] {0, 2, 3});
adj[2].AddRange(new int[] {0, 1, 3, 4});
adj[3].AddRange(new int[] {1, 2, 4});
adj[4].AddRange(new int[] {2, 3});
Console.WriteLine(IsKConnected(n, k) ? "Graph is K-connected" : "Graph is not K-connected");
}
}
let adj = [];
let removed = [];
let visited = [];
function DFS(u) {
visited[u] = true;
for (let v of adj[u]) {
if (!visited[v] && !removed[v]) {
DFS(v);
}
}
}
function isConnected(n) {
visited = new Array(n).fill(false);
let start = -1;
for (let i = 0; i < n; i++) {
if (!removed[i]) {
start = i;
break;
}
}
if (start === -1) return true;
DFS(start);
for (let i = 0; i < n; i++) {
if (!removed[i] && !visited[i]) return false;
}
return true;
}
function solve(idx, taken, k, n) {
if (taken === k - 1) {
return isConnected(n);
}
if (idx === n) return true;
removed[idx] = true;
if (!solve(idx + 1, taken + 1, k, n)) return false;
removed[idx] = false;
if (!solve(idx + 1, taken, k, n)) return false;
return true;
}
function isKConnected(n, k) {
if (k >= n) return false;
removed = new Array(n).fill(false);
return solve(0, 0, k, n);
}
// driver code
let n = 5, k = 2;
adj = [
[1, 2],
[0, 2, 3],
[0, 1, 3, 4],
[1, 2, 4],
[2, 3]
];
console.log(isKConnected(n, k) ? "Graph is K-connected" : "Graph is not K-connected");
Output
Graph is K-connected