Graph coloring with densest subgraph

Problem definition

An undirected graph GG is kk-coloring if all vertices could be colored with at most kk different colors, such that all adjacent vertices have different colors. For example, a kk-clique is kk-coloring, and a tree is 2-coloring. The densest subgraph of a graph GG, is an induced subgraph of a vertex subset SS of GG with nSn_S vertices and mSm_S edges, such that its density (i.e., ρmax=2mSnS\rho_{max}=\frac{2m_S}{n_S}) is highest among all induced subgraphs. In this article, we aim to prove that for a graph GG whose densest subgraph has a density ρmax\rho_{max}, it is ρmax+1\lceil\rho_{max}+1\rceil-coloring.

Proof

Let G=(V,E)G=(V,E) and n=V,m=En=|V|,m=|E|. We prove it by induction. When n=1n=1, ρmax=0\rho_{max}=0 and the graph is 1-coloring.

Assume we have proved the case for n=in=i. For any graph GG such that n=i+1n=i+1, we denote SS as the vertex set of its densest subgraph and assume its density is ρmax\rho_{max}. Then we remove the smallest degree vertex uu of GG and derives a graph with ii vertices, which is proved to be ρmax+1\lceil\rho_{max}'+1\rceil-coloring and ρmax\rho_{max}' is the largest density of the new graph. Obviously, the degree of uu is no larger than ρmax\rho_{max}. Otherwise, the total degree of all vertices in GG is larger than ρmaxn\rho_{max}n, which yields a density larger than ρmax\rho_{max}. Therefore, uu can be colored with at most ρmax+1\lceil\rho_{max}+1\rceil colors (if only considering its neighbours).

We claim that ρmaxρmax\rho_{max}'\leq\rho_{max}. Then GG is ρmax+1\lceil\rho_{max}+1\rceil-coloring (note that if a graph is aa-coloring and aba\leq b, then it is also bb-coloring).

We prove it by contradiction. If ρmax>ρmax\rho_{max}'>\rho_{max}, removing uu results in some induced subgraph with a larger density. However, by definition, the densest subgraph of GG is already the induced subgraph with the highest density. Therefore, it is impossible to find a denser subgraph by removing a vertex in GG.

By induction, the proof is done.

Finding a coloring scheme

We recursively remove the smallest degree vertex in GG. Specifically, we maintain a min-heap storing the degrees of all vertices. Initially, we insert all vertices into the heap. For each round, we extract the minimum degree vertex from the heap and remove the vertex. During the remove process, we need to update the degree of its neighbors (for a simple graph, the new degree of its neighbors dnewd_{new} should be dold1d_{old}-1) and adjust the heap. With a binary heap, since extracting each vertex and updating the degree of each vertex is O(logn)O(\log n), and there are mm updates in total, the time complexity would be O(mlogn)O(m\log n). With a Fibonacci heap, where decrease-key function could be done in O(1)O(1), the time complexity would reduce to O(m+nlogn)O(m+n\log n).

We record the sequence a1,a2,,ana_1,a_2,\cdots,a_n of removing vertices, i.e., the algorithm removes a1,a2,,ana_1,a_2,\cdots,a_n sequentially. To construct the coloring scheme, we reversely consider each vertex: let GG' be an empty graph. We firstly add ana_n to GG' and color it with 11. Then we add an1a_{n-1} to GG' and its corresponding edges in GG connecting ana_n (if exist). If an,an1a_n,a_{n-1} are connected, we color an1a_{n-1} with 22. Otherwise, it is colored with 11. Similarly, we add an2a_{n-2} to GG' and its edges to an1,ana_{n-1},a_n if exist, and color an2a_{n-2} with the minimum possible color. Repeat this process until a1a_1 is inserted into GG and colored. The time complexity of this process is bounded by O(m)O(m).

Therefore, the total time complexity of the algorithm is bounded by O(m+nlogn)O(m+n\log n), and it is straightforward to prove its correctness using the similar technique in the induction proof.