Exact and approximate solution of
NP-hard problems:
coloring and clique search in graphs
Bogdán Zaválnij
University of Pécs
Institute of Mathematics and Informatics
Ljubljana, 2017
Bogdán Zaválnij (University of Pécs)
NP-hard problems
2017
1 / 20
Table of Contents
1
Maximum Clique and Graph Coloring
Combinatorial Optimization
Definition of the problems
2
Coloring problem
Culberson’s method
Brélaz’s DSatur coloring
Zykov’s algorithm
3
Clique problem
Greedy algorithms
Bron–Kerbosch Algorithm
Carraghan–Pardalos Algorithm
Östergård’s cliquer
Bogdán Zaválnij (University of Pécs)
NP-hard problems
2017
2 / 20
Maximum Clique and Graph Coloring
Table of Contents
1
Maximum Clique and Graph Coloring
Combinatorial Optimization
Definition of the problems
2
Coloring problem
Culberson’s method
Brélaz’s DSatur coloring
Zykov’s algorithm
3
Clique problem
Greedy algorithms
Bron–Kerbosch Algorithm
Carraghan–Pardalos Algorithm
Östergård’s cliquer
Bogdán Zaválnij (University of Pécs)
NP-hard problems
2017
3 / 20
Maximum Clique and Graph Coloring
Combinatorial Optimization
Combinatorial Optimization
Finding an optimal object from a finite set.
Often graph based problems
Some of them can be solved in polynomial time – for example the
Shortest path problem, or the Minimum weight spanning tree
problem
Some of them NP-hard – for example the Graph coloring problem,
or the Maximum clique problem ← we will look at these
Approach to NP-hard problems:
Approximate algorithms – using some heuristic method
Exact algorithms – usually a Branch-and-Bound algorithm
Bogdán Zaválnij (University of Pécs)
NP-hard problems
2017
4 / 20
Maximum Clique and Graph Coloring
Definition of the problems
The Minimum Coloring Problem
Let G be a finite, simple graph: G = (V , E).
A coloring of the nodes of G with r colors can be described more
formally as a surjective map f : V → {1, . . . , r }
two nodes connected by an edge cannot receive the same color:
if {u, v } ∈ E then f (v ) 6= f (u)
The level sets of f are the so-called color classes of the coloring.
The i-th color class Ci = {v : v ∈ V , f (v ) = i} consists of all the
nodes of G that are colored with color i.
The smallest number of colors that a graph can be colored legally
by is called the chromatic number of the graph and denoted by
χ(G).
The question if a given graph can be colored by k colors is a well
known NP-complete problem.
Finding the chromatic number is an NP-hard problem.
Bogdán Zaválnij (University of Pécs)
NP-hard problems
2017
5 / 20
Maximum Clique and Graph Coloring
Definition of the problems
The Maximum Clique Problem
Let G be a finite, simple graph: G = (V , E), and C be a subgraph,
which has the nodes ∆ ⊆ V , and C is spanned by ∆.
We call the subgraph C a clique, if all of its nodes are connected
to each other: ∀vi , ∀vj ∈ ∆, i 6= j : (vi , vj ) ∈ E
We call the clique size the number of the nodes in the clique
we call the clique size of the graph the size of its biggest clique
(maximum clique), and denote it by ω(G).
The Problem:
We can search for the size of a maximum clique, or ask if a given
graph has a clique of size k
The k -clique question is a well known NP-complete problem
The maximum clique optimization problem is NP-hard
Obviously one can examine all the subgraphs: a problem of size
2|V | – it would be unrealistic to do so.
Bogdán Zaválnij (University of Pécs)
NP-hard problems
2017
6 / 20
Maximum Clique and Graph Coloring
Definition of the problems
Methods for solving these problems
For approximate solution we use some greedy heuristic.
For exact solution we we can use some backtracking algorithms.
(Eight Queen problem, Sudoku game)
For example the Carraghan & Pardalos algorithm is a classical
Branch-and-Bound technique. We take the nodes of the graph each by
one, and reduce the graph to their neighborhood.
If the reduced graph is “not satisfactory” we go back, if it is
“satisfactory” we do the same (go forward).
branching: we try several different nodes, if they should be in a
maximum clique
bound: we try to prune the branches of the search tree (number of
nodes, coloring)
Bogdán Zaválnij (University of Pécs)
NP-hard problems
2017
7 / 20
Maximum Clique and Graph Coloring
Definition of the problems
Methods for solving these problems
For approximate solution we use some greedy heuristic.
For exact solution we we can use some backtracking algorithms.
(Eight Queen problem, Sudoku game)
For example the Carraghan & Pardalos algorithm is a classical
Branch-and-Bound technique. We take the nodes of the graph each by
one, and reduce the graph to their neighborhood.
If the reduced graph is “not satisfactory” we go back, if it is
“satisfactory” we do the same (go forward).
branching: we try several different nodes, if they should be in a
maximum clique
bound: we try to prune the branches of the search tree (number of
nodes, coloring)
Bogdán Zaválnij (University of Pécs)
NP-hard problems
2017
7 / 20
Maximum Clique and Graph Coloring
Definition of the problems
Applications
Coloring:
scheduling
register allocation (in compilers)
non-overlapping channel allocation
the Sudoku game
Clique / Independent set:
coding theory
portfolio selection
image recognition
drug design (protein docking)
substructure searching between molecules
Bogdán Zaválnij (University of Pécs)
NP-hard problems
2017
8 / 20
Coloring problem
Table of Contents
1
Maximum Clique and Graph Coloring
Combinatorial Optimization
Definition of the problems
2
Coloring problem
Culberson’s method
Brélaz’s DSatur coloring
Zykov’s algorithm
3
Clique problem
Greedy algorithms
Bron–Kerbosch Algorithm
Carraghan–Pardalos Algorithm
Östergård’s cliquer
Bogdán Zaválnij (University of Pécs)
NP-hard problems
2017
9 / 20
Coloring problem
Culberson’s method
Greedy sequential coloring
The simplest way to color a graph is the sequential greedy coloring
algorithm. We define a sequence of nodes (v1 , v2 , . . . , vn )
Require: k = 0 (number of colors used)
1: function G REEDY S EQUENTIAL C OLORING
2:
for all vi ∈ V in increasing order do
3:
for all Cj color class in increasing order do
4:
if node vi fits into the color class Cj then
5:
Cj ← vi
6:
(that is: put vi into color class Cj )
7:
8:
9:
10:
11:
if We couldn’t put vi in any color class then
k ←k +1
open the new color class Ck
C k ← vi
(that is: put vi into the new color class Ck )
Bogdán Zaválnij (University of Pécs)
NP-hard problems
2017
10 / 20
Coloring problem
Culberson’s method
Culberson’s re-coloring algorithm
Some notes on this method:
The ordering of nodes have great impact on the number of colors
used
→ Crown graph
If we re-color nodes of the graph, that is the order of nodes
defined by color classes, we get at least as good coloring
=⇒ there is a “perfect” ordering that results the best coloring
Using this fact Culberson proposed a re-coloring technique:
1
color the nodes of the given graph
2
reorder the color classes
by decreasing size
by increasing size
randomly
3
4
make the new sequence of nodes by the new order of color
classes
repeat from 1.
Bogdán Zaválnij (University of Pécs)
NP-hard problems
2017
11 / 20
Coloring problem
Culberson’s method
Culberson’s re-coloring algorithm
Some notes on this method:
The ordering of nodes have great impact on the number of colors
used
→ Crown graph
If we re-color nodes of the graph, that is the order of nodes
defined by color classes, we get at least as good coloring
=⇒ there is a “perfect” ordering that results the best coloring
Using this fact Culberson proposed a re-coloring technique:
1
color the nodes of the given graph
2
reorder the color classes
by decreasing size
by increasing size
randomly
3
4
make the new sequence of nodes by the new order of color
classes
repeat from 1.
Bogdán Zaválnij (University of Pécs)
NP-hard problems
2017
11 / 20
Coloring problem
Brélaz’s DSatur coloring
Daniel Brélaz’s DSatur (Degree SATuration) coloring
Greedy algorithm
Idea: we choose the least suitable node to color
we should calculate the fitting of the uncolored nodes into the color
classes
1
Optimal node
minimal freedom (less suitable color classes)
maximum degree (debated)
2
Color the node
Put into the first free color class, or
Open a new class (if no free)
3
Update information of remaining nodes
If the just colored node have a neighbour, then
It cannot be placed in that color class
The freedom of it will decreese by one
Bogdán Zaválnij (University of Pécs)
NP-hard problems
2017
12 / 20
Coloring problem
Brélaz’s DSatur coloring
Daniel Brélaz’s DSatur (Degree SATuration) coloring
Greedy algorithm
Idea: we choose the least suitable node to color
we should calculate the fitting of the uncolored nodes into the color
classes
1
Optimal node
minimal freedom (less suitable color classes)
maximum degree (debated)
2
Color the node
Put into the first free color class, or
Open a new class (if no free)
3
Update information of remaining nodes
If the just colored node have a neighbour, then
It cannot be placed in that color class
The freedom of it will decreese by one
Bogdán Zaválnij (University of Pécs)
NP-hard problems
2017
12 / 20
Coloring problem
Brélaz’s DSatur coloring
Daniel Brélaz’s DSatur (Degree SATuration) coloring
Greedy algorithm
Idea: we choose the least suitable node to color
we should calculate the fitting of the uncolored nodes into the color
classes
1
Optimal node
minimal freedom (less suitable color classes)
maximum degree (debated)
2
Color the node
Put into the first free color class, or
Open a new class (if no free)
3
Update information of remaining nodes
If the just colored node have a neighbour, then
It cannot be placed in that color class
The freedom of it will decreese by one
Bogdán Zaválnij (University of Pécs)
NP-hard problems
2017
12 / 20
Coloring problem
Brélaz’s DSatur coloring
Daniel Brélaz’s DSatur (Degree SATuration) coloring
Greedy algorithm
Idea: we choose the least suitable node to color
we should calculate the fitting of the uncolored nodes into the color
classes
1
Optimal node
minimal freedom (less suitable color classes)
maximum degree (debated)
2
Color the node
Put into the first free color class, or
Open a new class (if no free)
3
Update information of remaining nodes
If the just colored node have a neighbour, then
It cannot be placed in that color class
The freedom of it will decreese by one
Bogdán Zaválnij (University of Pécs)
NP-hard problems
2017
12 / 20
Coloring problem
Zykov’s algorithm
Zykov’s algorithm
A backtracking algorithm. We build a search tree (Zykov tree) using
two modifications on the input graph. We take a non-edge {x, y } of the
graph.
1
2
G0 = G/x, y , that is we contract the two nodes x, y into one node.
The neighborhood of the new node is the common neighborhood
of both: N(x) ∪ N(y )
G0 = G + xy , that is we add the new edge {x, y }
Theorem
χ(G) = min (χ(G/x, y ), χ(G + xy ))
Proof.
χ(G) = min ({χ(G), f (x) = f (y )}, {χ(G), f (x) 6= f (y )})
Bogdán Zaválnij (University of Pécs)
NP-hard problems
2017
13 / 20
Clique problem
Table of Contents
1
Maximum Clique and Graph Coloring
Combinatorial Optimization
Definition of the problems
2
Coloring problem
Culberson’s method
Brélaz’s DSatur coloring
Zykov’s algorithm
3
Clique problem
Greedy algorithms
Bron–Kerbosch Algorithm
Carraghan–Pardalos Algorithm
Östergård’s cliquer
Bogdán Zaválnij (University of Pécs)
NP-hard problems
2017
14 / 20
Clique problem
Greedy algorithms
Greedy maximum clique methods
Maximum degree rule:
C = ∅, P = V
1
choose node v with the greatest degree
2
C 0 = C ∪ {v }, P 0 = N(v )
3
STOP if P 0 empty
Minimum degree rule:
C=V
1
choose node v with the smallest degree
2
C 0 = C \ {v }
3
STOP if C 0 a clique
Bogdán Zaválnij (University of Pécs)
NP-hard problems
2017
15 / 20
Clique problem
Bron–Kerbosch Algorithm
Bron–Kerbosch Algorithm (1973)
R is the nodes of the clique we are building, P are the perspective
nodes. X are those nodes, we excluded.
Require: R = ∅, P = V , X = ∅
1: function B RON K ERBOSCH(R, P, X )
2:
if P and X are both empty then
3:
report R as a maximal clique
4:
for all vertex v ∈ P do
5:
B RON K ERBOSCH(R ∪ {v }, P ∩ N(v ), X ∩ N(v ))
6:
P ← P \ {v }
7:
X ← X ∪ {v }
Bogdán Zaválnij (University of Pécs)
NP-hard problems
2017
16 / 20
Clique problem
Carraghan–Pardalos Algorithm
Carraghan–Pardalos Algorithm (1990)
C is the nodes of the clique we are building, C ∗ are the nodes of the
biggest clique found till now. P are the perspective nodes.
Require: C = ∅, P = V
1: function CP(C, P)
2:
if |C| > |C ∗ | then
3:
C∗ ← C
4:
if |C| + |P| > |C ∗ | then
5:
for all vertex p ∈ P do
6:
CP(C ∪ {p}, P ∩ N(p))
7:
P ← P \ {p}
Bogdán Zaválnij (University of Pécs)
NP-hard problems
2017
17 / 20
Clique problem
Carraghan–Pardalos Algorithm
Carraghan–Pardalos Algorithm (1990)
C is the nodes of the clique we are building, C ∗ are the nodes of the
biggest clique found till now. P are the perspective nodes.
Require: C = ∅, P = V
1: function CP(C, P)
2:
if |C| > |C ∗ | then
3:
C∗ ← C
4:
if |C| + |P| > |C ∗ | then
5:
for all vertex p ∈ P do
6:
CP(C ∪ {p}, P ∩ N(p))
7:
P ← P \ {p}
Bogdán Zaválnij (University of Pécs)
NP-hard problems
2017
17 / 20
Clique problem
Carraghan–Pardalos Algorithm
Carraghan–Pardalos Algorithm (1990)
We can use coloring of the subgraph instead of the size of the
subgraph (|P|). The combinatorial meaning of witch is that we cannot
take more than one node from a color class to be a part of a clique.
ω(G) ≤ χ(G)
Notes:
1
coloring is also used in branch factor modification
2
other types of coloring – such as fractional, etc – can be used as
well
3
obviously |P| can be replaced with other, non combinatorial
measurement – LP or SDP techniques are used, for example the
Lovász’ theta function
Bogdán Zaválnij (University of Pécs)
NP-hard problems
2017
18 / 20
Clique problem
Carraghan–Pardalos Algorithm
Carraghan–Pardalos Algorithm (1990)
We can use coloring of the subgraph instead of the size of the
subgraph (|P|). The combinatorial meaning of witch is that we cannot
take more than one node from a color class to be a part of a clique.
ω(G) ≤ χ(G)
Notes:
1
coloring is also used in branch factor modification
2
other types of coloring – such as fractional, etc – can be used as
well
3
obviously |P| can be replaced with other, non combinatorial
measurement – LP or SDP techniques are used, for example the
Lovász’ theta function
Bogdán Zaválnij (University of Pécs)
NP-hard problems
2017
18 / 20
Clique problem
Östergård’s cliquer
Östergård’s cliquer (2002)
Russian doll technique. We use a fixed sequence of the nodes
(v1 , v2 , . . . vn ) and build up a function c(i). Let
Si = {vi , vi+1 , . . . , vn }
c(i) indicates the size of the clique in Si . Note, that either
c(i) = c(i + 1) or c(i) = c(i + 1) + 1.
The algorithm starts with calculating cn , and follows till c1 . By each
step:
P = N(vi ) ∩ Si
take the nodes of P in decreasing order (u) – Branching
either c(u) is too small to increase ci – Go back, delete u from P
or P 0 = N(u) ∩ P – Go forward
Bogdán Zaválnij (University of Pécs)
NP-hard problems
2017
19 / 20
Bibliography
Culberson, J.C. Iterated Greedy Graph Coloring and the Difficulty
Landscape. Technical Report, University of Alberta, 1992.
Brélaz, D. “New Methods to color the vertices of a graph.”
Communication of ACM. April 1979, Vol. 22. Number 4.
McDiarmid, C. “Determining the chromatic number of a graph.”
SIAM J. Comput. Vol. 8., No 1. February 1979.
Wo, Q. and Hao, J-K. “A review on algorithms for maximum clique
problems.” European Journal of Operational Research. Volume
242, Issue 3, 1 May 2015, Pages 693–709.
Thank you for your attention!
Questions?
Bogdán Zaválnij (University of Pécs)
NP-hard problems
2017
20 / 20
Bibliography
Culberson, J.C. Iterated Greedy Graph Coloring and the Difficulty
Landscape. Technical Report, University of Alberta, 1992.
Brélaz, D. “New Methods to color the vertices of a graph.”
Communication of ACM. April 1979, Vol. 22. Number 4.
McDiarmid, C. “Determining the chromatic number of a graph.”
SIAM J. Comput. Vol. 8., No 1. February 1979.
Wo, Q. and Hao, J-K. “A review on algorithms for maximum clique
problems.” European Journal of Operational Research. Volume
242, Issue 3, 1 May 2015, Pages 693–709.
Thank you for your attention!
Questions?
Bogdán Zaválnij (University of Pécs)
NP-hard problems
2017
20 / 20
© Copyright 2026 Paperzz