Let G=(V,E)G = (V, E) be an undirected graph with ∣V∣=n|V| = n vertices and ∣E∣=m|E| = m edges.
For each S⊂VS \subset V, denote E(S)E(S) the set of edges in the subgraph induced by SS, i.e.,

E(S)≐{(u,v)∈E:u,v∈S}. E(S) \doteq \{ (u, v) \in E : u, v \in S \}.

The density of the subgraph induced by SS is

dG(S)≐∣E(S)∣∣S∣. d_G(S) \doteq \frac{|E(S)|}{|S|}.

Problem. Find S∗⊂VS^* \subset V, s.t. dG(S∗)d_G(S^*) is maximized.

Greedy Algorithm

Definition. Given S⊂VS \subset V, for each u∈Su \in S, define the set of edges incident to uu in SS as

E(u,S)≐{(u,v)∈E(S)}. E(u, S) \doteq \{ (u, v) \in E(S) \}.

Definition. A function w:E→Vw: E \rightarrow V is called an edge assignment, if it maps each edge (u,v)∈E(u, v) \in E to one of its endpoints {u,v}\{u, v \}.

There is a linear time, 2-approximation greedy algorithm [1] which works as follows.

Greedy Algorithm.

  1. S1←VS_1 \leftarrow V;
  2. for i∈[n]i \in [n] do
  3. \qquad ui←arg⁡min⁡u∈Si∣E(u,Si)∣u_i \leftarrow \arg\min_{u \in S_i} |E(u, S_i)|;
  4. \qquad Si+1←Si∖{ui}S_{i + 1} \leftarrow S_i \setminus \{ u_i \};
  5. \qquad for e=(ui,v)∈E(ui,Si)e = (u_i, v) \in E(u_i, S_i) do
  6. \qquad \qquad w(e)←uiw(e) \leftarrow u_i;
  7. k←arg⁡max⁡i∈n]∣E(ui,Si)∣k \leftarrow \arg\max_{i \in n]} |E(u_i, S_i)|;
  8. return SkS_k;

Approximation Guarantee

Definition. Given an edge assignment ww, for each u∈Vu \in V, denote the set of edges assigned to uu as

Aw(u)≐{e=(u,v)∈E:w(e)=u}. A_w(u) \doteq \{ e = (u, v) \in E : w(e) = u \}.

The approximation guarantee relies on the following lemma.

Lemma. For edge assignment ww and each S⊂VS \subset V, it holds that

max⁡u∈V∣Aw(u)∣≥dG(S). \max_{u \in V} |A_w(u)| \ge d_G(S).

Proof. Observe that all edges in E(S)E(S) are assigned to vertices in SS. It follows that

max⁡u∈V∣Aw(u)∣≥max⁡u∈S∣Aw(u)∣≥∣E(S)∣∣S∣=dG(S). \max_{u \in V} |A_w(u)| \ge \max_{u \in S} |A_w(u)| \ge \frac{|E(S)|}{|S|} = d_G(S).

□\square

Theorem. The solution SkS_k satisfies

dG(Sk)≥12⋅dG(S∗). d_G(S_k) \ge \frac{1}{2} \cdot d_G (S^*).

Proof.
Let ww be the assignment constructed by the greedy algorithm, and denote

dmax⁡≐max⁡u∈V∣Aw(u)∣=max⁡i∈[n]∣E(ui,Si)∣=∣E(uk,Sk)∣. d_{\max} \doteq \max_{u \in V} |A_w(u)| = \max_{i \in [n]} |E(u_i, S_i)| = |E(u_k, S_k)|.

Via the previous lemma, it holds that

dG(S∗)≤dmax⁡=∣E(uk,Sk)∣. d_G(S^*) \le d_{\max} = |E(u_k, S_k)|.

Further, as uku_k is the vertices with minimum degree in the subgraph induced by SkS_k, ∣E(uk,Sk)∣|E(u_k, S_k)| should be upper bounded by the average degree in SkS_k:

dG(S∗)≤∣E(uk,Sk)∣≤2⋅∣E(Sk)∣∣Sk∣=2⋅dG(Sk). d_G(S^*) \le |E(u_k, S_k)| \le 2 \cdot \frac{|E(S_k)|}{ |S_k| } = 2 \cdot d_G(S_k).

□\square

Running Time

Theorem. The algorithm can be implemented in O(m+n)O(m + n) time.

Proof.

We can maintain the degrees of the vertices in Si,i∈[n]S_i, i \in [n] dynamically.

  1. At the beginning of the algorithm, set d(u)=∣E(u,V)∣=∣E(u,Si)∣d(u) = |E(u, V)| = |E(u, S_i)| for each u∈Vu \in V. We maintain the invariant that d(u)=∣E(u,Si)∣d(u) = |E(u, S_i)| at the beginning of each iteration i∈[n]i \in [n].

  2. At the i(th)i^{(th)} iteration, when uiu_i is removed from SiS_i to construct Si+1S_{i + 1}, we decrease d(v)d(v) by 11, if (ui,v)∈E(Si)(u_i, v) \in E(S_i).

It is easy to see that the invariant is maintained, and the total update time is O(m)O(m).

Next, we design a data structure that supports the extraction of uiu_i, the vertex with minimum degree in SiS_i, in O(1)O(1) time. We keep an array with size nn.

  • Each vertex uu is kept in the d(u)d(u)-th bucket of the array. When d(u)d(u) is updated, we update the bucket of uu correspondingly. The total update cost is O(m)O(m).

  • At the beginning of the algorithm, we search bucket 0,1,…0, 1, \ldots , until we find the first non-empty bucket j∈[n]j \in [n]. Then we extract a vertex uu from the bucket jj, and updates the d(v)d(v) for which vv is neighbor of uu in the induced subgraph. The update decreases d(v)d(v) by 11. Therefore, the bucket max⁡{0,j−1}\max \{ 0, j - 1 \} can become non-empty at the next iteration, from which we should try to find the next vertex with minimum degree. There are nn iteration, and we can move backward at the array by at most nn steps. It follows that the total searching cost in the array is O(n)O(n).

□\square

Reference

[1] M. Charikar, “Greedy Approximation Algorithms for Finding Dense Components in a Graph,” 2000.