Tecniche Algoritmiche per Grafi e Reti Fabrizio Frati Dipartimento di Informatica e Automazione Università degli Studi Roma Tre • 3 CREDITI • I° periodo: • Lunedì.

Download Report

Transcript Tecniche Algoritmiche per Grafi e Reti Fabrizio Frati Dipartimento di Informatica e Automazione Università degli Studi Roma Tre • 3 CREDITI • I° periodo: • Lunedì.

Slide 1

Tecniche Algoritmiche per Grafi e Reti
Fabrizio Frati

Dipartimento di Informatica e Automazione
Università degli Studi Roma Tre

• 3 CREDITI
• I° periodo:
• Lunedì 9:45-11:15 aula N13

• II° periodo:
• Venerdì 8:00-9:45 aula N7

• Contatti:
• {angelini,gdb,frati,ratm} @dia.uniroma3.it
• Ricevimento: mercoledì dalle 17 alle 19

• Struttura del Corso
• ~ 8 seminari
• algoritmi, strutture dati, combinatorica,
graph drawing…

• progetti a gruppi di 2 - 4 persone
• problema di ricerca

• Materiale Didattico
• slides
• G. Di Battista, P. Eades, R. Tamassia, I. G.
Tollis, Graph Drawing: Algorithms for the
Visualization of Graphs, 1999. Prentice Hall.

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
C. Computer System Organization
1.
2.
3.
4.
5.

Processor Architectures
Computer-Communication Networks
Application-Based Systems
Performance of Systems
Computer System Implementations

ACM Computing Classification System
C. Computer System Organization
2. Computer-Communication Networks
2.1 Network Architectures
2.2 Network Protocols
2.3 Network Operations
2.4 Distributed Systems
2.5 LAN & WAN
2.6 Internetworking

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
E. Data
1.
2.
3.
4.
5.

Data Structures
Data Storage Representations
Data Encryption
Coding and Information Theory
Files

ACM Computing Classification System
E. Data
1. Data Structures
1.1 Arrays
1.2 Distributed Data Structures
1.3 Graphs and Networks
1.4 Lists, Stacks, and Queues
1.5 Records
1.6 Tables
1.7 Trees

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
F. Theory of Computation
1.
2.
3.
4.

Computation by Abstract Devices
Analysis of Algorithms and Problem Complexity
Logics and Meanings of Programs
Mathematical Logic and Formal Languages

ACM Computing Classification System
F. Theory of Computation
1. Computation by Abstract Devices
1.1 Models of Computation
1.2 Complexity Measures and Completeness
1.2.1 Complexity Hierarchies
1.2.2 Machine-Independent Complexity
1.2.3 Reducibility and Completeness
1.2.4 Relations among Complexity Classes

ACM Computing Classification System
F. Theory of Computation
2. Analysis of Algorithms and Problem Complexity
2.1 Numerical Algorithms
2.2 Non-numerical Algorithms and Problems
2.2.1 Complexity of Proof Procedures
2.2.2 Computations on Discrete Structures
2.2.3 Geometrical Problems
2.2.4 Pattern Matching
2.2.5 Routing and Layout
2.2.6 Sequencing and Scheduling
2.2.7 Sorting and Searching

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
G. Mathematics of Computing
1.
2.
3.
4.

Numerical Analysis
Discrete Mathematics
Probability and Statistics
Mathematical Software

ACM Computing Classification System
G. Mathematics of Computing
2. Discrete Mathematics
2.1 Combinatorics

2.1.1 Combinatorial Algorithms
2.1.2 Counting Problems
2.1.3 Generating Functions
2.1.4 Permutations and Combinations
2.1.5 Recurrences and Difference Equations

2.2 Graph Theory
2.2.1 Graph Algorithms
2.2.2 Graph Labeling

2.2.5 Path and Circuit Problems
2.2.6 Trees

2.3 Applications

a world FULL of NP-hard problems
Problem: I want to travel among a set of
cities driving the fewest possible number
of KMs. IT’S DIFFICULT!!

Problem: I want to put a set of objects
into some bags, knowing that each bag
can not afford more than 10 KGs and
trying to use as few bags as possible.
IT’S DIFFICULT!!

How to Deal with NP-hard problems?
• Exact Algorithms
• Randomized Algorithms
• Approximation Algorithms
• Fixed-Parameter Tractable Algorithms
• …

Approximation Algorithms

Approximation Algorithms
• We want a solution “close” to the
optimal one.
• Given a minimization problem Π, an
algorithm is an α-approximation for Π if,
for every instance I of Π, it outputs a
solution SOL(I) such that
SOL(I)/OPT(I) ≤ α

Vertex Cover
• Problem: Given a graph G(V,E), find a
minimum vertex cover, that is, a set V’  V
such that every edge e  E has an
endvertex in V’.

NP-hard 
[Karp]

How to Guarantee an Approximation?
• We want an approximation algorithm
for Vertex Cover.
• The cost of the solution produced by the
algorithm should be compared with the
cost of an optimal solution.

• But computing the cost of an optimal
solution is NP-HARD!!
LOWER BOUNDS!

Lower Bound for Vertex Cover
• Given a graph G(V,E), a matching M is
a set of edges M  E such that no two
edges share an endvertex.
• A matching is maximal if no matching M’
exists such that M  M’.

• The size of a matching
is a lower bound on the
size of an optimal
solution to Vertex
Cover!

An Approximation Algorithm
for Vertex Cover

• Algorithm: Find a maximal matching M
and output the set S of matched vertices

An Approximation Algorithm
for Vertex Cover
• Theorem: The previous algorithm is a
2-approximation algorithm for Vertex Cover
• Proof:
• S is a vertex cover, otherwhise the
matching would not be maximal.
• OPT≥M, where M is the size of the output
maximal matching.
• SOL=2M, as the number of matched
vertices is twice the size of the matching.

Approximation Algorithms:much more…
• Approximation schemes: (1+ε)-approx.
• Inapproximability results.
• Complexity classes, e.g., APX.

Fixed-Parameter Tractable Algorithms

Easy or Hard?
Problem (optimization): Let G be a graph.
Which is the minimum number of vertices
whose deletion makes G planar?

NP-hard 
[Lewis-Yannakakis ]

Easy or Hard?
Problem (decision): Let G be a graph and k
be an integer. Is there a set of k vertices
whose deletion makes G planar?
Polynomial 
• Easy O(nk+1) time algorithm for solving the problem:
• Consider every set of k vertices. Remove such
vertices. Test the planarity of the resulting graph.

• There are O(nk) such sets. Testing the planarity of
an n-vertex graph takes O(n) time. Then,
T(n,k)= O(nk) O(n) = O(nk+1)

Easy or Hard?
Where is the trick?
In the decision version, k is a constant
parameter part of the input
An O(nk+1)-time algorithm, with k constant, is a
polynomial-time algorithm.

But it is very slow 

Fixed-Parameter Tractability
A problem is fixed-parameter tractable
if it can be solved in f(k) nO(1) time,
where k is a parameter of the problem,
f is an arbitrary function, and nO(1) is a
polynomial (not depending on k).

FPT algorithm for Vertex Cover
Theorem [Melhorn]: There is an O(2k n)time algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• There is a vertex cover with k=0 if and only if G
has no edge.
• Consider any edge e=(u,v). Either u or v belongs
to any vertex cover S.
• Consider both the case in which u S and the
case in which v S.

FPT algorithm for Vertex Cover
u

u

v

v

• u  S -> S is a vertex cover of G if and only if
S-{u} is a vertex cover of G-{u} -> solve the
instance (G-{u}, k-1)
• v  S -> S is a vertex cover of G if and only if
S-{v} is a vertex cover of G-{v} -> solve the
instance (G-{v}, k-1)

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• T(n,0) = O(n)
• T(n,k) = 2 T(n-1, k-1) +O(n) ≤ 2 T(n, k-1) +O(n) ≤
2 (2 T(n, k-2) +O(n)) +O(n) ≤
2 (2 (2 T(n, k-3) +O(n)) +O(n)) +O(n) ≤
2 (2 (2 (…(2 T(n, 0)+O(n)) + … +O(n))
+O(n)) +O(n) ≤
2k O(n) + (2k-1 + 2k-2 + 2k-3 + ... + 1) O(n) =
2k O(n) + (2k - 1) O(n) = O(2k n)

Reduction Rules
Reduction rule : a rule (that is, a polynomial time
algorithm) that transforms an instance (I,k) to
an "equivalent and simpler” instance (I', k’).

Equivalent: (I,k) is a YES instance if and only if
(I', k') is a YES instance.
Simpler: |I'|<|I| or k'occurrences of a particular substructure.

Another FPT algorithm for Vertex Cover
Theorem: There is an O(1.6181k n2)-time
algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• We apply the following two reduction rules:
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k).
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u,N(u)},k-1).

Another FPT algorithm for Vertex Cover
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k). Correctness: if S is a vertex
cover of G and u is in S, then S-{u} is also a
vertex cover of G, as u has no incident edge.
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u, N(u)},k-1). Correctness: if S is a
vertex cover of G and u is in S, then
S-{u}  N(u) is also a vertex cover of G, as u
has no other incident edge.

Another FPT algorithm for Vertex Cover
• If neither of the two rules can be applied,
then every vertex has degree at least 2.
• Pick a vertex u. Any vertex cover of G
contains either u or N(u). Thus, (G,k) is a YES
instance if and only if (G-{u},k-1) or
(G-N(u),k-|N(u)|) is.

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• Since |N(u)|\geq 2,
• T(n,k) ≤ T(n,k-1)+ T(n,k-2)+O(n^2).
• Fibonacci series: every number is the sum of
the previous two xk =xk-1 +xk-2 +c.

• The k-th number of the Fibonacci series
tends to the golden ratio to the power of k.
• T(n,k)=Φk O(n2)=((1+√5)/2)k O(n2) =
O(1.6181k n2).

Kernelization
• Sometimes the reduction rules work till the size
of the problem is reduced really a lot. That is,
after the reduction rules have been applied,
the problem has size g(k), for some function k.
In this case the problem has a g(k)-kernel.

• Kernel: given a problem and an instance (I,k), a
kernel is an algorithm that outputs in polynomial
time an instance (I',k') such that (a) (I',k') is a
YES instance if and only if (I,k) is; (b) |I'|and k'
Kernelization
• Theorem [Niedermaier]: Every fixed-parameter
tractable problem has a g(k)-kernel.
• Proof: Suppose that there exists a FPT
algorithm with running time f(k) nc, for some
function f and some constant c. Consider an
instance (I,k) with |I|=n.
• If n>f(k), we run the decision algorithm in time
f(k) nc < nc+1. If it returns YES (NO), the
kernelization algorithm outputs a constant size
YES (resp. NO) instance.
• If n≤f(k), the the kernelization algorithm
returns (I,k).

Kernelization
• The last theorem implies that every problem
that is FPT has a kernel.
• However, the goal is to obtain kernels that are
"small", that is, polynomial in k, or even constant.

FPT: much more…
• Some problems are not FPT (e.g., graph coloring).
• Complexity classes: W[1] -> Can a nondeterministic Turing machine accept an unary
string s in at most k steps?
• Independent Set is W[1]-hard.
• Reductions to W[1]-hard problems give new
W[1]-hard problems.
• Lower bounds for FPT tractability
• Upper and lower bounds for the size of the
kernels

FPT: much more…
• Theorem [Robertson and Seymour]: Every graph
problem with parameter k whose YES istances
are closed under taking minors can be solved in
O(f(k) n3)


Slide 2

Tecniche Algoritmiche per Grafi e Reti
Fabrizio Frati

Dipartimento di Informatica e Automazione
Università degli Studi Roma Tre

• 3 CREDITI
• I° periodo:
• Lunedì 9:45-11:15 aula N13

• II° periodo:
• Venerdì 8:00-9:45 aula N7

• Contatti:
• {angelini,gdb,frati,ratm} @dia.uniroma3.it
• Ricevimento: mercoledì dalle 17 alle 19

• Struttura del Corso
• ~ 8 seminari
• algoritmi, strutture dati, combinatorica,
graph drawing…

• progetti a gruppi di 2 - 4 persone
• problema di ricerca

• Materiale Didattico
• slides
• G. Di Battista, P. Eades, R. Tamassia, I. G.
Tollis, Graph Drawing: Algorithms for the
Visualization of Graphs, 1999. Prentice Hall.

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
C. Computer System Organization
1.
2.
3.
4.
5.

Processor Architectures
Computer-Communication Networks
Application-Based Systems
Performance of Systems
Computer System Implementations

ACM Computing Classification System
C. Computer System Organization
2. Computer-Communication Networks
2.1 Network Architectures
2.2 Network Protocols
2.3 Network Operations
2.4 Distributed Systems
2.5 LAN & WAN
2.6 Internetworking

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
E. Data
1.
2.
3.
4.
5.

Data Structures
Data Storage Representations
Data Encryption
Coding and Information Theory
Files

ACM Computing Classification System
E. Data
1. Data Structures
1.1 Arrays
1.2 Distributed Data Structures
1.3 Graphs and Networks
1.4 Lists, Stacks, and Queues
1.5 Records
1.6 Tables
1.7 Trees

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
F. Theory of Computation
1.
2.
3.
4.

Computation by Abstract Devices
Analysis of Algorithms and Problem Complexity
Logics and Meanings of Programs
Mathematical Logic and Formal Languages

ACM Computing Classification System
F. Theory of Computation
1. Computation by Abstract Devices
1.1 Models of Computation
1.2 Complexity Measures and Completeness
1.2.1 Complexity Hierarchies
1.2.2 Machine-Independent Complexity
1.2.3 Reducibility and Completeness
1.2.4 Relations among Complexity Classes

ACM Computing Classification System
F. Theory of Computation
2. Analysis of Algorithms and Problem Complexity
2.1 Numerical Algorithms
2.2 Non-numerical Algorithms and Problems
2.2.1 Complexity of Proof Procedures
2.2.2 Computations on Discrete Structures
2.2.3 Geometrical Problems
2.2.4 Pattern Matching
2.2.5 Routing and Layout
2.2.6 Sequencing and Scheduling
2.2.7 Sorting and Searching

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
G. Mathematics of Computing
1.
2.
3.
4.

Numerical Analysis
Discrete Mathematics
Probability and Statistics
Mathematical Software

ACM Computing Classification System
G. Mathematics of Computing
2. Discrete Mathematics
2.1 Combinatorics

2.1.1 Combinatorial Algorithms
2.1.2 Counting Problems
2.1.3 Generating Functions
2.1.4 Permutations and Combinations
2.1.5 Recurrences and Difference Equations

2.2 Graph Theory
2.2.1 Graph Algorithms
2.2.2 Graph Labeling

2.2.5 Path and Circuit Problems
2.2.6 Trees

2.3 Applications

a world FULL of NP-hard problems
Problem: I want to travel among a set of
cities driving the fewest possible number
of KMs. IT’S DIFFICULT!!

Problem: I want to put a set of objects
into some bags, knowing that each bag
can not afford more than 10 KGs and
trying to use as few bags as possible.
IT’S DIFFICULT!!

How to Deal with NP-hard problems?
• Exact Algorithms
• Randomized Algorithms
• Approximation Algorithms
• Fixed-Parameter Tractable Algorithms
• …

Approximation Algorithms

Approximation Algorithms
• We want a solution “close” to the
optimal one.
• Given a minimization problem Π, an
algorithm is an α-approximation for Π if,
for every instance I of Π, it outputs a
solution SOL(I) such that
SOL(I)/OPT(I) ≤ α

Vertex Cover
• Problem: Given a graph G(V,E), find a
minimum vertex cover, that is, a set V’  V
such that every edge e  E has an
endvertex in V’.

NP-hard 
[Karp]

How to Guarantee an Approximation?
• We want an approximation algorithm
for Vertex Cover.
• The cost of the solution produced by the
algorithm should be compared with the
cost of an optimal solution.

• But computing the cost of an optimal
solution is NP-HARD!!
LOWER BOUNDS!

Lower Bound for Vertex Cover
• Given a graph G(V,E), a matching M is
a set of edges M  E such that no two
edges share an endvertex.
• A matching is maximal if no matching M’
exists such that M  M’.

• The size of a matching
is a lower bound on the
size of an optimal
solution to Vertex
Cover!

An Approximation Algorithm
for Vertex Cover

• Algorithm: Find a maximal matching M
and output the set S of matched vertices

An Approximation Algorithm
for Vertex Cover
• Theorem: The previous algorithm is a
2-approximation algorithm for Vertex Cover
• Proof:
• S is a vertex cover, otherwhise the
matching would not be maximal.
• OPT≥M, where M is the size of the output
maximal matching.
• SOL=2M, as the number of matched
vertices is twice the size of the matching.

Approximation Algorithms:much more…
• Approximation schemes: (1+ε)-approx.
• Inapproximability results.
• Complexity classes, e.g., APX.

Fixed-Parameter Tractable Algorithms

Easy or Hard?
Problem (optimization): Let G be a graph.
Which is the minimum number of vertices
whose deletion makes G planar?

NP-hard 
[Lewis-Yannakakis ]

Easy or Hard?
Problem (decision): Let G be a graph and k
be an integer. Is there a set of k vertices
whose deletion makes G planar?
Polynomial 
• Easy O(nk+1) time algorithm for solving the problem:
• Consider every set of k vertices. Remove such
vertices. Test the planarity of the resulting graph.

• There are O(nk) such sets. Testing the planarity of
an n-vertex graph takes O(n) time. Then,
T(n,k)= O(nk) O(n) = O(nk+1)

Easy or Hard?
Where is the trick?
In the decision version, k is a constant
parameter part of the input
An O(nk+1)-time algorithm, with k constant, is a
polynomial-time algorithm.

But it is very slow 

Fixed-Parameter Tractability
A problem is fixed-parameter tractable
if it can be solved in f(k) nO(1) time,
where k is a parameter of the problem,
f is an arbitrary function, and nO(1) is a
polynomial (not depending on k).

FPT algorithm for Vertex Cover
Theorem [Melhorn]: There is an O(2k n)time algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• There is a vertex cover with k=0 if and only if G
has no edge.
• Consider any edge e=(u,v). Either u or v belongs
to any vertex cover S.
• Consider both the case in which u S and the
case in which v S.

FPT algorithm for Vertex Cover
u

u

v

v

• u  S -> S is a vertex cover of G if and only if
S-{u} is a vertex cover of G-{u} -> solve the
instance (G-{u}, k-1)
• v  S -> S is a vertex cover of G if and only if
S-{v} is a vertex cover of G-{v} -> solve the
instance (G-{v}, k-1)

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• T(n,0) = O(n)
• T(n,k) = 2 T(n-1, k-1) +O(n) ≤ 2 T(n, k-1) +O(n) ≤
2 (2 T(n, k-2) +O(n)) +O(n) ≤
2 (2 (2 T(n, k-3) +O(n)) +O(n)) +O(n) ≤
2 (2 (2 (…(2 T(n, 0)+O(n)) + … +O(n))
+O(n)) +O(n) ≤
2k O(n) + (2k-1 + 2k-2 + 2k-3 + ... + 1) O(n) =
2k O(n) + (2k - 1) O(n) = O(2k n)

Reduction Rules
Reduction rule : a rule (that is, a polynomial time
algorithm) that transforms an instance (I,k) to
an "equivalent and simpler” instance (I', k’).

Equivalent: (I,k) is a YES instance if and only if
(I', k') is a YES instance.
Simpler: |I'|<|I| or k'occurrences of a particular substructure.

Another FPT algorithm for Vertex Cover
Theorem: There is an O(1.6181k n2)-time
algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• We apply the following two reduction rules:
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k).
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u,N(u)},k-1).

Another FPT algorithm for Vertex Cover
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k). Correctness: if S is a vertex
cover of G and u is in S, then S-{u} is also a
vertex cover of G, as u has no incident edge.
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u, N(u)},k-1). Correctness: if S is a
vertex cover of G and u is in S, then
S-{u}  N(u) is also a vertex cover of G, as u
has no other incident edge.

Another FPT algorithm for Vertex Cover
• If neither of the two rules can be applied,
then every vertex has degree at least 2.
• Pick a vertex u. Any vertex cover of G
contains either u or N(u). Thus, (G,k) is a YES
instance if and only if (G-{u},k-1) or
(G-N(u),k-|N(u)|) is.

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• Since |N(u)|\geq 2,
• T(n,k) ≤ T(n,k-1)+ T(n,k-2)+O(n^2).
• Fibonacci series: every number is the sum of
the previous two xk =xk-1 +xk-2 +c.

• The k-th number of the Fibonacci series
tends to the golden ratio to the power of k.
• T(n,k)=Φk O(n2)=((1+√5)/2)k O(n2) =
O(1.6181k n2).

Kernelization
• Sometimes the reduction rules work till the size
of the problem is reduced really a lot. That is,
after the reduction rules have been applied,
the problem has size g(k), for some function k.
In this case the problem has a g(k)-kernel.

• Kernel: given a problem and an instance (I,k), a
kernel is an algorithm that outputs in polynomial
time an instance (I',k') such that (a) (I',k') is a
YES instance if and only if (I,k) is; (b) |I'|and k'
Kernelization
• Theorem [Niedermaier]: Every fixed-parameter
tractable problem has a g(k)-kernel.
• Proof: Suppose that there exists a FPT
algorithm with running time f(k) nc, for some
function f and some constant c. Consider an
instance (I,k) with |I|=n.
• If n>f(k), we run the decision algorithm in time
f(k) nc < nc+1. If it returns YES (NO), the
kernelization algorithm outputs a constant size
YES (resp. NO) instance.
• If n≤f(k), the the kernelization algorithm
returns (I,k).

Kernelization
• The last theorem implies that every problem
that is FPT has a kernel.
• However, the goal is to obtain kernels that are
"small", that is, polynomial in k, or even constant.

FPT: much more…
• Some problems are not FPT (e.g., graph coloring).
• Complexity classes: W[1] -> Can a nondeterministic Turing machine accept an unary
string s in at most k steps?
• Independent Set is W[1]-hard.
• Reductions to W[1]-hard problems give new
W[1]-hard problems.
• Lower bounds for FPT tractability
• Upper and lower bounds for the size of the
kernels

FPT: much more…
• Theorem [Robertson and Seymour]: Every graph
problem with parameter k whose YES istances
are closed under taking minors can be solved in
O(f(k) n3)


Slide 3

Tecniche Algoritmiche per Grafi e Reti
Fabrizio Frati

Dipartimento di Informatica e Automazione
Università degli Studi Roma Tre

• 3 CREDITI
• I° periodo:
• Lunedì 9:45-11:15 aula N13

• II° periodo:
• Venerdì 8:00-9:45 aula N7

• Contatti:
• {angelini,gdb,frati,ratm} @dia.uniroma3.it
• Ricevimento: mercoledì dalle 17 alle 19

• Struttura del Corso
• ~ 8 seminari
• algoritmi, strutture dati, combinatorica,
graph drawing…

• progetti a gruppi di 2 - 4 persone
• problema di ricerca

• Materiale Didattico
• slides
• G. Di Battista, P. Eades, R. Tamassia, I. G.
Tollis, Graph Drawing: Algorithms for the
Visualization of Graphs, 1999. Prentice Hall.

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
C. Computer System Organization
1.
2.
3.
4.
5.

Processor Architectures
Computer-Communication Networks
Application-Based Systems
Performance of Systems
Computer System Implementations

ACM Computing Classification System
C. Computer System Organization
2. Computer-Communication Networks
2.1 Network Architectures
2.2 Network Protocols
2.3 Network Operations
2.4 Distributed Systems
2.5 LAN & WAN
2.6 Internetworking

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
E. Data
1.
2.
3.
4.
5.

Data Structures
Data Storage Representations
Data Encryption
Coding and Information Theory
Files

ACM Computing Classification System
E. Data
1. Data Structures
1.1 Arrays
1.2 Distributed Data Structures
1.3 Graphs and Networks
1.4 Lists, Stacks, and Queues
1.5 Records
1.6 Tables
1.7 Trees

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
F. Theory of Computation
1.
2.
3.
4.

Computation by Abstract Devices
Analysis of Algorithms and Problem Complexity
Logics and Meanings of Programs
Mathematical Logic and Formal Languages

ACM Computing Classification System
F. Theory of Computation
1. Computation by Abstract Devices
1.1 Models of Computation
1.2 Complexity Measures and Completeness
1.2.1 Complexity Hierarchies
1.2.2 Machine-Independent Complexity
1.2.3 Reducibility and Completeness
1.2.4 Relations among Complexity Classes

ACM Computing Classification System
F. Theory of Computation
2. Analysis of Algorithms and Problem Complexity
2.1 Numerical Algorithms
2.2 Non-numerical Algorithms and Problems
2.2.1 Complexity of Proof Procedures
2.2.2 Computations on Discrete Structures
2.2.3 Geometrical Problems
2.2.4 Pattern Matching
2.2.5 Routing and Layout
2.2.6 Sequencing and Scheduling
2.2.7 Sorting and Searching

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
G. Mathematics of Computing
1.
2.
3.
4.

Numerical Analysis
Discrete Mathematics
Probability and Statistics
Mathematical Software

ACM Computing Classification System
G. Mathematics of Computing
2. Discrete Mathematics
2.1 Combinatorics

2.1.1 Combinatorial Algorithms
2.1.2 Counting Problems
2.1.3 Generating Functions
2.1.4 Permutations and Combinations
2.1.5 Recurrences and Difference Equations

2.2 Graph Theory
2.2.1 Graph Algorithms
2.2.2 Graph Labeling

2.2.5 Path and Circuit Problems
2.2.6 Trees

2.3 Applications

a world FULL of NP-hard problems
Problem: I want to travel among a set of
cities driving the fewest possible number
of KMs. IT’S DIFFICULT!!

Problem: I want to put a set of objects
into some bags, knowing that each bag
can not afford more than 10 KGs and
trying to use as few bags as possible.
IT’S DIFFICULT!!

How to Deal with NP-hard problems?
• Exact Algorithms
• Randomized Algorithms
• Approximation Algorithms
• Fixed-Parameter Tractable Algorithms
• …

Approximation Algorithms

Approximation Algorithms
• We want a solution “close” to the
optimal one.
• Given a minimization problem Π, an
algorithm is an α-approximation for Π if,
for every instance I of Π, it outputs a
solution SOL(I) such that
SOL(I)/OPT(I) ≤ α

Vertex Cover
• Problem: Given a graph G(V,E), find a
minimum vertex cover, that is, a set V’  V
such that every edge e  E has an
endvertex in V’.

NP-hard 
[Karp]

How to Guarantee an Approximation?
• We want an approximation algorithm
for Vertex Cover.
• The cost of the solution produced by the
algorithm should be compared with the
cost of an optimal solution.

• But computing the cost of an optimal
solution is NP-HARD!!
LOWER BOUNDS!

Lower Bound for Vertex Cover
• Given a graph G(V,E), a matching M is
a set of edges M  E such that no two
edges share an endvertex.
• A matching is maximal if no matching M’
exists such that M  M’.

• The size of a matching
is a lower bound on the
size of an optimal
solution to Vertex
Cover!

An Approximation Algorithm
for Vertex Cover

• Algorithm: Find a maximal matching M
and output the set S of matched vertices

An Approximation Algorithm
for Vertex Cover
• Theorem: The previous algorithm is a
2-approximation algorithm for Vertex Cover
• Proof:
• S is a vertex cover, otherwhise the
matching would not be maximal.
• OPT≥M, where M is the size of the output
maximal matching.
• SOL=2M, as the number of matched
vertices is twice the size of the matching.

Approximation Algorithms:much more…
• Approximation schemes: (1+ε)-approx.
• Inapproximability results.
• Complexity classes, e.g., APX.

Fixed-Parameter Tractable Algorithms

Easy or Hard?
Problem (optimization): Let G be a graph.
Which is the minimum number of vertices
whose deletion makes G planar?

NP-hard 
[Lewis-Yannakakis ]

Easy or Hard?
Problem (decision): Let G be a graph and k
be an integer. Is there a set of k vertices
whose deletion makes G planar?
Polynomial 
• Easy O(nk+1) time algorithm for solving the problem:
• Consider every set of k vertices. Remove such
vertices. Test the planarity of the resulting graph.

• There are O(nk) such sets. Testing the planarity of
an n-vertex graph takes O(n) time. Then,
T(n,k)= O(nk) O(n) = O(nk+1)

Easy or Hard?
Where is the trick?
In the decision version, k is a constant
parameter part of the input
An O(nk+1)-time algorithm, with k constant, is a
polynomial-time algorithm.

But it is very slow 

Fixed-Parameter Tractability
A problem is fixed-parameter tractable
if it can be solved in f(k) nO(1) time,
where k is a parameter of the problem,
f is an arbitrary function, and nO(1) is a
polynomial (not depending on k).

FPT algorithm for Vertex Cover
Theorem [Melhorn]: There is an O(2k n)time algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• There is a vertex cover with k=0 if and only if G
has no edge.
• Consider any edge e=(u,v). Either u or v belongs
to any vertex cover S.
• Consider both the case in which u S and the
case in which v S.

FPT algorithm for Vertex Cover
u

u

v

v

• u  S -> S is a vertex cover of G if and only if
S-{u} is a vertex cover of G-{u} -> solve the
instance (G-{u}, k-1)
• v  S -> S is a vertex cover of G if and only if
S-{v} is a vertex cover of G-{v} -> solve the
instance (G-{v}, k-1)

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• T(n,0) = O(n)
• T(n,k) = 2 T(n-1, k-1) +O(n) ≤ 2 T(n, k-1) +O(n) ≤
2 (2 T(n, k-2) +O(n)) +O(n) ≤
2 (2 (2 T(n, k-3) +O(n)) +O(n)) +O(n) ≤
2 (2 (2 (…(2 T(n, 0)+O(n)) + … +O(n))
+O(n)) +O(n) ≤
2k O(n) + (2k-1 + 2k-2 + 2k-3 + ... + 1) O(n) =
2k O(n) + (2k - 1) O(n) = O(2k n)

Reduction Rules
Reduction rule : a rule (that is, a polynomial time
algorithm) that transforms an instance (I,k) to
an "equivalent and simpler” instance (I', k’).

Equivalent: (I,k) is a YES instance if and only if
(I', k') is a YES instance.
Simpler: |I'|<|I| or k'occurrences of a particular substructure.

Another FPT algorithm for Vertex Cover
Theorem: There is an O(1.6181k n2)-time
algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• We apply the following two reduction rules:
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k).
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u,N(u)},k-1).

Another FPT algorithm for Vertex Cover
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k). Correctness: if S is a vertex
cover of G and u is in S, then S-{u} is also a
vertex cover of G, as u has no incident edge.
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u, N(u)},k-1). Correctness: if S is a
vertex cover of G and u is in S, then
S-{u}  N(u) is also a vertex cover of G, as u
has no other incident edge.

Another FPT algorithm for Vertex Cover
• If neither of the two rules can be applied,
then every vertex has degree at least 2.
• Pick a vertex u. Any vertex cover of G
contains either u or N(u). Thus, (G,k) is a YES
instance if and only if (G-{u},k-1) or
(G-N(u),k-|N(u)|) is.

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• Since |N(u)|\geq 2,
• T(n,k) ≤ T(n,k-1)+ T(n,k-2)+O(n^2).
• Fibonacci series: every number is the sum of
the previous two xk =xk-1 +xk-2 +c.

• The k-th number of the Fibonacci series
tends to the golden ratio to the power of k.
• T(n,k)=Φk O(n2)=((1+√5)/2)k O(n2) =
O(1.6181k n2).

Kernelization
• Sometimes the reduction rules work till the size
of the problem is reduced really a lot. That is,
after the reduction rules have been applied,
the problem has size g(k), for some function k.
In this case the problem has a g(k)-kernel.

• Kernel: given a problem and an instance (I,k), a
kernel is an algorithm that outputs in polynomial
time an instance (I',k') such that (a) (I',k') is a
YES instance if and only if (I,k) is; (b) |I'|and k'
Kernelization
• Theorem [Niedermaier]: Every fixed-parameter
tractable problem has a g(k)-kernel.
• Proof: Suppose that there exists a FPT
algorithm with running time f(k) nc, for some
function f and some constant c. Consider an
instance (I,k) with |I|=n.
• If n>f(k), we run the decision algorithm in time
f(k) nc < nc+1. If it returns YES (NO), the
kernelization algorithm outputs a constant size
YES (resp. NO) instance.
• If n≤f(k), the the kernelization algorithm
returns (I,k).

Kernelization
• The last theorem implies that every problem
that is FPT has a kernel.
• However, the goal is to obtain kernels that are
"small", that is, polynomial in k, or even constant.

FPT: much more…
• Some problems are not FPT (e.g., graph coloring).
• Complexity classes: W[1] -> Can a nondeterministic Turing machine accept an unary
string s in at most k steps?
• Independent Set is W[1]-hard.
• Reductions to W[1]-hard problems give new
W[1]-hard problems.
• Lower bounds for FPT tractability
• Upper and lower bounds for the size of the
kernels

FPT: much more…
• Theorem [Robertson and Seymour]: Every graph
problem with parameter k whose YES istances
are closed under taking minors can be solved in
O(f(k) n3)


Slide 4

Tecniche Algoritmiche per Grafi e Reti
Fabrizio Frati

Dipartimento di Informatica e Automazione
Università degli Studi Roma Tre

• 3 CREDITI
• I° periodo:
• Lunedì 9:45-11:15 aula N13

• II° periodo:
• Venerdì 8:00-9:45 aula N7

• Contatti:
• {angelini,gdb,frati,ratm} @dia.uniroma3.it
• Ricevimento: mercoledì dalle 17 alle 19

• Struttura del Corso
• ~ 8 seminari
• algoritmi, strutture dati, combinatorica,
graph drawing…

• progetti a gruppi di 2 - 4 persone
• problema di ricerca

• Materiale Didattico
• slides
• G. Di Battista, P. Eades, R. Tamassia, I. G.
Tollis, Graph Drawing: Algorithms for the
Visualization of Graphs, 1999. Prentice Hall.

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
C. Computer System Organization
1.
2.
3.
4.
5.

Processor Architectures
Computer-Communication Networks
Application-Based Systems
Performance of Systems
Computer System Implementations

ACM Computing Classification System
C. Computer System Organization
2. Computer-Communication Networks
2.1 Network Architectures
2.2 Network Protocols
2.3 Network Operations
2.4 Distributed Systems
2.5 LAN & WAN
2.6 Internetworking

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
E. Data
1.
2.
3.
4.
5.

Data Structures
Data Storage Representations
Data Encryption
Coding and Information Theory
Files

ACM Computing Classification System
E. Data
1. Data Structures
1.1 Arrays
1.2 Distributed Data Structures
1.3 Graphs and Networks
1.4 Lists, Stacks, and Queues
1.5 Records
1.6 Tables
1.7 Trees

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
F. Theory of Computation
1.
2.
3.
4.

Computation by Abstract Devices
Analysis of Algorithms and Problem Complexity
Logics and Meanings of Programs
Mathematical Logic and Formal Languages

ACM Computing Classification System
F. Theory of Computation
1. Computation by Abstract Devices
1.1 Models of Computation
1.2 Complexity Measures and Completeness
1.2.1 Complexity Hierarchies
1.2.2 Machine-Independent Complexity
1.2.3 Reducibility and Completeness
1.2.4 Relations among Complexity Classes

ACM Computing Classification System
F. Theory of Computation
2. Analysis of Algorithms and Problem Complexity
2.1 Numerical Algorithms
2.2 Non-numerical Algorithms and Problems
2.2.1 Complexity of Proof Procedures
2.2.2 Computations on Discrete Structures
2.2.3 Geometrical Problems
2.2.4 Pattern Matching
2.2.5 Routing and Layout
2.2.6 Sequencing and Scheduling
2.2.7 Sorting and Searching

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
G. Mathematics of Computing
1.
2.
3.
4.

Numerical Analysis
Discrete Mathematics
Probability and Statistics
Mathematical Software

ACM Computing Classification System
G. Mathematics of Computing
2. Discrete Mathematics
2.1 Combinatorics

2.1.1 Combinatorial Algorithms
2.1.2 Counting Problems
2.1.3 Generating Functions
2.1.4 Permutations and Combinations
2.1.5 Recurrences and Difference Equations

2.2 Graph Theory
2.2.1 Graph Algorithms
2.2.2 Graph Labeling

2.2.5 Path and Circuit Problems
2.2.6 Trees

2.3 Applications

a world FULL of NP-hard problems
Problem: I want to travel among a set of
cities driving the fewest possible number
of KMs. IT’S DIFFICULT!!

Problem: I want to put a set of objects
into some bags, knowing that each bag
can not afford more than 10 KGs and
trying to use as few bags as possible.
IT’S DIFFICULT!!

How to Deal with NP-hard problems?
• Exact Algorithms
• Randomized Algorithms
• Approximation Algorithms
• Fixed-Parameter Tractable Algorithms
• …

Approximation Algorithms

Approximation Algorithms
• We want a solution “close” to the
optimal one.
• Given a minimization problem Π, an
algorithm is an α-approximation for Π if,
for every instance I of Π, it outputs a
solution SOL(I) such that
SOL(I)/OPT(I) ≤ α

Vertex Cover
• Problem: Given a graph G(V,E), find a
minimum vertex cover, that is, a set V’  V
such that every edge e  E has an
endvertex in V’.

NP-hard 
[Karp]

How to Guarantee an Approximation?
• We want an approximation algorithm
for Vertex Cover.
• The cost of the solution produced by the
algorithm should be compared with the
cost of an optimal solution.

• But computing the cost of an optimal
solution is NP-HARD!!
LOWER BOUNDS!

Lower Bound for Vertex Cover
• Given a graph G(V,E), a matching M is
a set of edges M  E such that no two
edges share an endvertex.
• A matching is maximal if no matching M’
exists such that M  M’.

• The size of a matching
is a lower bound on the
size of an optimal
solution to Vertex
Cover!

An Approximation Algorithm
for Vertex Cover

• Algorithm: Find a maximal matching M
and output the set S of matched vertices

An Approximation Algorithm
for Vertex Cover
• Theorem: The previous algorithm is a
2-approximation algorithm for Vertex Cover
• Proof:
• S is a vertex cover, otherwhise the
matching would not be maximal.
• OPT≥M, where M is the size of the output
maximal matching.
• SOL=2M, as the number of matched
vertices is twice the size of the matching.

Approximation Algorithms:much more…
• Approximation schemes: (1+ε)-approx.
• Inapproximability results.
• Complexity classes, e.g., APX.

Fixed-Parameter Tractable Algorithms

Easy or Hard?
Problem (optimization): Let G be a graph.
Which is the minimum number of vertices
whose deletion makes G planar?

NP-hard 
[Lewis-Yannakakis ]

Easy or Hard?
Problem (decision): Let G be a graph and k
be an integer. Is there a set of k vertices
whose deletion makes G planar?
Polynomial 
• Easy O(nk+1) time algorithm for solving the problem:
• Consider every set of k vertices. Remove such
vertices. Test the planarity of the resulting graph.

• There are O(nk) such sets. Testing the planarity of
an n-vertex graph takes O(n) time. Then,
T(n,k)= O(nk) O(n) = O(nk+1)

Easy or Hard?
Where is the trick?
In the decision version, k is a constant
parameter part of the input
An O(nk+1)-time algorithm, with k constant, is a
polynomial-time algorithm.

But it is very slow 

Fixed-Parameter Tractability
A problem is fixed-parameter tractable
if it can be solved in f(k) nO(1) time,
where k is a parameter of the problem,
f is an arbitrary function, and nO(1) is a
polynomial (not depending on k).

FPT algorithm for Vertex Cover
Theorem [Melhorn]: There is an O(2k n)time algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• There is a vertex cover with k=0 if and only if G
has no edge.
• Consider any edge e=(u,v). Either u or v belongs
to any vertex cover S.
• Consider both the case in which u S and the
case in which v S.

FPT algorithm for Vertex Cover
u

u

v

v

• u  S -> S is a vertex cover of G if and only if
S-{u} is a vertex cover of G-{u} -> solve the
instance (G-{u}, k-1)
• v  S -> S is a vertex cover of G if and only if
S-{v} is a vertex cover of G-{v} -> solve the
instance (G-{v}, k-1)

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• T(n,0) = O(n)
• T(n,k) = 2 T(n-1, k-1) +O(n) ≤ 2 T(n, k-1) +O(n) ≤
2 (2 T(n, k-2) +O(n)) +O(n) ≤
2 (2 (2 T(n, k-3) +O(n)) +O(n)) +O(n) ≤
2 (2 (2 (…(2 T(n, 0)+O(n)) + … +O(n))
+O(n)) +O(n) ≤
2k O(n) + (2k-1 + 2k-2 + 2k-3 + ... + 1) O(n) =
2k O(n) + (2k - 1) O(n) = O(2k n)

Reduction Rules
Reduction rule : a rule (that is, a polynomial time
algorithm) that transforms an instance (I,k) to
an "equivalent and simpler” instance (I', k’).

Equivalent: (I,k) is a YES instance if and only if
(I', k') is a YES instance.
Simpler: |I'|<|I| or k'occurrences of a particular substructure.

Another FPT algorithm for Vertex Cover
Theorem: There is an O(1.6181k n2)-time
algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• We apply the following two reduction rules:
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k).
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u,N(u)},k-1).

Another FPT algorithm for Vertex Cover
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k). Correctness: if S is a vertex
cover of G and u is in S, then S-{u} is also a
vertex cover of G, as u has no incident edge.
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u, N(u)},k-1). Correctness: if S is a
vertex cover of G and u is in S, then
S-{u}  N(u) is also a vertex cover of G, as u
has no other incident edge.

Another FPT algorithm for Vertex Cover
• If neither of the two rules can be applied,
then every vertex has degree at least 2.
• Pick a vertex u. Any vertex cover of G
contains either u or N(u). Thus, (G,k) is a YES
instance if and only if (G-{u},k-1) or
(G-N(u),k-|N(u)|) is.

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• Since |N(u)|\geq 2,
• T(n,k) ≤ T(n,k-1)+ T(n,k-2)+O(n^2).
• Fibonacci series: every number is the sum of
the previous two xk =xk-1 +xk-2 +c.

• The k-th number of the Fibonacci series
tends to the golden ratio to the power of k.
• T(n,k)=Φk O(n2)=((1+√5)/2)k O(n2) =
O(1.6181k n2).

Kernelization
• Sometimes the reduction rules work till the size
of the problem is reduced really a lot. That is,
after the reduction rules have been applied,
the problem has size g(k), for some function k.
In this case the problem has a g(k)-kernel.

• Kernel: given a problem and an instance (I,k), a
kernel is an algorithm that outputs in polynomial
time an instance (I',k') such that (a) (I',k') is a
YES instance if and only if (I,k) is; (b) |I'|and k'
Kernelization
• Theorem [Niedermaier]: Every fixed-parameter
tractable problem has a g(k)-kernel.
• Proof: Suppose that there exists a FPT
algorithm with running time f(k) nc, for some
function f and some constant c. Consider an
instance (I,k) with |I|=n.
• If n>f(k), we run the decision algorithm in time
f(k) nc < nc+1. If it returns YES (NO), the
kernelization algorithm outputs a constant size
YES (resp. NO) instance.
• If n≤f(k), the the kernelization algorithm
returns (I,k).

Kernelization
• The last theorem implies that every problem
that is FPT has a kernel.
• However, the goal is to obtain kernels that are
"small", that is, polynomial in k, or even constant.

FPT: much more…
• Some problems are not FPT (e.g., graph coloring).
• Complexity classes: W[1] -> Can a nondeterministic Turing machine accept an unary
string s in at most k steps?
• Independent Set is W[1]-hard.
• Reductions to W[1]-hard problems give new
W[1]-hard problems.
• Lower bounds for FPT tractability
• Upper and lower bounds for the size of the
kernels

FPT: much more…
• Theorem [Robertson and Seymour]: Every graph
problem with parameter k whose YES istances
are closed under taking minors can be solved in
O(f(k) n3)


Slide 5

Tecniche Algoritmiche per Grafi e Reti
Fabrizio Frati

Dipartimento di Informatica e Automazione
Università degli Studi Roma Tre

• 3 CREDITI
• I° periodo:
• Lunedì 9:45-11:15 aula N13

• II° periodo:
• Venerdì 8:00-9:45 aula N7

• Contatti:
• {angelini,gdb,frati,ratm} @dia.uniroma3.it
• Ricevimento: mercoledì dalle 17 alle 19

• Struttura del Corso
• ~ 8 seminari
• algoritmi, strutture dati, combinatorica,
graph drawing…

• progetti a gruppi di 2 - 4 persone
• problema di ricerca

• Materiale Didattico
• slides
• G. Di Battista, P. Eades, R. Tamassia, I. G.
Tollis, Graph Drawing: Algorithms for the
Visualization of Graphs, 1999. Prentice Hall.

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
C. Computer System Organization
1.
2.
3.
4.
5.

Processor Architectures
Computer-Communication Networks
Application-Based Systems
Performance of Systems
Computer System Implementations

ACM Computing Classification System
C. Computer System Organization
2. Computer-Communication Networks
2.1 Network Architectures
2.2 Network Protocols
2.3 Network Operations
2.4 Distributed Systems
2.5 LAN & WAN
2.6 Internetworking

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
E. Data
1.
2.
3.
4.
5.

Data Structures
Data Storage Representations
Data Encryption
Coding and Information Theory
Files

ACM Computing Classification System
E. Data
1. Data Structures
1.1 Arrays
1.2 Distributed Data Structures
1.3 Graphs and Networks
1.4 Lists, Stacks, and Queues
1.5 Records
1.6 Tables
1.7 Trees

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
F. Theory of Computation
1.
2.
3.
4.

Computation by Abstract Devices
Analysis of Algorithms and Problem Complexity
Logics and Meanings of Programs
Mathematical Logic and Formal Languages

ACM Computing Classification System
F. Theory of Computation
1. Computation by Abstract Devices
1.1 Models of Computation
1.2 Complexity Measures and Completeness
1.2.1 Complexity Hierarchies
1.2.2 Machine-Independent Complexity
1.2.3 Reducibility and Completeness
1.2.4 Relations among Complexity Classes

ACM Computing Classification System
F. Theory of Computation
2. Analysis of Algorithms and Problem Complexity
2.1 Numerical Algorithms
2.2 Non-numerical Algorithms and Problems
2.2.1 Complexity of Proof Procedures
2.2.2 Computations on Discrete Structures
2.2.3 Geometrical Problems
2.2.4 Pattern Matching
2.2.5 Routing and Layout
2.2.6 Sequencing and Scheduling
2.2.7 Sorting and Searching

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
G. Mathematics of Computing
1.
2.
3.
4.

Numerical Analysis
Discrete Mathematics
Probability and Statistics
Mathematical Software

ACM Computing Classification System
G. Mathematics of Computing
2. Discrete Mathematics
2.1 Combinatorics

2.1.1 Combinatorial Algorithms
2.1.2 Counting Problems
2.1.3 Generating Functions
2.1.4 Permutations and Combinations
2.1.5 Recurrences and Difference Equations

2.2 Graph Theory
2.2.1 Graph Algorithms
2.2.2 Graph Labeling

2.2.5 Path and Circuit Problems
2.2.6 Trees

2.3 Applications

a world FULL of NP-hard problems
Problem: I want to travel among a set of
cities driving the fewest possible number
of KMs. IT’S DIFFICULT!!

Problem: I want to put a set of objects
into some bags, knowing that each bag
can not afford more than 10 KGs and
trying to use as few bags as possible.
IT’S DIFFICULT!!

How to Deal with NP-hard problems?
• Exact Algorithms
• Randomized Algorithms
• Approximation Algorithms
• Fixed-Parameter Tractable Algorithms
• …

Approximation Algorithms

Approximation Algorithms
• We want a solution “close” to the
optimal one.
• Given a minimization problem Π, an
algorithm is an α-approximation for Π if,
for every instance I of Π, it outputs a
solution SOL(I) such that
SOL(I)/OPT(I) ≤ α

Vertex Cover
• Problem: Given a graph G(V,E), find a
minimum vertex cover, that is, a set V’  V
such that every edge e  E has an
endvertex in V’.

NP-hard 
[Karp]

How to Guarantee an Approximation?
• We want an approximation algorithm
for Vertex Cover.
• The cost of the solution produced by the
algorithm should be compared with the
cost of an optimal solution.

• But computing the cost of an optimal
solution is NP-HARD!!
LOWER BOUNDS!

Lower Bound for Vertex Cover
• Given a graph G(V,E), a matching M is
a set of edges M  E such that no two
edges share an endvertex.
• A matching is maximal if no matching M’
exists such that M  M’.

• The size of a matching
is a lower bound on the
size of an optimal
solution to Vertex
Cover!

An Approximation Algorithm
for Vertex Cover

• Algorithm: Find a maximal matching M
and output the set S of matched vertices

An Approximation Algorithm
for Vertex Cover
• Theorem: The previous algorithm is a
2-approximation algorithm for Vertex Cover
• Proof:
• S is a vertex cover, otherwhise the
matching would not be maximal.
• OPT≥M, where M is the size of the output
maximal matching.
• SOL=2M, as the number of matched
vertices is twice the size of the matching.

Approximation Algorithms:much more…
• Approximation schemes: (1+ε)-approx.
• Inapproximability results.
• Complexity classes, e.g., APX.

Fixed-Parameter Tractable Algorithms

Easy or Hard?
Problem (optimization): Let G be a graph.
Which is the minimum number of vertices
whose deletion makes G planar?

NP-hard 
[Lewis-Yannakakis ]

Easy or Hard?
Problem (decision): Let G be a graph and k
be an integer. Is there a set of k vertices
whose deletion makes G planar?
Polynomial 
• Easy O(nk+1) time algorithm for solving the problem:
• Consider every set of k vertices. Remove such
vertices. Test the planarity of the resulting graph.

• There are O(nk) such sets. Testing the planarity of
an n-vertex graph takes O(n) time. Then,
T(n,k)= O(nk) O(n) = O(nk+1)

Easy or Hard?
Where is the trick?
In the decision version, k is a constant
parameter part of the input
An O(nk+1)-time algorithm, with k constant, is a
polynomial-time algorithm.

But it is very slow 

Fixed-Parameter Tractability
A problem is fixed-parameter tractable
if it can be solved in f(k) nO(1) time,
where k is a parameter of the problem,
f is an arbitrary function, and nO(1) is a
polynomial (not depending on k).

FPT algorithm for Vertex Cover
Theorem [Melhorn]: There is an O(2k n)time algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• There is a vertex cover with k=0 if and only if G
has no edge.
• Consider any edge e=(u,v). Either u or v belongs
to any vertex cover S.
• Consider both the case in which u S and the
case in which v S.

FPT algorithm for Vertex Cover
u

u

v

v

• u  S -> S is a vertex cover of G if and only if
S-{u} is a vertex cover of G-{u} -> solve the
instance (G-{u}, k-1)
• v  S -> S is a vertex cover of G if and only if
S-{v} is a vertex cover of G-{v} -> solve the
instance (G-{v}, k-1)

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• T(n,0) = O(n)
• T(n,k) = 2 T(n-1, k-1) +O(n) ≤ 2 T(n, k-1) +O(n) ≤
2 (2 T(n, k-2) +O(n)) +O(n) ≤
2 (2 (2 T(n, k-3) +O(n)) +O(n)) +O(n) ≤
2 (2 (2 (…(2 T(n, 0)+O(n)) + … +O(n))
+O(n)) +O(n) ≤
2k O(n) + (2k-1 + 2k-2 + 2k-3 + ... + 1) O(n) =
2k O(n) + (2k - 1) O(n) = O(2k n)

Reduction Rules
Reduction rule : a rule (that is, a polynomial time
algorithm) that transforms an instance (I,k) to
an "equivalent and simpler” instance (I', k’).

Equivalent: (I,k) is a YES instance if and only if
(I', k') is a YES instance.
Simpler: |I'|<|I| or k'occurrences of a particular substructure.

Another FPT algorithm for Vertex Cover
Theorem: There is an O(1.6181k n2)-time
algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• We apply the following two reduction rules:
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k).
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u,N(u)},k-1).

Another FPT algorithm for Vertex Cover
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k). Correctness: if S is a vertex
cover of G and u is in S, then S-{u} is also a
vertex cover of G, as u has no incident edge.
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u, N(u)},k-1). Correctness: if S is a
vertex cover of G and u is in S, then
S-{u}  N(u) is also a vertex cover of G, as u
has no other incident edge.

Another FPT algorithm for Vertex Cover
• If neither of the two rules can be applied,
then every vertex has degree at least 2.
• Pick a vertex u. Any vertex cover of G
contains either u or N(u). Thus, (G,k) is a YES
instance if and only if (G-{u},k-1) or
(G-N(u),k-|N(u)|) is.

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• Since |N(u)|\geq 2,
• T(n,k) ≤ T(n,k-1)+ T(n,k-2)+O(n^2).
• Fibonacci series: every number is the sum of
the previous two xk =xk-1 +xk-2 +c.

• The k-th number of the Fibonacci series
tends to the golden ratio to the power of k.
• T(n,k)=Φk O(n2)=((1+√5)/2)k O(n2) =
O(1.6181k n2).

Kernelization
• Sometimes the reduction rules work till the size
of the problem is reduced really a lot. That is,
after the reduction rules have been applied,
the problem has size g(k), for some function k.
In this case the problem has a g(k)-kernel.

• Kernel: given a problem and an instance (I,k), a
kernel is an algorithm that outputs in polynomial
time an instance (I',k') such that (a) (I',k') is a
YES instance if and only if (I,k) is; (b) |I'|and k'
Kernelization
• Theorem [Niedermaier]: Every fixed-parameter
tractable problem has a g(k)-kernel.
• Proof: Suppose that there exists a FPT
algorithm with running time f(k) nc, for some
function f and some constant c. Consider an
instance (I,k) with |I|=n.
• If n>f(k), we run the decision algorithm in time
f(k) nc < nc+1. If it returns YES (NO), the
kernelization algorithm outputs a constant size
YES (resp. NO) instance.
• If n≤f(k), the the kernelization algorithm
returns (I,k).

Kernelization
• The last theorem implies that every problem
that is FPT has a kernel.
• However, the goal is to obtain kernels that are
"small", that is, polynomial in k, or even constant.

FPT: much more…
• Some problems are not FPT (e.g., graph coloring).
• Complexity classes: W[1] -> Can a nondeterministic Turing machine accept an unary
string s in at most k steps?
• Independent Set is W[1]-hard.
• Reductions to W[1]-hard problems give new
W[1]-hard problems.
• Lower bounds for FPT tractability
• Upper and lower bounds for the size of the
kernels

FPT: much more…
• Theorem [Robertson and Seymour]: Every graph
problem with parameter k whose YES istances
are closed under taking minors can be solved in
O(f(k) n3)


Slide 6

Tecniche Algoritmiche per Grafi e Reti
Fabrizio Frati

Dipartimento di Informatica e Automazione
Università degli Studi Roma Tre

• 3 CREDITI
• I° periodo:
• Lunedì 9:45-11:15 aula N13

• II° periodo:
• Venerdì 8:00-9:45 aula N7

• Contatti:
• {angelini,gdb,frati,ratm} @dia.uniroma3.it
• Ricevimento: mercoledì dalle 17 alle 19

• Struttura del Corso
• ~ 8 seminari
• algoritmi, strutture dati, combinatorica,
graph drawing…

• progetti a gruppi di 2 - 4 persone
• problema di ricerca

• Materiale Didattico
• slides
• G. Di Battista, P. Eades, R. Tamassia, I. G.
Tollis, Graph Drawing: Algorithms for the
Visualization of Graphs, 1999. Prentice Hall.

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
C. Computer System Organization
1.
2.
3.
4.
5.

Processor Architectures
Computer-Communication Networks
Application-Based Systems
Performance of Systems
Computer System Implementations

ACM Computing Classification System
C. Computer System Organization
2. Computer-Communication Networks
2.1 Network Architectures
2.2 Network Protocols
2.3 Network Operations
2.4 Distributed Systems
2.5 LAN & WAN
2.6 Internetworking

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
E. Data
1.
2.
3.
4.
5.

Data Structures
Data Storage Representations
Data Encryption
Coding and Information Theory
Files

ACM Computing Classification System
E. Data
1. Data Structures
1.1 Arrays
1.2 Distributed Data Structures
1.3 Graphs and Networks
1.4 Lists, Stacks, and Queues
1.5 Records
1.6 Tables
1.7 Trees

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
F. Theory of Computation
1.
2.
3.
4.

Computation by Abstract Devices
Analysis of Algorithms and Problem Complexity
Logics and Meanings of Programs
Mathematical Logic and Formal Languages

ACM Computing Classification System
F. Theory of Computation
1. Computation by Abstract Devices
1.1 Models of Computation
1.2 Complexity Measures and Completeness
1.2.1 Complexity Hierarchies
1.2.2 Machine-Independent Complexity
1.2.3 Reducibility and Completeness
1.2.4 Relations among Complexity Classes

ACM Computing Classification System
F. Theory of Computation
2. Analysis of Algorithms and Problem Complexity
2.1 Numerical Algorithms
2.2 Non-numerical Algorithms and Problems
2.2.1 Complexity of Proof Procedures
2.2.2 Computations on Discrete Structures
2.2.3 Geometrical Problems
2.2.4 Pattern Matching
2.2.5 Routing and Layout
2.2.6 Sequencing and Scheduling
2.2.7 Sorting and Searching

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
G. Mathematics of Computing
1.
2.
3.
4.

Numerical Analysis
Discrete Mathematics
Probability and Statistics
Mathematical Software

ACM Computing Classification System
G. Mathematics of Computing
2. Discrete Mathematics
2.1 Combinatorics

2.1.1 Combinatorial Algorithms
2.1.2 Counting Problems
2.1.3 Generating Functions
2.1.4 Permutations and Combinations
2.1.5 Recurrences and Difference Equations

2.2 Graph Theory
2.2.1 Graph Algorithms
2.2.2 Graph Labeling

2.2.5 Path and Circuit Problems
2.2.6 Trees

2.3 Applications

a world FULL of NP-hard problems
Problem: I want to travel among a set of
cities driving the fewest possible number
of KMs. IT’S DIFFICULT!!

Problem: I want to put a set of objects
into some bags, knowing that each bag
can not afford more than 10 KGs and
trying to use as few bags as possible.
IT’S DIFFICULT!!

How to Deal with NP-hard problems?
• Exact Algorithms
• Randomized Algorithms
• Approximation Algorithms
• Fixed-Parameter Tractable Algorithms
• …

Approximation Algorithms

Approximation Algorithms
• We want a solution “close” to the
optimal one.
• Given a minimization problem Π, an
algorithm is an α-approximation for Π if,
for every instance I of Π, it outputs a
solution SOL(I) such that
SOL(I)/OPT(I) ≤ α

Vertex Cover
• Problem: Given a graph G(V,E), find a
minimum vertex cover, that is, a set V’  V
such that every edge e  E has an
endvertex in V’.

NP-hard 
[Karp]

How to Guarantee an Approximation?
• We want an approximation algorithm
for Vertex Cover.
• The cost of the solution produced by the
algorithm should be compared with the
cost of an optimal solution.

• But computing the cost of an optimal
solution is NP-HARD!!
LOWER BOUNDS!

Lower Bound for Vertex Cover
• Given a graph G(V,E), a matching M is
a set of edges M  E such that no two
edges share an endvertex.
• A matching is maximal if no matching M’
exists such that M  M’.

• The size of a matching
is a lower bound on the
size of an optimal
solution to Vertex
Cover!

An Approximation Algorithm
for Vertex Cover

• Algorithm: Find a maximal matching M
and output the set S of matched vertices

An Approximation Algorithm
for Vertex Cover
• Theorem: The previous algorithm is a
2-approximation algorithm for Vertex Cover
• Proof:
• S is a vertex cover, otherwhise the
matching would not be maximal.
• OPT≥M, where M is the size of the output
maximal matching.
• SOL=2M, as the number of matched
vertices is twice the size of the matching.

Approximation Algorithms:much more…
• Approximation schemes: (1+ε)-approx.
• Inapproximability results.
• Complexity classes, e.g., APX.

Fixed-Parameter Tractable Algorithms

Easy or Hard?
Problem (optimization): Let G be a graph.
Which is the minimum number of vertices
whose deletion makes G planar?

NP-hard 
[Lewis-Yannakakis ]

Easy or Hard?
Problem (decision): Let G be a graph and k
be an integer. Is there a set of k vertices
whose deletion makes G planar?
Polynomial 
• Easy O(nk+1) time algorithm for solving the problem:
• Consider every set of k vertices. Remove such
vertices. Test the planarity of the resulting graph.

• There are O(nk) such sets. Testing the planarity of
an n-vertex graph takes O(n) time. Then,
T(n,k)= O(nk) O(n) = O(nk+1)

Easy or Hard?
Where is the trick?
In the decision version, k is a constant
parameter part of the input
An O(nk+1)-time algorithm, with k constant, is a
polynomial-time algorithm.

But it is very slow 

Fixed-Parameter Tractability
A problem is fixed-parameter tractable
if it can be solved in f(k) nO(1) time,
where k is a parameter of the problem,
f is an arbitrary function, and nO(1) is a
polynomial (not depending on k).

FPT algorithm for Vertex Cover
Theorem [Melhorn]: There is an O(2k n)time algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• There is a vertex cover with k=0 if and only if G
has no edge.
• Consider any edge e=(u,v). Either u or v belongs
to any vertex cover S.
• Consider both the case in which u S and the
case in which v S.

FPT algorithm for Vertex Cover
u

u

v

v

• u  S -> S is a vertex cover of G if and only if
S-{u} is a vertex cover of G-{u} -> solve the
instance (G-{u}, k-1)
• v  S -> S is a vertex cover of G if and only if
S-{v} is a vertex cover of G-{v} -> solve the
instance (G-{v}, k-1)

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• T(n,0) = O(n)
• T(n,k) = 2 T(n-1, k-1) +O(n) ≤ 2 T(n, k-1) +O(n) ≤
2 (2 T(n, k-2) +O(n)) +O(n) ≤
2 (2 (2 T(n, k-3) +O(n)) +O(n)) +O(n) ≤
2 (2 (2 (…(2 T(n, 0)+O(n)) + … +O(n))
+O(n)) +O(n) ≤
2k O(n) + (2k-1 + 2k-2 + 2k-3 + ... + 1) O(n) =
2k O(n) + (2k - 1) O(n) = O(2k n)

Reduction Rules
Reduction rule : a rule (that is, a polynomial time
algorithm) that transforms an instance (I,k) to
an "equivalent and simpler” instance (I', k’).

Equivalent: (I,k) is a YES instance if and only if
(I', k') is a YES instance.
Simpler: |I'|<|I| or k'occurrences of a particular substructure.

Another FPT algorithm for Vertex Cover
Theorem: There is an O(1.6181k n2)-time
algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• We apply the following two reduction rules:
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k).
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u,N(u)},k-1).

Another FPT algorithm for Vertex Cover
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k). Correctness: if S is a vertex
cover of G and u is in S, then S-{u} is also a
vertex cover of G, as u has no incident edge.
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u, N(u)},k-1). Correctness: if S is a
vertex cover of G and u is in S, then
S-{u}  N(u) is also a vertex cover of G, as u
has no other incident edge.

Another FPT algorithm for Vertex Cover
• If neither of the two rules can be applied,
then every vertex has degree at least 2.
• Pick a vertex u. Any vertex cover of G
contains either u or N(u). Thus, (G,k) is a YES
instance if and only if (G-{u},k-1) or
(G-N(u),k-|N(u)|) is.

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• Since |N(u)|\geq 2,
• T(n,k) ≤ T(n,k-1)+ T(n,k-2)+O(n^2).
• Fibonacci series: every number is the sum of
the previous two xk =xk-1 +xk-2 +c.

• The k-th number of the Fibonacci series
tends to the golden ratio to the power of k.
• T(n,k)=Φk O(n2)=((1+√5)/2)k O(n2) =
O(1.6181k n2).

Kernelization
• Sometimes the reduction rules work till the size
of the problem is reduced really a lot. That is,
after the reduction rules have been applied,
the problem has size g(k), for some function k.
In this case the problem has a g(k)-kernel.

• Kernel: given a problem and an instance (I,k), a
kernel is an algorithm that outputs in polynomial
time an instance (I',k') such that (a) (I',k') is a
YES instance if and only if (I,k) is; (b) |I'|and k'
Kernelization
• Theorem [Niedermaier]: Every fixed-parameter
tractable problem has a g(k)-kernel.
• Proof: Suppose that there exists a FPT
algorithm with running time f(k) nc, for some
function f and some constant c. Consider an
instance (I,k) with |I|=n.
• If n>f(k), we run the decision algorithm in time
f(k) nc < nc+1. If it returns YES (NO), the
kernelization algorithm outputs a constant size
YES (resp. NO) instance.
• If n≤f(k), the the kernelization algorithm
returns (I,k).

Kernelization
• The last theorem implies that every problem
that is FPT has a kernel.
• However, the goal is to obtain kernels that are
"small", that is, polynomial in k, or even constant.

FPT: much more…
• Some problems are not FPT (e.g., graph coloring).
• Complexity classes: W[1] -> Can a nondeterministic Turing machine accept an unary
string s in at most k steps?
• Independent Set is W[1]-hard.
• Reductions to W[1]-hard problems give new
W[1]-hard problems.
• Lower bounds for FPT tractability
• Upper and lower bounds for the size of the
kernels

FPT: much more…
• Theorem [Robertson and Seymour]: Every graph
problem with parameter k whose YES istances
are closed under taking minors can be solved in
O(f(k) n3)


Slide 7

Tecniche Algoritmiche per Grafi e Reti
Fabrizio Frati

Dipartimento di Informatica e Automazione
Università degli Studi Roma Tre

• 3 CREDITI
• I° periodo:
• Lunedì 9:45-11:15 aula N13

• II° periodo:
• Venerdì 8:00-9:45 aula N7

• Contatti:
• {angelini,gdb,frati,ratm} @dia.uniroma3.it
• Ricevimento: mercoledì dalle 17 alle 19

• Struttura del Corso
• ~ 8 seminari
• algoritmi, strutture dati, combinatorica,
graph drawing…

• progetti a gruppi di 2 - 4 persone
• problema di ricerca

• Materiale Didattico
• slides
• G. Di Battista, P. Eades, R. Tamassia, I. G.
Tollis, Graph Drawing: Algorithms for the
Visualization of Graphs, 1999. Prentice Hall.

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
C. Computer System Organization
1.
2.
3.
4.
5.

Processor Architectures
Computer-Communication Networks
Application-Based Systems
Performance of Systems
Computer System Implementations

ACM Computing Classification System
C. Computer System Organization
2. Computer-Communication Networks
2.1 Network Architectures
2.2 Network Protocols
2.3 Network Operations
2.4 Distributed Systems
2.5 LAN & WAN
2.6 Internetworking

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
E. Data
1.
2.
3.
4.
5.

Data Structures
Data Storage Representations
Data Encryption
Coding and Information Theory
Files

ACM Computing Classification System
E. Data
1. Data Structures
1.1 Arrays
1.2 Distributed Data Structures
1.3 Graphs and Networks
1.4 Lists, Stacks, and Queues
1.5 Records
1.6 Tables
1.7 Trees

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
F. Theory of Computation
1.
2.
3.
4.

Computation by Abstract Devices
Analysis of Algorithms and Problem Complexity
Logics and Meanings of Programs
Mathematical Logic and Formal Languages

ACM Computing Classification System
F. Theory of Computation
1. Computation by Abstract Devices
1.1 Models of Computation
1.2 Complexity Measures and Completeness
1.2.1 Complexity Hierarchies
1.2.2 Machine-Independent Complexity
1.2.3 Reducibility and Completeness
1.2.4 Relations among Complexity Classes

ACM Computing Classification System
F. Theory of Computation
2. Analysis of Algorithms and Problem Complexity
2.1 Numerical Algorithms
2.2 Non-numerical Algorithms and Problems
2.2.1 Complexity of Proof Procedures
2.2.2 Computations on Discrete Structures
2.2.3 Geometrical Problems
2.2.4 Pattern Matching
2.2.5 Routing and Layout
2.2.6 Sequencing and Scheduling
2.2.7 Sorting and Searching

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
G. Mathematics of Computing
1.
2.
3.
4.

Numerical Analysis
Discrete Mathematics
Probability and Statistics
Mathematical Software

ACM Computing Classification System
G. Mathematics of Computing
2. Discrete Mathematics
2.1 Combinatorics

2.1.1 Combinatorial Algorithms
2.1.2 Counting Problems
2.1.3 Generating Functions
2.1.4 Permutations and Combinations
2.1.5 Recurrences and Difference Equations

2.2 Graph Theory
2.2.1 Graph Algorithms
2.2.2 Graph Labeling

2.2.5 Path and Circuit Problems
2.2.6 Trees

2.3 Applications

a world FULL of NP-hard problems
Problem: I want to travel among a set of
cities driving the fewest possible number
of KMs. IT’S DIFFICULT!!

Problem: I want to put a set of objects
into some bags, knowing that each bag
can not afford more than 10 KGs and
trying to use as few bags as possible.
IT’S DIFFICULT!!

How to Deal with NP-hard problems?
• Exact Algorithms
• Randomized Algorithms
• Approximation Algorithms
• Fixed-Parameter Tractable Algorithms
• …

Approximation Algorithms

Approximation Algorithms
• We want a solution “close” to the
optimal one.
• Given a minimization problem Π, an
algorithm is an α-approximation for Π if,
for every instance I of Π, it outputs a
solution SOL(I) such that
SOL(I)/OPT(I) ≤ α

Vertex Cover
• Problem: Given a graph G(V,E), find a
minimum vertex cover, that is, a set V’  V
such that every edge e  E has an
endvertex in V’.

NP-hard 
[Karp]

How to Guarantee an Approximation?
• We want an approximation algorithm
for Vertex Cover.
• The cost of the solution produced by the
algorithm should be compared with the
cost of an optimal solution.

• But computing the cost of an optimal
solution is NP-HARD!!
LOWER BOUNDS!

Lower Bound for Vertex Cover
• Given a graph G(V,E), a matching M is
a set of edges M  E such that no two
edges share an endvertex.
• A matching is maximal if no matching M’
exists such that M  M’.

• The size of a matching
is a lower bound on the
size of an optimal
solution to Vertex
Cover!

An Approximation Algorithm
for Vertex Cover

• Algorithm: Find a maximal matching M
and output the set S of matched vertices

An Approximation Algorithm
for Vertex Cover
• Theorem: The previous algorithm is a
2-approximation algorithm for Vertex Cover
• Proof:
• S is a vertex cover, otherwhise the
matching would not be maximal.
• OPT≥M, where M is the size of the output
maximal matching.
• SOL=2M, as the number of matched
vertices is twice the size of the matching.

Approximation Algorithms:much more…
• Approximation schemes: (1+ε)-approx.
• Inapproximability results.
• Complexity classes, e.g., APX.

Fixed-Parameter Tractable Algorithms

Easy or Hard?
Problem (optimization): Let G be a graph.
Which is the minimum number of vertices
whose deletion makes G planar?

NP-hard 
[Lewis-Yannakakis ]

Easy or Hard?
Problem (decision): Let G be a graph and k
be an integer. Is there a set of k vertices
whose deletion makes G planar?
Polynomial 
• Easy O(nk+1) time algorithm for solving the problem:
• Consider every set of k vertices. Remove such
vertices. Test the planarity of the resulting graph.

• There are O(nk) such sets. Testing the planarity of
an n-vertex graph takes O(n) time. Then,
T(n,k)= O(nk) O(n) = O(nk+1)

Easy or Hard?
Where is the trick?
In the decision version, k is a constant
parameter part of the input
An O(nk+1)-time algorithm, with k constant, is a
polynomial-time algorithm.

But it is very slow 

Fixed-Parameter Tractability
A problem is fixed-parameter tractable
if it can be solved in f(k) nO(1) time,
where k is a parameter of the problem,
f is an arbitrary function, and nO(1) is a
polynomial (not depending on k).

FPT algorithm for Vertex Cover
Theorem [Melhorn]: There is an O(2k n)time algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• There is a vertex cover with k=0 if and only if G
has no edge.
• Consider any edge e=(u,v). Either u or v belongs
to any vertex cover S.
• Consider both the case in which u S and the
case in which v S.

FPT algorithm for Vertex Cover
u

u

v

v

• u  S -> S is a vertex cover of G if and only if
S-{u} is a vertex cover of G-{u} -> solve the
instance (G-{u}, k-1)
• v  S -> S is a vertex cover of G if and only if
S-{v} is a vertex cover of G-{v} -> solve the
instance (G-{v}, k-1)

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• T(n,0) = O(n)
• T(n,k) = 2 T(n-1, k-1) +O(n) ≤ 2 T(n, k-1) +O(n) ≤
2 (2 T(n, k-2) +O(n)) +O(n) ≤
2 (2 (2 T(n, k-3) +O(n)) +O(n)) +O(n) ≤
2 (2 (2 (…(2 T(n, 0)+O(n)) + … +O(n))
+O(n)) +O(n) ≤
2k O(n) + (2k-1 + 2k-2 + 2k-3 + ... + 1) O(n) =
2k O(n) + (2k - 1) O(n) = O(2k n)

Reduction Rules
Reduction rule : a rule (that is, a polynomial time
algorithm) that transforms an instance (I,k) to
an "equivalent and simpler” instance (I', k’).

Equivalent: (I,k) is a YES instance if and only if
(I', k') is a YES instance.
Simpler: |I'|<|I| or k'occurrences of a particular substructure.

Another FPT algorithm for Vertex Cover
Theorem: There is an O(1.6181k n2)-time
algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• We apply the following two reduction rules:
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k).
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u,N(u)},k-1).

Another FPT algorithm for Vertex Cover
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k). Correctness: if S is a vertex
cover of G and u is in S, then S-{u} is also a
vertex cover of G, as u has no incident edge.
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u, N(u)},k-1). Correctness: if S is a
vertex cover of G and u is in S, then
S-{u}  N(u) is also a vertex cover of G, as u
has no other incident edge.

Another FPT algorithm for Vertex Cover
• If neither of the two rules can be applied,
then every vertex has degree at least 2.
• Pick a vertex u. Any vertex cover of G
contains either u or N(u). Thus, (G,k) is a YES
instance if and only if (G-{u},k-1) or
(G-N(u),k-|N(u)|) is.

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• Since |N(u)|\geq 2,
• T(n,k) ≤ T(n,k-1)+ T(n,k-2)+O(n^2).
• Fibonacci series: every number is the sum of
the previous two xk =xk-1 +xk-2 +c.

• The k-th number of the Fibonacci series
tends to the golden ratio to the power of k.
• T(n,k)=Φk O(n2)=((1+√5)/2)k O(n2) =
O(1.6181k n2).

Kernelization
• Sometimes the reduction rules work till the size
of the problem is reduced really a lot. That is,
after the reduction rules have been applied,
the problem has size g(k), for some function k.
In this case the problem has a g(k)-kernel.

• Kernel: given a problem and an instance (I,k), a
kernel is an algorithm that outputs in polynomial
time an instance (I',k') such that (a) (I',k') is a
YES instance if and only if (I,k) is; (b) |I'|and k'
Kernelization
• Theorem [Niedermaier]: Every fixed-parameter
tractable problem has a g(k)-kernel.
• Proof: Suppose that there exists a FPT
algorithm with running time f(k) nc, for some
function f and some constant c. Consider an
instance (I,k) with |I|=n.
• If n>f(k), we run the decision algorithm in time
f(k) nc < nc+1. If it returns YES (NO), the
kernelization algorithm outputs a constant size
YES (resp. NO) instance.
• If n≤f(k), the the kernelization algorithm
returns (I,k).

Kernelization
• The last theorem implies that every problem
that is FPT has a kernel.
• However, the goal is to obtain kernels that are
"small", that is, polynomial in k, or even constant.

FPT: much more…
• Some problems are not FPT (e.g., graph coloring).
• Complexity classes: W[1] -> Can a nondeterministic Turing machine accept an unary
string s in at most k steps?
• Independent Set is W[1]-hard.
• Reductions to W[1]-hard problems give new
W[1]-hard problems.
• Lower bounds for FPT tractability
• Upper and lower bounds for the size of the
kernels

FPT: much more…
• Theorem [Robertson and Seymour]: Every graph
problem with parameter k whose YES istances
are closed under taking minors can be solved in
O(f(k) n3)


Slide 8

Tecniche Algoritmiche per Grafi e Reti
Fabrizio Frati

Dipartimento di Informatica e Automazione
Università degli Studi Roma Tre

• 3 CREDITI
• I° periodo:
• Lunedì 9:45-11:15 aula N13

• II° periodo:
• Venerdì 8:00-9:45 aula N7

• Contatti:
• {angelini,gdb,frati,ratm} @dia.uniroma3.it
• Ricevimento: mercoledì dalle 17 alle 19

• Struttura del Corso
• ~ 8 seminari
• algoritmi, strutture dati, combinatorica,
graph drawing…

• progetti a gruppi di 2 - 4 persone
• problema di ricerca

• Materiale Didattico
• slides
• G. Di Battista, P. Eades, R. Tamassia, I. G.
Tollis, Graph Drawing: Algorithms for the
Visualization of Graphs, 1999. Prentice Hall.

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
C. Computer System Organization
1.
2.
3.
4.
5.

Processor Architectures
Computer-Communication Networks
Application-Based Systems
Performance of Systems
Computer System Implementations

ACM Computing Classification System
C. Computer System Organization
2. Computer-Communication Networks
2.1 Network Architectures
2.2 Network Protocols
2.3 Network Operations
2.4 Distributed Systems
2.5 LAN & WAN
2.6 Internetworking

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
E. Data
1.
2.
3.
4.
5.

Data Structures
Data Storage Representations
Data Encryption
Coding and Information Theory
Files

ACM Computing Classification System
E. Data
1. Data Structures
1.1 Arrays
1.2 Distributed Data Structures
1.3 Graphs and Networks
1.4 Lists, Stacks, and Queues
1.5 Records
1.6 Tables
1.7 Trees

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
F. Theory of Computation
1.
2.
3.
4.

Computation by Abstract Devices
Analysis of Algorithms and Problem Complexity
Logics and Meanings of Programs
Mathematical Logic and Formal Languages

ACM Computing Classification System
F. Theory of Computation
1. Computation by Abstract Devices
1.1 Models of Computation
1.2 Complexity Measures and Completeness
1.2.1 Complexity Hierarchies
1.2.2 Machine-Independent Complexity
1.2.3 Reducibility and Completeness
1.2.4 Relations among Complexity Classes

ACM Computing Classification System
F. Theory of Computation
2. Analysis of Algorithms and Problem Complexity
2.1 Numerical Algorithms
2.2 Non-numerical Algorithms and Problems
2.2.1 Complexity of Proof Procedures
2.2.2 Computations on Discrete Structures
2.2.3 Geometrical Problems
2.2.4 Pattern Matching
2.2.5 Routing and Layout
2.2.6 Sequencing and Scheduling
2.2.7 Sorting and Searching

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
G. Mathematics of Computing
1.
2.
3.
4.

Numerical Analysis
Discrete Mathematics
Probability and Statistics
Mathematical Software

ACM Computing Classification System
G. Mathematics of Computing
2. Discrete Mathematics
2.1 Combinatorics

2.1.1 Combinatorial Algorithms
2.1.2 Counting Problems
2.1.3 Generating Functions
2.1.4 Permutations and Combinations
2.1.5 Recurrences and Difference Equations

2.2 Graph Theory
2.2.1 Graph Algorithms
2.2.2 Graph Labeling

2.2.5 Path and Circuit Problems
2.2.6 Trees

2.3 Applications

a world FULL of NP-hard problems
Problem: I want to travel among a set of
cities driving the fewest possible number
of KMs. IT’S DIFFICULT!!

Problem: I want to put a set of objects
into some bags, knowing that each bag
can not afford more than 10 KGs and
trying to use as few bags as possible.
IT’S DIFFICULT!!

How to Deal with NP-hard problems?
• Exact Algorithms
• Randomized Algorithms
• Approximation Algorithms
• Fixed-Parameter Tractable Algorithms
• …

Approximation Algorithms

Approximation Algorithms
• We want a solution “close” to the
optimal one.
• Given a minimization problem Π, an
algorithm is an α-approximation for Π if,
for every instance I of Π, it outputs a
solution SOL(I) such that
SOL(I)/OPT(I) ≤ α

Vertex Cover
• Problem: Given a graph G(V,E), find a
minimum vertex cover, that is, a set V’  V
such that every edge e  E has an
endvertex in V’.

NP-hard 
[Karp]

How to Guarantee an Approximation?
• We want an approximation algorithm
for Vertex Cover.
• The cost of the solution produced by the
algorithm should be compared with the
cost of an optimal solution.

• But computing the cost of an optimal
solution is NP-HARD!!
LOWER BOUNDS!

Lower Bound for Vertex Cover
• Given a graph G(V,E), a matching M is
a set of edges M  E such that no two
edges share an endvertex.
• A matching is maximal if no matching M’
exists such that M  M’.

• The size of a matching
is a lower bound on the
size of an optimal
solution to Vertex
Cover!

An Approximation Algorithm
for Vertex Cover

• Algorithm: Find a maximal matching M
and output the set S of matched vertices

An Approximation Algorithm
for Vertex Cover
• Theorem: The previous algorithm is a
2-approximation algorithm for Vertex Cover
• Proof:
• S is a vertex cover, otherwhise the
matching would not be maximal.
• OPT≥M, where M is the size of the output
maximal matching.
• SOL=2M, as the number of matched
vertices is twice the size of the matching.

Approximation Algorithms:much more…
• Approximation schemes: (1+ε)-approx.
• Inapproximability results.
• Complexity classes, e.g., APX.

Fixed-Parameter Tractable Algorithms

Easy or Hard?
Problem (optimization): Let G be a graph.
Which is the minimum number of vertices
whose deletion makes G planar?

NP-hard 
[Lewis-Yannakakis ]

Easy or Hard?
Problem (decision): Let G be a graph and k
be an integer. Is there a set of k vertices
whose deletion makes G planar?
Polynomial 
• Easy O(nk+1) time algorithm for solving the problem:
• Consider every set of k vertices. Remove such
vertices. Test the planarity of the resulting graph.

• There are O(nk) such sets. Testing the planarity of
an n-vertex graph takes O(n) time. Then,
T(n,k)= O(nk) O(n) = O(nk+1)

Easy or Hard?
Where is the trick?
In the decision version, k is a constant
parameter part of the input
An O(nk+1)-time algorithm, with k constant, is a
polynomial-time algorithm.

But it is very slow 

Fixed-Parameter Tractability
A problem is fixed-parameter tractable
if it can be solved in f(k) nO(1) time,
where k is a parameter of the problem,
f is an arbitrary function, and nO(1) is a
polynomial (not depending on k).

FPT algorithm for Vertex Cover
Theorem [Melhorn]: There is an O(2k n)time algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• There is a vertex cover with k=0 if and only if G
has no edge.
• Consider any edge e=(u,v). Either u or v belongs
to any vertex cover S.
• Consider both the case in which u S and the
case in which v S.

FPT algorithm for Vertex Cover
u

u

v

v

• u  S -> S is a vertex cover of G if and only if
S-{u} is a vertex cover of G-{u} -> solve the
instance (G-{u}, k-1)
• v  S -> S is a vertex cover of G if and only if
S-{v} is a vertex cover of G-{v} -> solve the
instance (G-{v}, k-1)

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• T(n,0) = O(n)
• T(n,k) = 2 T(n-1, k-1) +O(n) ≤ 2 T(n, k-1) +O(n) ≤
2 (2 T(n, k-2) +O(n)) +O(n) ≤
2 (2 (2 T(n, k-3) +O(n)) +O(n)) +O(n) ≤
2 (2 (2 (…(2 T(n, 0)+O(n)) + … +O(n))
+O(n)) +O(n) ≤
2k O(n) + (2k-1 + 2k-2 + 2k-3 + ... + 1) O(n) =
2k O(n) + (2k - 1) O(n) = O(2k n)

Reduction Rules
Reduction rule : a rule (that is, a polynomial time
algorithm) that transforms an instance (I,k) to
an "equivalent and simpler” instance (I', k’).

Equivalent: (I,k) is a YES instance if and only if
(I', k') is a YES instance.
Simpler: |I'|<|I| or k'occurrences of a particular substructure.

Another FPT algorithm for Vertex Cover
Theorem: There is an O(1.6181k n2)-time
algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• We apply the following two reduction rules:
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k).
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u,N(u)},k-1).

Another FPT algorithm for Vertex Cover
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k). Correctness: if S is a vertex
cover of G and u is in S, then S-{u} is also a
vertex cover of G, as u has no incident edge.
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u, N(u)},k-1). Correctness: if S is a
vertex cover of G and u is in S, then
S-{u}  N(u) is also a vertex cover of G, as u
has no other incident edge.

Another FPT algorithm for Vertex Cover
• If neither of the two rules can be applied,
then every vertex has degree at least 2.
• Pick a vertex u. Any vertex cover of G
contains either u or N(u). Thus, (G,k) is a YES
instance if and only if (G-{u},k-1) or
(G-N(u),k-|N(u)|) is.

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• Since |N(u)|\geq 2,
• T(n,k) ≤ T(n,k-1)+ T(n,k-2)+O(n^2).
• Fibonacci series: every number is the sum of
the previous two xk =xk-1 +xk-2 +c.

• The k-th number of the Fibonacci series
tends to the golden ratio to the power of k.
• T(n,k)=Φk O(n2)=((1+√5)/2)k O(n2) =
O(1.6181k n2).

Kernelization
• Sometimes the reduction rules work till the size
of the problem is reduced really a lot. That is,
after the reduction rules have been applied,
the problem has size g(k), for some function k.
In this case the problem has a g(k)-kernel.

• Kernel: given a problem and an instance (I,k), a
kernel is an algorithm that outputs in polynomial
time an instance (I',k') such that (a) (I',k') is a
YES instance if and only if (I,k) is; (b) |I'|and k'
Kernelization
• Theorem [Niedermaier]: Every fixed-parameter
tractable problem has a g(k)-kernel.
• Proof: Suppose that there exists a FPT
algorithm with running time f(k) nc, for some
function f and some constant c. Consider an
instance (I,k) with |I|=n.
• If n>f(k), we run the decision algorithm in time
f(k) nc < nc+1. If it returns YES (NO), the
kernelization algorithm outputs a constant size
YES (resp. NO) instance.
• If n≤f(k), the the kernelization algorithm
returns (I,k).

Kernelization
• The last theorem implies that every problem
that is FPT has a kernel.
• However, the goal is to obtain kernels that are
"small", that is, polynomial in k, or even constant.

FPT: much more…
• Some problems are not FPT (e.g., graph coloring).
• Complexity classes: W[1] -> Can a nondeterministic Turing machine accept an unary
string s in at most k steps?
• Independent Set is W[1]-hard.
• Reductions to W[1]-hard problems give new
W[1]-hard problems.
• Lower bounds for FPT tractability
• Upper and lower bounds for the size of the
kernels

FPT: much more…
• Theorem [Robertson and Seymour]: Every graph
problem with parameter k whose YES istances
are closed under taking minors can be solved in
O(f(k) n3)


Slide 9

Tecniche Algoritmiche per Grafi e Reti
Fabrizio Frati

Dipartimento di Informatica e Automazione
Università degli Studi Roma Tre

• 3 CREDITI
• I° periodo:
• Lunedì 9:45-11:15 aula N13

• II° periodo:
• Venerdì 8:00-9:45 aula N7

• Contatti:
• {angelini,gdb,frati,ratm} @dia.uniroma3.it
• Ricevimento: mercoledì dalle 17 alle 19

• Struttura del Corso
• ~ 8 seminari
• algoritmi, strutture dati, combinatorica,
graph drawing…

• progetti a gruppi di 2 - 4 persone
• problema di ricerca

• Materiale Didattico
• slides
• G. Di Battista, P. Eades, R. Tamassia, I. G.
Tollis, Graph Drawing: Algorithms for the
Visualization of Graphs, 1999. Prentice Hall.

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
C. Computer System Organization
1.
2.
3.
4.
5.

Processor Architectures
Computer-Communication Networks
Application-Based Systems
Performance of Systems
Computer System Implementations

ACM Computing Classification System
C. Computer System Organization
2. Computer-Communication Networks
2.1 Network Architectures
2.2 Network Protocols
2.3 Network Operations
2.4 Distributed Systems
2.5 LAN & WAN
2.6 Internetworking

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
E. Data
1.
2.
3.
4.
5.

Data Structures
Data Storage Representations
Data Encryption
Coding and Information Theory
Files

ACM Computing Classification System
E. Data
1. Data Structures
1.1 Arrays
1.2 Distributed Data Structures
1.3 Graphs and Networks
1.4 Lists, Stacks, and Queues
1.5 Records
1.6 Tables
1.7 Trees

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
F. Theory of Computation
1.
2.
3.
4.

Computation by Abstract Devices
Analysis of Algorithms and Problem Complexity
Logics and Meanings of Programs
Mathematical Logic and Formal Languages

ACM Computing Classification System
F. Theory of Computation
1. Computation by Abstract Devices
1.1 Models of Computation
1.2 Complexity Measures and Completeness
1.2.1 Complexity Hierarchies
1.2.2 Machine-Independent Complexity
1.2.3 Reducibility and Completeness
1.2.4 Relations among Complexity Classes

ACM Computing Classification System
F. Theory of Computation
2. Analysis of Algorithms and Problem Complexity
2.1 Numerical Algorithms
2.2 Non-numerical Algorithms and Problems
2.2.1 Complexity of Proof Procedures
2.2.2 Computations on Discrete Structures
2.2.3 Geometrical Problems
2.2.4 Pattern Matching
2.2.5 Routing and Layout
2.2.6 Sequencing and Scheduling
2.2.7 Sorting and Searching

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
G. Mathematics of Computing
1.
2.
3.
4.

Numerical Analysis
Discrete Mathematics
Probability and Statistics
Mathematical Software

ACM Computing Classification System
G. Mathematics of Computing
2. Discrete Mathematics
2.1 Combinatorics

2.1.1 Combinatorial Algorithms
2.1.2 Counting Problems
2.1.3 Generating Functions
2.1.4 Permutations and Combinations
2.1.5 Recurrences and Difference Equations

2.2 Graph Theory
2.2.1 Graph Algorithms
2.2.2 Graph Labeling

2.2.5 Path and Circuit Problems
2.2.6 Trees

2.3 Applications

a world FULL of NP-hard problems
Problem: I want to travel among a set of
cities driving the fewest possible number
of KMs. IT’S DIFFICULT!!

Problem: I want to put a set of objects
into some bags, knowing that each bag
can not afford more than 10 KGs and
trying to use as few bags as possible.
IT’S DIFFICULT!!

How to Deal with NP-hard problems?
• Exact Algorithms
• Randomized Algorithms
• Approximation Algorithms
• Fixed-Parameter Tractable Algorithms
• …

Approximation Algorithms

Approximation Algorithms
• We want a solution “close” to the
optimal one.
• Given a minimization problem Π, an
algorithm is an α-approximation for Π if,
for every instance I of Π, it outputs a
solution SOL(I) such that
SOL(I)/OPT(I) ≤ α

Vertex Cover
• Problem: Given a graph G(V,E), find a
minimum vertex cover, that is, a set V’  V
such that every edge e  E has an
endvertex in V’.

NP-hard 
[Karp]

How to Guarantee an Approximation?
• We want an approximation algorithm
for Vertex Cover.
• The cost of the solution produced by the
algorithm should be compared with the
cost of an optimal solution.

• But computing the cost of an optimal
solution is NP-HARD!!
LOWER BOUNDS!

Lower Bound for Vertex Cover
• Given a graph G(V,E), a matching M is
a set of edges M  E such that no two
edges share an endvertex.
• A matching is maximal if no matching M’
exists such that M  M’.

• The size of a matching
is a lower bound on the
size of an optimal
solution to Vertex
Cover!

An Approximation Algorithm
for Vertex Cover

• Algorithm: Find a maximal matching M
and output the set S of matched vertices

An Approximation Algorithm
for Vertex Cover
• Theorem: The previous algorithm is a
2-approximation algorithm for Vertex Cover
• Proof:
• S is a vertex cover, otherwhise the
matching would not be maximal.
• OPT≥M, where M is the size of the output
maximal matching.
• SOL=2M, as the number of matched
vertices is twice the size of the matching.

Approximation Algorithms:much more…
• Approximation schemes: (1+ε)-approx.
• Inapproximability results.
• Complexity classes, e.g., APX.

Fixed-Parameter Tractable Algorithms

Easy or Hard?
Problem (optimization): Let G be a graph.
Which is the minimum number of vertices
whose deletion makes G planar?

NP-hard 
[Lewis-Yannakakis ]

Easy or Hard?
Problem (decision): Let G be a graph and k
be an integer. Is there a set of k vertices
whose deletion makes G planar?
Polynomial 
• Easy O(nk+1) time algorithm for solving the problem:
• Consider every set of k vertices. Remove such
vertices. Test the planarity of the resulting graph.

• There are O(nk) such sets. Testing the planarity of
an n-vertex graph takes O(n) time. Then,
T(n,k)= O(nk) O(n) = O(nk+1)

Easy or Hard?
Where is the trick?
In the decision version, k is a constant
parameter part of the input
An O(nk+1)-time algorithm, with k constant, is a
polynomial-time algorithm.

But it is very slow 

Fixed-Parameter Tractability
A problem is fixed-parameter tractable
if it can be solved in f(k) nO(1) time,
where k is a parameter of the problem,
f is an arbitrary function, and nO(1) is a
polynomial (not depending on k).

FPT algorithm for Vertex Cover
Theorem [Melhorn]: There is an O(2k n)time algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• There is a vertex cover with k=0 if and only if G
has no edge.
• Consider any edge e=(u,v). Either u or v belongs
to any vertex cover S.
• Consider both the case in which u S and the
case in which v S.

FPT algorithm for Vertex Cover
u

u

v

v

• u  S -> S is a vertex cover of G if and only if
S-{u} is a vertex cover of G-{u} -> solve the
instance (G-{u}, k-1)
• v  S -> S is a vertex cover of G if and only if
S-{v} is a vertex cover of G-{v} -> solve the
instance (G-{v}, k-1)

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• T(n,0) = O(n)
• T(n,k) = 2 T(n-1, k-1) +O(n) ≤ 2 T(n, k-1) +O(n) ≤
2 (2 T(n, k-2) +O(n)) +O(n) ≤
2 (2 (2 T(n, k-3) +O(n)) +O(n)) +O(n) ≤
2 (2 (2 (…(2 T(n, 0)+O(n)) + … +O(n))
+O(n)) +O(n) ≤
2k O(n) + (2k-1 + 2k-2 + 2k-3 + ... + 1) O(n) =
2k O(n) + (2k - 1) O(n) = O(2k n)

Reduction Rules
Reduction rule : a rule (that is, a polynomial time
algorithm) that transforms an instance (I,k) to
an "equivalent and simpler” instance (I', k’).

Equivalent: (I,k) is a YES instance if and only if
(I', k') is a YES instance.
Simpler: |I'|<|I| or k'occurrences of a particular substructure.

Another FPT algorithm for Vertex Cover
Theorem: There is an O(1.6181k n2)-time
algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• We apply the following two reduction rules:
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k).
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u,N(u)},k-1).

Another FPT algorithm for Vertex Cover
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k). Correctness: if S is a vertex
cover of G and u is in S, then S-{u} is also a
vertex cover of G, as u has no incident edge.
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u, N(u)},k-1). Correctness: if S is a
vertex cover of G and u is in S, then
S-{u}  N(u) is also a vertex cover of G, as u
has no other incident edge.

Another FPT algorithm for Vertex Cover
• If neither of the two rules can be applied,
then every vertex has degree at least 2.
• Pick a vertex u. Any vertex cover of G
contains either u or N(u). Thus, (G,k) is a YES
instance if and only if (G-{u},k-1) or
(G-N(u),k-|N(u)|) is.

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• Since |N(u)|\geq 2,
• T(n,k) ≤ T(n,k-1)+ T(n,k-2)+O(n^2).
• Fibonacci series: every number is the sum of
the previous two xk =xk-1 +xk-2 +c.

• The k-th number of the Fibonacci series
tends to the golden ratio to the power of k.
• T(n,k)=Φk O(n2)=((1+√5)/2)k O(n2) =
O(1.6181k n2).

Kernelization
• Sometimes the reduction rules work till the size
of the problem is reduced really a lot. That is,
after the reduction rules have been applied,
the problem has size g(k), for some function k.
In this case the problem has a g(k)-kernel.

• Kernel: given a problem and an instance (I,k), a
kernel is an algorithm that outputs in polynomial
time an instance (I',k') such that (a) (I',k') is a
YES instance if and only if (I,k) is; (b) |I'|and k'
Kernelization
• Theorem [Niedermaier]: Every fixed-parameter
tractable problem has a g(k)-kernel.
• Proof: Suppose that there exists a FPT
algorithm with running time f(k) nc, for some
function f and some constant c. Consider an
instance (I,k) with |I|=n.
• If n>f(k), we run the decision algorithm in time
f(k) nc < nc+1. If it returns YES (NO), the
kernelization algorithm outputs a constant size
YES (resp. NO) instance.
• If n≤f(k), the the kernelization algorithm
returns (I,k).

Kernelization
• The last theorem implies that every problem
that is FPT has a kernel.
• However, the goal is to obtain kernels that are
"small", that is, polynomial in k, or even constant.

FPT: much more…
• Some problems are not FPT (e.g., graph coloring).
• Complexity classes: W[1] -> Can a nondeterministic Turing machine accept an unary
string s in at most k steps?
• Independent Set is W[1]-hard.
• Reductions to W[1]-hard problems give new
W[1]-hard problems.
• Lower bounds for FPT tractability
• Upper and lower bounds for the size of the
kernels

FPT: much more…
• Theorem [Robertson and Seymour]: Every graph
problem with parameter k whose YES istances
are closed under taking minors can be solved in
O(f(k) n3)


Slide 10

Tecniche Algoritmiche per Grafi e Reti
Fabrizio Frati

Dipartimento di Informatica e Automazione
Università degli Studi Roma Tre

• 3 CREDITI
• I° periodo:
• Lunedì 9:45-11:15 aula N13

• II° periodo:
• Venerdì 8:00-9:45 aula N7

• Contatti:
• {angelini,gdb,frati,ratm} @dia.uniroma3.it
• Ricevimento: mercoledì dalle 17 alle 19

• Struttura del Corso
• ~ 8 seminari
• algoritmi, strutture dati, combinatorica,
graph drawing…

• progetti a gruppi di 2 - 4 persone
• problema di ricerca

• Materiale Didattico
• slides
• G. Di Battista, P. Eades, R. Tamassia, I. G.
Tollis, Graph Drawing: Algorithms for the
Visualization of Graphs, 1999. Prentice Hall.

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
C. Computer System Organization
1.
2.
3.
4.
5.

Processor Architectures
Computer-Communication Networks
Application-Based Systems
Performance of Systems
Computer System Implementations

ACM Computing Classification System
C. Computer System Organization
2. Computer-Communication Networks
2.1 Network Architectures
2.2 Network Protocols
2.3 Network Operations
2.4 Distributed Systems
2.5 LAN & WAN
2.6 Internetworking

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
E. Data
1.
2.
3.
4.
5.

Data Structures
Data Storage Representations
Data Encryption
Coding and Information Theory
Files

ACM Computing Classification System
E. Data
1. Data Structures
1.1 Arrays
1.2 Distributed Data Structures
1.3 Graphs and Networks
1.4 Lists, Stacks, and Queues
1.5 Records
1.6 Tables
1.7 Trees

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
F. Theory of Computation
1.
2.
3.
4.

Computation by Abstract Devices
Analysis of Algorithms and Problem Complexity
Logics and Meanings of Programs
Mathematical Logic and Formal Languages

ACM Computing Classification System
F. Theory of Computation
1. Computation by Abstract Devices
1.1 Models of Computation
1.2 Complexity Measures and Completeness
1.2.1 Complexity Hierarchies
1.2.2 Machine-Independent Complexity
1.2.3 Reducibility and Completeness
1.2.4 Relations among Complexity Classes

ACM Computing Classification System
F. Theory of Computation
2. Analysis of Algorithms and Problem Complexity
2.1 Numerical Algorithms
2.2 Non-numerical Algorithms and Problems
2.2.1 Complexity of Proof Procedures
2.2.2 Computations on Discrete Structures
2.2.3 Geometrical Problems
2.2.4 Pattern Matching
2.2.5 Routing and Layout
2.2.6 Sequencing and Scheduling
2.2.7 Sorting and Searching

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
G. Mathematics of Computing
1.
2.
3.
4.

Numerical Analysis
Discrete Mathematics
Probability and Statistics
Mathematical Software

ACM Computing Classification System
G. Mathematics of Computing
2. Discrete Mathematics
2.1 Combinatorics

2.1.1 Combinatorial Algorithms
2.1.2 Counting Problems
2.1.3 Generating Functions
2.1.4 Permutations and Combinations
2.1.5 Recurrences and Difference Equations

2.2 Graph Theory
2.2.1 Graph Algorithms
2.2.2 Graph Labeling

2.2.5 Path and Circuit Problems
2.2.6 Trees

2.3 Applications

a world FULL of NP-hard problems
Problem: I want to travel among a set of
cities driving the fewest possible number
of KMs. IT’S DIFFICULT!!

Problem: I want to put a set of objects
into some bags, knowing that each bag
can not afford more than 10 KGs and
trying to use as few bags as possible.
IT’S DIFFICULT!!

How to Deal with NP-hard problems?
• Exact Algorithms
• Randomized Algorithms
• Approximation Algorithms
• Fixed-Parameter Tractable Algorithms
• …

Approximation Algorithms

Approximation Algorithms
• We want a solution “close” to the
optimal one.
• Given a minimization problem Π, an
algorithm is an α-approximation for Π if,
for every instance I of Π, it outputs a
solution SOL(I) such that
SOL(I)/OPT(I) ≤ α

Vertex Cover
• Problem: Given a graph G(V,E), find a
minimum vertex cover, that is, a set V’  V
such that every edge e  E has an
endvertex in V’.

NP-hard 
[Karp]

How to Guarantee an Approximation?
• We want an approximation algorithm
for Vertex Cover.
• The cost of the solution produced by the
algorithm should be compared with the
cost of an optimal solution.

• But computing the cost of an optimal
solution is NP-HARD!!
LOWER BOUNDS!

Lower Bound for Vertex Cover
• Given a graph G(V,E), a matching M is
a set of edges M  E such that no two
edges share an endvertex.
• A matching is maximal if no matching M’
exists such that M  M’.

• The size of a matching
is a lower bound on the
size of an optimal
solution to Vertex
Cover!

An Approximation Algorithm
for Vertex Cover

• Algorithm: Find a maximal matching M
and output the set S of matched vertices

An Approximation Algorithm
for Vertex Cover
• Theorem: The previous algorithm is a
2-approximation algorithm for Vertex Cover
• Proof:
• S is a vertex cover, otherwhise the
matching would not be maximal.
• OPT≥M, where M is the size of the output
maximal matching.
• SOL=2M, as the number of matched
vertices is twice the size of the matching.

Approximation Algorithms:much more…
• Approximation schemes: (1+ε)-approx.
• Inapproximability results.
• Complexity classes, e.g., APX.

Fixed-Parameter Tractable Algorithms

Easy or Hard?
Problem (optimization): Let G be a graph.
Which is the minimum number of vertices
whose deletion makes G planar?

NP-hard 
[Lewis-Yannakakis ]

Easy or Hard?
Problem (decision): Let G be a graph and k
be an integer. Is there a set of k vertices
whose deletion makes G planar?
Polynomial 
• Easy O(nk+1) time algorithm for solving the problem:
• Consider every set of k vertices. Remove such
vertices. Test the planarity of the resulting graph.

• There are O(nk) such sets. Testing the planarity of
an n-vertex graph takes O(n) time. Then,
T(n,k)= O(nk) O(n) = O(nk+1)

Easy or Hard?
Where is the trick?
In the decision version, k is a constant
parameter part of the input
An O(nk+1)-time algorithm, with k constant, is a
polynomial-time algorithm.

But it is very slow 

Fixed-Parameter Tractability
A problem is fixed-parameter tractable
if it can be solved in f(k) nO(1) time,
where k is a parameter of the problem,
f is an arbitrary function, and nO(1) is a
polynomial (not depending on k).

FPT algorithm for Vertex Cover
Theorem [Melhorn]: There is an O(2k n)time algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• There is a vertex cover with k=0 if and only if G
has no edge.
• Consider any edge e=(u,v). Either u or v belongs
to any vertex cover S.
• Consider both the case in which u S and the
case in which v S.

FPT algorithm for Vertex Cover
u

u

v

v

• u  S -> S is a vertex cover of G if and only if
S-{u} is a vertex cover of G-{u} -> solve the
instance (G-{u}, k-1)
• v  S -> S is a vertex cover of G if and only if
S-{v} is a vertex cover of G-{v} -> solve the
instance (G-{v}, k-1)

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• T(n,0) = O(n)
• T(n,k) = 2 T(n-1, k-1) +O(n) ≤ 2 T(n, k-1) +O(n) ≤
2 (2 T(n, k-2) +O(n)) +O(n) ≤
2 (2 (2 T(n, k-3) +O(n)) +O(n)) +O(n) ≤
2 (2 (2 (…(2 T(n, 0)+O(n)) + … +O(n))
+O(n)) +O(n) ≤
2k O(n) + (2k-1 + 2k-2 + 2k-3 + ... + 1) O(n) =
2k O(n) + (2k - 1) O(n) = O(2k n)

Reduction Rules
Reduction rule : a rule (that is, a polynomial time
algorithm) that transforms an instance (I,k) to
an "equivalent and simpler” instance (I', k’).

Equivalent: (I,k) is a YES instance if and only if
(I', k') is a YES instance.
Simpler: |I'|<|I| or k'occurrences of a particular substructure.

Another FPT algorithm for Vertex Cover
Theorem: There is an O(1.6181k n2)-time
algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• We apply the following two reduction rules:
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k).
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u,N(u)},k-1).

Another FPT algorithm for Vertex Cover
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k). Correctness: if S is a vertex
cover of G and u is in S, then S-{u} is also a
vertex cover of G, as u has no incident edge.
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u, N(u)},k-1). Correctness: if S is a
vertex cover of G and u is in S, then
S-{u}  N(u) is also a vertex cover of G, as u
has no other incident edge.

Another FPT algorithm for Vertex Cover
• If neither of the two rules can be applied,
then every vertex has degree at least 2.
• Pick a vertex u. Any vertex cover of G
contains either u or N(u). Thus, (G,k) is a YES
instance if and only if (G-{u},k-1) or
(G-N(u),k-|N(u)|) is.

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• Since |N(u)|\geq 2,
• T(n,k) ≤ T(n,k-1)+ T(n,k-2)+O(n^2).
• Fibonacci series: every number is the sum of
the previous two xk =xk-1 +xk-2 +c.

• The k-th number of the Fibonacci series
tends to the golden ratio to the power of k.
• T(n,k)=Φk O(n2)=((1+√5)/2)k O(n2) =
O(1.6181k n2).

Kernelization
• Sometimes the reduction rules work till the size
of the problem is reduced really a lot. That is,
after the reduction rules have been applied,
the problem has size g(k), for some function k.
In this case the problem has a g(k)-kernel.

• Kernel: given a problem and an instance (I,k), a
kernel is an algorithm that outputs in polynomial
time an instance (I',k') such that (a) (I',k') is a
YES instance if and only if (I,k) is; (b) |I'|and k'
Kernelization
• Theorem [Niedermaier]: Every fixed-parameter
tractable problem has a g(k)-kernel.
• Proof: Suppose that there exists a FPT
algorithm with running time f(k) nc, for some
function f and some constant c. Consider an
instance (I,k) with |I|=n.
• If n>f(k), we run the decision algorithm in time
f(k) nc < nc+1. If it returns YES (NO), the
kernelization algorithm outputs a constant size
YES (resp. NO) instance.
• If n≤f(k), the the kernelization algorithm
returns (I,k).

Kernelization
• The last theorem implies that every problem
that is FPT has a kernel.
• However, the goal is to obtain kernels that are
"small", that is, polynomial in k, or even constant.

FPT: much more…
• Some problems are not FPT (e.g., graph coloring).
• Complexity classes: W[1] -> Can a nondeterministic Turing machine accept an unary
string s in at most k steps?
• Independent Set is W[1]-hard.
• Reductions to W[1]-hard problems give new
W[1]-hard problems.
• Lower bounds for FPT tractability
• Upper and lower bounds for the size of the
kernels

FPT: much more…
• Theorem [Robertson and Seymour]: Every graph
problem with parameter k whose YES istances
are closed under taking minors can be solved in
O(f(k) n3)


Slide 11

Tecniche Algoritmiche per Grafi e Reti
Fabrizio Frati

Dipartimento di Informatica e Automazione
Università degli Studi Roma Tre

• 3 CREDITI
• I° periodo:
• Lunedì 9:45-11:15 aula N13

• II° periodo:
• Venerdì 8:00-9:45 aula N7

• Contatti:
• {angelini,gdb,frati,ratm} @dia.uniroma3.it
• Ricevimento: mercoledì dalle 17 alle 19

• Struttura del Corso
• ~ 8 seminari
• algoritmi, strutture dati, combinatorica,
graph drawing…

• progetti a gruppi di 2 - 4 persone
• problema di ricerca

• Materiale Didattico
• slides
• G. Di Battista, P. Eades, R. Tamassia, I. G.
Tollis, Graph Drawing: Algorithms for the
Visualization of Graphs, 1999. Prentice Hall.

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
C. Computer System Organization
1.
2.
3.
4.
5.

Processor Architectures
Computer-Communication Networks
Application-Based Systems
Performance of Systems
Computer System Implementations

ACM Computing Classification System
C. Computer System Organization
2. Computer-Communication Networks
2.1 Network Architectures
2.2 Network Protocols
2.3 Network Operations
2.4 Distributed Systems
2.5 LAN & WAN
2.6 Internetworking

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
E. Data
1.
2.
3.
4.
5.

Data Structures
Data Storage Representations
Data Encryption
Coding and Information Theory
Files

ACM Computing Classification System
E. Data
1. Data Structures
1.1 Arrays
1.2 Distributed Data Structures
1.3 Graphs and Networks
1.4 Lists, Stacks, and Queues
1.5 Records
1.6 Tables
1.7 Trees

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
F. Theory of Computation
1.
2.
3.
4.

Computation by Abstract Devices
Analysis of Algorithms and Problem Complexity
Logics and Meanings of Programs
Mathematical Logic and Formal Languages

ACM Computing Classification System
F. Theory of Computation
1. Computation by Abstract Devices
1.1 Models of Computation
1.2 Complexity Measures and Completeness
1.2.1 Complexity Hierarchies
1.2.2 Machine-Independent Complexity
1.2.3 Reducibility and Completeness
1.2.4 Relations among Complexity Classes

ACM Computing Classification System
F. Theory of Computation
2. Analysis of Algorithms and Problem Complexity
2.1 Numerical Algorithms
2.2 Non-numerical Algorithms and Problems
2.2.1 Complexity of Proof Procedures
2.2.2 Computations on Discrete Structures
2.2.3 Geometrical Problems
2.2.4 Pattern Matching
2.2.5 Routing and Layout
2.2.6 Sequencing and Scheduling
2.2.7 Sorting and Searching

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
G. Mathematics of Computing
1.
2.
3.
4.

Numerical Analysis
Discrete Mathematics
Probability and Statistics
Mathematical Software

ACM Computing Classification System
G. Mathematics of Computing
2. Discrete Mathematics
2.1 Combinatorics

2.1.1 Combinatorial Algorithms
2.1.2 Counting Problems
2.1.3 Generating Functions
2.1.4 Permutations and Combinations
2.1.5 Recurrences and Difference Equations

2.2 Graph Theory
2.2.1 Graph Algorithms
2.2.2 Graph Labeling

2.2.5 Path and Circuit Problems
2.2.6 Trees

2.3 Applications

a world FULL of NP-hard problems
Problem: I want to travel among a set of
cities driving the fewest possible number
of KMs. IT’S DIFFICULT!!

Problem: I want to put a set of objects
into some bags, knowing that each bag
can not afford more than 10 KGs and
trying to use as few bags as possible.
IT’S DIFFICULT!!

How to Deal with NP-hard problems?
• Exact Algorithms
• Randomized Algorithms
• Approximation Algorithms
• Fixed-Parameter Tractable Algorithms
• …

Approximation Algorithms

Approximation Algorithms
• We want a solution “close” to the
optimal one.
• Given a minimization problem Π, an
algorithm is an α-approximation for Π if,
for every instance I of Π, it outputs a
solution SOL(I) such that
SOL(I)/OPT(I) ≤ α

Vertex Cover
• Problem: Given a graph G(V,E), find a
minimum vertex cover, that is, a set V’  V
such that every edge e  E has an
endvertex in V’.

NP-hard 
[Karp]

How to Guarantee an Approximation?
• We want an approximation algorithm
for Vertex Cover.
• The cost of the solution produced by the
algorithm should be compared with the
cost of an optimal solution.

• But computing the cost of an optimal
solution is NP-HARD!!
LOWER BOUNDS!

Lower Bound for Vertex Cover
• Given a graph G(V,E), a matching M is
a set of edges M  E such that no two
edges share an endvertex.
• A matching is maximal if no matching M’
exists such that M  M’.

• The size of a matching
is a lower bound on the
size of an optimal
solution to Vertex
Cover!

An Approximation Algorithm
for Vertex Cover

• Algorithm: Find a maximal matching M
and output the set S of matched vertices

An Approximation Algorithm
for Vertex Cover
• Theorem: The previous algorithm is a
2-approximation algorithm for Vertex Cover
• Proof:
• S is a vertex cover, otherwhise the
matching would not be maximal.
• OPT≥M, where M is the size of the output
maximal matching.
• SOL=2M, as the number of matched
vertices is twice the size of the matching.

Approximation Algorithms:much more…
• Approximation schemes: (1+ε)-approx.
• Inapproximability results.
• Complexity classes, e.g., APX.

Fixed-Parameter Tractable Algorithms

Easy or Hard?
Problem (optimization): Let G be a graph.
Which is the minimum number of vertices
whose deletion makes G planar?

NP-hard 
[Lewis-Yannakakis ]

Easy or Hard?
Problem (decision): Let G be a graph and k
be an integer. Is there a set of k vertices
whose deletion makes G planar?
Polynomial 
• Easy O(nk+1) time algorithm for solving the problem:
• Consider every set of k vertices. Remove such
vertices. Test the planarity of the resulting graph.

• There are O(nk) such sets. Testing the planarity of
an n-vertex graph takes O(n) time. Then,
T(n,k)= O(nk) O(n) = O(nk+1)

Easy or Hard?
Where is the trick?
In the decision version, k is a constant
parameter part of the input
An O(nk+1)-time algorithm, with k constant, is a
polynomial-time algorithm.

But it is very slow 

Fixed-Parameter Tractability
A problem is fixed-parameter tractable
if it can be solved in f(k) nO(1) time,
where k is a parameter of the problem,
f is an arbitrary function, and nO(1) is a
polynomial (not depending on k).

FPT algorithm for Vertex Cover
Theorem [Melhorn]: There is an O(2k n)time algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• There is a vertex cover with k=0 if and only if G
has no edge.
• Consider any edge e=(u,v). Either u or v belongs
to any vertex cover S.
• Consider both the case in which u S and the
case in which v S.

FPT algorithm for Vertex Cover
u

u

v

v

• u  S -> S is a vertex cover of G if and only if
S-{u} is a vertex cover of G-{u} -> solve the
instance (G-{u}, k-1)
• v  S -> S is a vertex cover of G if and only if
S-{v} is a vertex cover of G-{v} -> solve the
instance (G-{v}, k-1)

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• T(n,0) = O(n)
• T(n,k) = 2 T(n-1, k-1) +O(n) ≤ 2 T(n, k-1) +O(n) ≤
2 (2 T(n, k-2) +O(n)) +O(n) ≤
2 (2 (2 T(n, k-3) +O(n)) +O(n)) +O(n) ≤
2 (2 (2 (…(2 T(n, 0)+O(n)) + … +O(n))
+O(n)) +O(n) ≤
2k O(n) + (2k-1 + 2k-2 + 2k-3 + ... + 1) O(n) =
2k O(n) + (2k - 1) O(n) = O(2k n)

Reduction Rules
Reduction rule : a rule (that is, a polynomial time
algorithm) that transforms an instance (I,k) to
an "equivalent and simpler” instance (I', k’).

Equivalent: (I,k) is a YES instance if and only if
(I', k') is a YES instance.
Simpler: |I'|<|I| or k'occurrences of a particular substructure.

Another FPT algorithm for Vertex Cover
Theorem: There is an O(1.6181k n2)-time
algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• We apply the following two reduction rules:
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k).
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u,N(u)},k-1).

Another FPT algorithm for Vertex Cover
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k). Correctness: if S is a vertex
cover of G and u is in S, then S-{u} is also a
vertex cover of G, as u has no incident edge.
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u, N(u)},k-1). Correctness: if S is a
vertex cover of G and u is in S, then
S-{u}  N(u) is also a vertex cover of G, as u
has no other incident edge.

Another FPT algorithm for Vertex Cover
• If neither of the two rules can be applied,
then every vertex has degree at least 2.
• Pick a vertex u. Any vertex cover of G
contains either u or N(u). Thus, (G,k) is a YES
instance if and only if (G-{u},k-1) or
(G-N(u),k-|N(u)|) is.

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• Since |N(u)|\geq 2,
• T(n,k) ≤ T(n,k-1)+ T(n,k-2)+O(n^2).
• Fibonacci series: every number is the sum of
the previous two xk =xk-1 +xk-2 +c.

• The k-th number of the Fibonacci series
tends to the golden ratio to the power of k.
• T(n,k)=Φk O(n2)=((1+√5)/2)k O(n2) =
O(1.6181k n2).

Kernelization
• Sometimes the reduction rules work till the size
of the problem is reduced really a lot. That is,
after the reduction rules have been applied,
the problem has size g(k), for some function k.
In this case the problem has a g(k)-kernel.

• Kernel: given a problem and an instance (I,k), a
kernel is an algorithm that outputs in polynomial
time an instance (I',k') such that (a) (I',k') is a
YES instance if and only if (I,k) is; (b) |I'|and k'
Kernelization
• Theorem [Niedermaier]: Every fixed-parameter
tractable problem has a g(k)-kernel.
• Proof: Suppose that there exists a FPT
algorithm with running time f(k) nc, for some
function f and some constant c. Consider an
instance (I,k) with |I|=n.
• If n>f(k), we run the decision algorithm in time
f(k) nc < nc+1. If it returns YES (NO), the
kernelization algorithm outputs a constant size
YES (resp. NO) instance.
• If n≤f(k), the the kernelization algorithm
returns (I,k).

Kernelization
• The last theorem implies that every problem
that is FPT has a kernel.
• However, the goal is to obtain kernels that are
"small", that is, polynomial in k, or even constant.

FPT: much more…
• Some problems are not FPT (e.g., graph coloring).
• Complexity classes: W[1] -> Can a nondeterministic Turing machine accept an unary
string s in at most k steps?
• Independent Set is W[1]-hard.
• Reductions to W[1]-hard problems give new
W[1]-hard problems.
• Lower bounds for FPT tractability
• Upper and lower bounds for the size of the
kernels

FPT: much more…
• Theorem [Robertson and Seymour]: Every graph
problem with parameter k whose YES istances
are closed under taking minors can be solved in
O(f(k) n3)


Slide 12

Tecniche Algoritmiche per Grafi e Reti
Fabrizio Frati

Dipartimento di Informatica e Automazione
Università degli Studi Roma Tre

• 3 CREDITI
• I° periodo:
• Lunedì 9:45-11:15 aula N13

• II° periodo:
• Venerdì 8:00-9:45 aula N7

• Contatti:
• {angelini,gdb,frati,ratm} @dia.uniroma3.it
• Ricevimento: mercoledì dalle 17 alle 19

• Struttura del Corso
• ~ 8 seminari
• algoritmi, strutture dati, combinatorica,
graph drawing…

• progetti a gruppi di 2 - 4 persone
• problema di ricerca

• Materiale Didattico
• slides
• G. Di Battista, P. Eades, R. Tamassia, I. G.
Tollis, Graph Drawing: Algorithms for the
Visualization of Graphs, 1999. Prentice Hall.

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
C. Computer System Organization
1.
2.
3.
4.
5.

Processor Architectures
Computer-Communication Networks
Application-Based Systems
Performance of Systems
Computer System Implementations

ACM Computing Classification System
C. Computer System Organization
2. Computer-Communication Networks
2.1 Network Architectures
2.2 Network Protocols
2.3 Network Operations
2.4 Distributed Systems
2.5 LAN & WAN
2.6 Internetworking

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
E. Data
1.
2.
3.
4.
5.

Data Structures
Data Storage Representations
Data Encryption
Coding and Information Theory
Files

ACM Computing Classification System
E. Data
1. Data Structures
1.1 Arrays
1.2 Distributed Data Structures
1.3 Graphs and Networks
1.4 Lists, Stacks, and Queues
1.5 Records
1.6 Tables
1.7 Trees

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
F. Theory of Computation
1.
2.
3.
4.

Computation by Abstract Devices
Analysis of Algorithms and Problem Complexity
Logics and Meanings of Programs
Mathematical Logic and Formal Languages

ACM Computing Classification System
F. Theory of Computation
1. Computation by Abstract Devices
1.1 Models of Computation
1.2 Complexity Measures and Completeness
1.2.1 Complexity Hierarchies
1.2.2 Machine-Independent Complexity
1.2.3 Reducibility and Completeness
1.2.4 Relations among Complexity Classes

ACM Computing Classification System
F. Theory of Computation
2. Analysis of Algorithms and Problem Complexity
2.1 Numerical Algorithms
2.2 Non-numerical Algorithms and Problems
2.2.1 Complexity of Proof Procedures
2.2.2 Computations on Discrete Structures
2.2.3 Geometrical Problems
2.2.4 Pattern Matching
2.2.5 Routing and Layout
2.2.6 Sequencing and Scheduling
2.2.7 Sorting and Searching

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
G. Mathematics of Computing
1.
2.
3.
4.

Numerical Analysis
Discrete Mathematics
Probability and Statistics
Mathematical Software

ACM Computing Classification System
G. Mathematics of Computing
2. Discrete Mathematics
2.1 Combinatorics

2.1.1 Combinatorial Algorithms
2.1.2 Counting Problems
2.1.3 Generating Functions
2.1.4 Permutations and Combinations
2.1.5 Recurrences and Difference Equations

2.2 Graph Theory
2.2.1 Graph Algorithms
2.2.2 Graph Labeling

2.2.5 Path and Circuit Problems
2.2.6 Trees

2.3 Applications

a world FULL of NP-hard problems
Problem: I want to travel among a set of
cities driving the fewest possible number
of KMs. IT’S DIFFICULT!!

Problem: I want to put a set of objects
into some bags, knowing that each bag
can not afford more than 10 KGs and
trying to use as few bags as possible.
IT’S DIFFICULT!!

How to Deal with NP-hard problems?
• Exact Algorithms
• Randomized Algorithms
• Approximation Algorithms
• Fixed-Parameter Tractable Algorithms
• …

Approximation Algorithms

Approximation Algorithms
• We want a solution “close” to the
optimal one.
• Given a minimization problem Π, an
algorithm is an α-approximation for Π if,
for every instance I of Π, it outputs a
solution SOL(I) such that
SOL(I)/OPT(I) ≤ α

Vertex Cover
• Problem: Given a graph G(V,E), find a
minimum vertex cover, that is, a set V’  V
such that every edge e  E has an
endvertex in V’.

NP-hard 
[Karp]

How to Guarantee an Approximation?
• We want an approximation algorithm
for Vertex Cover.
• The cost of the solution produced by the
algorithm should be compared with the
cost of an optimal solution.

• But computing the cost of an optimal
solution is NP-HARD!!
LOWER BOUNDS!

Lower Bound for Vertex Cover
• Given a graph G(V,E), a matching M is
a set of edges M  E such that no two
edges share an endvertex.
• A matching is maximal if no matching M’
exists such that M  M’.

• The size of a matching
is a lower bound on the
size of an optimal
solution to Vertex
Cover!

An Approximation Algorithm
for Vertex Cover

• Algorithm: Find a maximal matching M
and output the set S of matched vertices

An Approximation Algorithm
for Vertex Cover
• Theorem: The previous algorithm is a
2-approximation algorithm for Vertex Cover
• Proof:
• S is a vertex cover, otherwhise the
matching would not be maximal.
• OPT≥M, where M is the size of the output
maximal matching.
• SOL=2M, as the number of matched
vertices is twice the size of the matching.

Approximation Algorithms:much more…
• Approximation schemes: (1+ε)-approx.
• Inapproximability results.
• Complexity classes, e.g., APX.

Fixed-Parameter Tractable Algorithms

Easy or Hard?
Problem (optimization): Let G be a graph.
Which is the minimum number of vertices
whose deletion makes G planar?

NP-hard 
[Lewis-Yannakakis ]

Easy or Hard?
Problem (decision): Let G be a graph and k
be an integer. Is there a set of k vertices
whose deletion makes G planar?
Polynomial 
• Easy O(nk+1) time algorithm for solving the problem:
• Consider every set of k vertices. Remove such
vertices. Test the planarity of the resulting graph.

• There are O(nk) such sets. Testing the planarity of
an n-vertex graph takes O(n) time. Then,
T(n,k)= O(nk) O(n) = O(nk+1)

Easy or Hard?
Where is the trick?
In the decision version, k is a constant
parameter part of the input
An O(nk+1)-time algorithm, with k constant, is a
polynomial-time algorithm.

But it is very slow 

Fixed-Parameter Tractability
A problem is fixed-parameter tractable
if it can be solved in f(k) nO(1) time,
where k is a parameter of the problem,
f is an arbitrary function, and nO(1) is a
polynomial (not depending on k).

FPT algorithm for Vertex Cover
Theorem [Melhorn]: There is an O(2k n)time algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• There is a vertex cover with k=0 if and only if G
has no edge.
• Consider any edge e=(u,v). Either u or v belongs
to any vertex cover S.
• Consider both the case in which u S and the
case in which v S.

FPT algorithm for Vertex Cover
u

u

v

v

• u  S -> S is a vertex cover of G if and only if
S-{u} is a vertex cover of G-{u} -> solve the
instance (G-{u}, k-1)
• v  S -> S is a vertex cover of G if and only if
S-{v} is a vertex cover of G-{v} -> solve the
instance (G-{v}, k-1)

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• T(n,0) = O(n)
• T(n,k) = 2 T(n-1, k-1) +O(n) ≤ 2 T(n, k-1) +O(n) ≤
2 (2 T(n, k-2) +O(n)) +O(n) ≤
2 (2 (2 T(n, k-3) +O(n)) +O(n)) +O(n) ≤
2 (2 (2 (…(2 T(n, 0)+O(n)) + … +O(n))
+O(n)) +O(n) ≤
2k O(n) + (2k-1 + 2k-2 + 2k-3 + ... + 1) O(n) =
2k O(n) + (2k - 1) O(n) = O(2k n)

Reduction Rules
Reduction rule : a rule (that is, a polynomial time
algorithm) that transforms an instance (I,k) to
an "equivalent and simpler” instance (I', k’).

Equivalent: (I,k) is a YES instance if and only if
(I', k') is a YES instance.
Simpler: |I'|<|I| or k'occurrences of a particular substructure.

Another FPT algorithm for Vertex Cover
Theorem: There is an O(1.6181k n2)-time
algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• We apply the following two reduction rules:
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k).
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u,N(u)},k-1).

Another FPT algorithm for Vertex Cover
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k). Correctness: if S is a vertex
cover of G and u is in S, then S-{u} is also a
vertex cover of G, as u has no incident edge.
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u, N(u)},k-1). Correctness: if S is a
vertex cover of G and u is in S, then
S-{u}  N(u) is also a vertex cover of G, as u
has no other incident edge.

Another FPT algorithm for Vertex Cover
• If neither of the two rules can be applied,
then every vertex has degree at least 2.
• Pick a vertex u. Any vertex cover of G
contains either u or N(u). Thus, (G,k) is a YES
instance if and only if (G-{u},k-1) or
(G-N(u),k-|N(u)|) is.

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• Since |N(u)|\geq 2,
• T(n,k) ≤ T(n,k-1)+ T(n,k-2)+O(n^2).
• Fibonacci series: every number is the sum of
the previous two xk =xk-1 +xk-2 +c.

• The k-th number of the Fibonacci series
tends to the golden ratio to the power of k.
• T(n,k)=Φk O(n2)=((1+√5)/2)k O(n2) =
O(1.6181k n2).

Kernelization
• Sometimes the reduction rules work till the size
of the problem is reduced really a lot. That is,
after the reduction rules have been applied,
the problem has size g(k), for some function k.
In this case the problem has a g(k)-kernel.

• Kernel: given a problem and an instance (I,k), a
kernel is an algorithm that outputs in polynomial
time an instance (I',k') such that (a) (I',k') is a
YES instance if and only if (I,k) is; (b) |I'|and k'
Kernelization
• Theorem [Niedermaier]: Every fixed-parameter
tractable problem has a g(k)-kernel.
• Proof: Suppose that there exists a FPT
algorithm with running time f(k) nc, for some
function f and some constant c. Consider an
instance (I,k) with |I|=n.
• If n>f(k), we run the decision algorithm in time
f(k) nc < nc+1. If it returns YES (NO), the
kernelization algorithm outputs a constant size
YES (resp. NO) instance.
• If n≤f(k), the the kernelization algorithm
returns (I,k).

Kernelization
• The last theorem implies that every problem
that is FPT has a kernel.
• However, the goal is to obtain kernels that are
"small", that is, polynomial in k, or even constant.

FPT: much more…
• Some problems are not FPT (e.g., graph coloring).
• Complexity classes: W[1] -> Can a nondeterministic Turing machine accept an unary
string s in at most k steps?
• Independent Set is W[1]-hard.
• Reductions to W[1]-hard problems give new
W[1]-hard problems.
• Lower bounds for FPT tractability
• Upper and lower bounds for the size of the
kernels

FPT: much more…
• Theorem [Robertson and Seymour]: Every graph
problem with parameter k whose YES istances
are closed under taking minors can be solved in
O(f(k) n3)


Slide 13

Tecniche Algoritmiche per Grafi e Reti
Fabrizio Frati

Dipartimento di Informatica e Automazione
Università degli Studi Roma Tre

• 3 CREDITI
• I° periodo:
• Lunedì 9:45-11:15 aula N13

• II° periodo:
• Venerdì 8:00-9:45 aula N7

• Contatti:
• {angelini,gdb,frati,ratm} @dia.uniroma3.it
• Ricevimento: mercoledì dalle 17 alle 19

• Struttura del Corso
• ~ 8 seminari
• algoritmi, strutture dati, combinatorica,
graph drawing…

• progetti a gruppi di 2 - 4 persone
• problema di ricerca

• Materiale Didattico
• slides
• G. Di Battista, P. Eades, R. Tamassia, I. G.
Tollis, Graph Drawing: Algorithms for the
Visualization of Graphs, 1999. Prentice Hall.

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
C. Computer System Organization
1.
2.
3.
4.
5.

Processor Architectures
Computer-Communication Networks
Application-Based Systems
Performance of Systems
Computer System Implementations

ACM Computing Classification System
C. Computer System Organization
2. Computer-Communication Networks
2.1 Network Architectures
2.2 Network Protocols
2.3 Network Operations
2.4 Distributed Systems
2.5 LAN & WAN
2.6 Internetworking

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
E. Data
1.
2.
3.
4.
5.

Data Structures
Data Storage Representations
Data Encryption
Coding and Information Theory
Files

ACM Computing Classification System
E. Data
1. Data Structures
1.1 Arrays
1.2 Distributed Data Structures
1.3 Graphs and Networks
1.4 Lists, Stacks, and Queues
1.5 Records
1.6 Tables
1.7 Trees

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
F. Theory of Computation
1.
2.
3.
4.

Computation by Abstract Devices
Analysis of Algorithms and Problem Complexity
Logics and Meanings of Programs
Mathematical Logic and Formal Languages

ACM Computing Classification System
F. Theory of Computation
1. Computation by Abstract Devices
1.1 Models of Computation
1.2 Complexity Measures and Completeness
1.2.1 Complexity Hierarchies
1.2.2 Machine-Independent Complexity
1.2.3 Reducibility and Completeness
1.2.4 Relations among Complexity Classes

ACM Computing Classification System
F. Theory of Computation
2. Analysis of Algorithms and Problem Complexity
2.1 Numerical Algorithms
2.2 Non-numerical Algorithms and Problems
2.2.1 Complexity of Proof Procedures
2.2.2 Computations on Discrete Structures
2.2.3 Geometrical Problems
2.2.4 Pattern Matching
2.2.5 Routing and Layout
2.2.6 Sequencing and Scheduling
2.2.7 Sorting and Searching

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
G. Mathematics of Computing
1.
2.
3.
4.

Numerical Analysis
Discrete Mathematics
Probability and Statistics
Mathematical Software

ACM Computing Classification System
G. Mathematics of Computing
2. Discrete Mathematics
2.1 Combinatorics

2.1.1 Combinatorial Algorithms
2.1.2 Counting Problems
2.1.3 Generating Functions
2.1.4 Permutations and Combinations
2.1.5 Recurrences and Difference Equations

2.2 Graph Theory
2.2.1 Graph Algorithms
2.2.2 Graph Labeling

2.2.5 Path and Circuit Problems
2.2.6 Trees

2.3 Applications

a world FULL of NP-hard problems
Problem: I want to travel among a set of
cities driving the fewest possible number
of KMs. IT’S DIFFICULT!!

Problem: I want to put a set of objects
into some bags, knowing that each bag
can not afford more than 10 KGs and
trying to use as few bags as possible.
IT’S DIFFICULT!!

How to Deal with NP-hard problems?
• Exact Algorithms
• Randomized Algorithms
• Approximation Algorithms
• Fixed-Parameter Tractable Algorithms
• …

Approximation Algorithms

Approximation Algorithms
• We want a solution “close” to the
optimal one.
• Given a minimization problem Π, an
algorithm is an α-approximation for Π if,
for every instance I of Π, it outputs a
solution SOL(I) such that
SOL(I)/OPT(I) ≤ α

Vertex Cover
• Problem: Given a graph G(V,E), find a
minimum vertex cover, that is, a set V’  V
such that every edge e  E has an
endvertex in V’.

NP-hard 
[Karp]

How to Guarantee an Approximation?
• We want an approximation algorithm
for Vertex Cover.
• The cost of the solution produced by the
algorithm should be compared with the
cost of an optimal solution.

• But computing the cost of an optimal
solution is NP-HARD!!
LOWER BOUNDS!

Lower Bound for Vertex Cover
• Given a graph G(V,E), a matching M is
a set of edges M  E such that no two
edges share an endvertex.
• A matching is maximal if no matching M’
exists such that M  M’.

• The size of a matching
is a lower bound on the
size of an optimal
solution to Vertex
Cover!

An Approximation Algorithm
for Vertex Cover

• Algorithm: Find a maximal matching M
and output the set S of matched vertices

An Approximation Algorithm
for Vertex Cover
• Theorem: The previous algorithm is a
2-approximation algorithm for Vertex Cover
• Proof:
• S is a vertex cover, otherwhise the
matching would not be maximal.
• OPT≥M, where M is the size of the output
maximal matching.
• SOL=2M, as the number of matched
vertices is twice the size of the matching.

Approximation Algorithms:much more…
• Approximation schemes: (1+ε)-approx.
• Inapproximability results.
• Complexity classes, e.g., APX.

Fixed-Parameter Tractable Algorithms

Easy or Hard?
Problem (optimization): Let G be a graph.
Which is the minimum number of vertices
whose deletion makes G planar?

NP-hard 
[Lewis-Yannakakis ]

Easy or Hard?
Problem (decision): Let G be a graph and k
be an integer. Is there a set of k vertices
whose deletion makes G planar?
Polynomial 
• Easy O(nk+1) time algorithm for solving the problem:
• Consider every set of k vertices. Remove such
vertices. Test the planarity of the resulting graph.

• There are O(nk) such sets. Testing the planarity of
an n-vertex graph takes O(n) time. Then,
T(n,k)= O(nk) O(n) = O(nk+1)

Easy or Hard?
Where is the trick?
In the decision version, k is a constant
parameter part of the input
An O(nk+1)-time algorithm, with k constant, is a
polynomial-time algorithm.

But it is very slow 

Fixed-Parameter Tractability
A problem is fixed-parameter tractable
if it can be solved in f(k) nO(1) time,
where k is a parameter of the problem,
f is an arbitrary function, and nO(1) is a
polynomial (not depending on k).

FPT algorithm for Vertex Cover
Theorem [Melhorn]: There is an O(2k n)time algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• There is a vertex cover with k=0 if and only if G
has no edge.
• Consider any edge e=(u,v). Either u or v belongs
to any vertex cover S.
• Consider both the case in which u S and the
case in which v S.

FPT algorithm for Vertex Cover
u

u

v

v

• u  S -> S is a vertex cover of G if and only if
S-{u} is a vertex cover of G-{u} -> solve the
instance (G-{u}, k-1)
• v  S -> S is a vertex cover of G if and only if
S-{v} is a vertex cover of G-{v} -> solve the
instance (G-{v}, k-1)

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• T(n,0) = O(n)
• T(n,k) = 2 T(n-1, k-1) +O(n) ≤ 2 T(n, k-1) +O(n) ≤
2 (2 T(n, k-2) +O(n)) +O(n) ≤
2 (2 (2 T(n, k-3) +O(n)) +O(n)) +O(n) ≤
2 (2 (2 (…(2 T(n, 0)+O(n)) + … +O(n))
+O(n)) +O(n) ≤
2k O(n) + (2k-1 + 2k-2 + 2k-3 + ... + 1) O(n) =
2k O(n) + (2k - 1) O(n) = O(2k n)

Reduction Rules
Reduction rule : a rule (that is, a polynomial time
algorithm) that transforms an instance (I,k) to
an "equivalent and simpler” instance (I', k’).

Equivalent: (I,k) is a YES instance if and only if
(I', k') is a YES instance.
Simpler: |I'|<|I| or k'occurrences of a particular substructure.

Another FPT algorithm for Vertex Cover
Theorem: There is an O(1.6181k n2)-time
algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• We apply the following two reduction rules:
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k).
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u,N(u)},k-1).

Another FPT algorithm for Vertex Cover
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k). Correctness: if S is a vertex
cover of G and u is in S, then S-{u} is also a
vertex cover of G, as u has no incident edge.
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u, N(u)},k-1). Correctness: if S is a
vertex cover of G and u is in S, then
S-{u}  N(u) is also a vertex cover of G, as u
has no other incident edge.

Another FPT algorithm for Vertex Cover
• If neither of the two rules can be applied,
then every vertex has degree at least 2.
• Pick a vertex u. Any vertex cover of G
contains either u or N(u). Thus, (G,k) is a YES
instance if and only if (G-{u},k-1) or
(G-N(u),k-|N(u)|) is.

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• Since |N(u)|\geq 2,
• T(n,k) ≤ T(n,k-1)+ T(n,k-2)+O(n^2).
• Fibonacci series: every number is the sum of
the previous two xk =xk-1 +xk-2 +c.

• The k-th number of the Fibonacci series
tends to the golden ratio to the power of k.
• T(n,k)=Φk O(n2)=((1+√5)/2)k O(n2) =
O(1.6181k n2).

Kernelization
• Sometimes the reduction rules work till the size
of the problem is reduced really a lot. That is,
after the reduction rules have been applied,
the problem has size g(k), for some function k.
In this case the problem has a g(k)-kernel.

• Kernel: given a problem and an instance (I,k), a
kernel is an algorithm that outputs in polynomial
time an instance (I',k') such that (a) (I',k') is a
YES instance if and only if (I,k) is; (b) |I'|and k'
Kernelization
• Theorem [Niedermaier]: Every fixed-parameter
tractable problem has a g(k)-kernel.
• Proof: Suppose that there exists a FPT
algorithm with running time f(k) nc, for some
function f and some constant c. Consider an
instance (I,k) with |I|=n.
• If n>f(k), we run the decision algorithm in time
f(k) nc < nc+1. If it returns YES (NO), the
kernelization algorithm outputs a constant size
YES (resp. NO) instance.
• If n≤f(k), the the kernelization algorithm
returns (I,k).

Kernelization
• The last theorem implies that every problem
that is FPT has a kernel.
• However, the goal is to obtain kernels that are
"small", that is, polynomial in k, or even constant.

FPT: much more…
• Some problems are not FPT (e.g., graph coloring).
• Complexity classes: W[1] -> Can a nondeterministic Turing machine accept an unary
string s in at most k steps?
• Independent Set is W[1]-hard.
• Reductions to W[1]-hard problems give new
W[1]-hard problems.
• Lower bounds for FPT tractability
• Upper and lower bounds for the size of the
kernels

FPT: much more…
• Theorem [Robertson and Seymour]: Every graph
problem with parameter k whose YES istances
are closed under taking minors can be solved in
O(f(k) n3)


Slide 14

Tecniche Algoritmiche per Grafi e Reti
Fabrizio Frati

Dipartimento di Informatica e Automazione
Università degli Studi Roma Tre

• 3 CREDITI
• I° periodo:
• Lunedì 9:45-11:15 aula N13

• II° periodo:
• Venerdì 8:00-9:45 aula N7

• Contatti:
• {angelini,gdb,frati,ratm} @dia.uniroma3.it
• Ricevimento: mercoledì dalle 17 alle 19

• Struttura del Corso
• ~ 8 seminari
• algoritmi, strutture dati, combinatorica,
graph drawing…

• progetti a gruppi di 2 - 4 persone
• problema di ricerca

• Materiale Didattico
• slides
• G. Di Battista, P. Eades, R. Tamassia, I. G.
Tollis, Graph Drawing: Algorithms for the
Visualization of Graphs, 1999. Prentice Hall.

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
C. Computer System Organization
1.
2.
3.
4.
5.

Processor Architectures
Computer-Communication Networks
Application-Based Systems
Performance of Systems
Computer System Implementations

ACM Computing Classification System
C. Computer System Organization
2. Computer-Communication Networks
2.1 Network Architectures
2.2 Network Protocols
2.3 Network Operations
2.4 Distributed Systems
2.5 LAN & WAN
2.6 Internetworking

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
E. Data
1.
2.
3.
4.
5.

Data Structures
Data Storage Representations
Data Encryption
Coding and Information Theory
Files

ACM Computing Classification System
E. Data
1. Data Structures
1.1 Arrays
1.2 Distributed Data Structures
1.3 Graphs and Networks
1.4 Lists, Stacks, and Queues
1.5 Records
1.6 Tables
1.7 Trees

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
F. Theory of Computation
1.
2.
3.
4.

Computation by Abstract Devices
Analysis of Algorithms and Problem Complexity
Logics and Meanings of Programs
Mathematical Logic and Formal Languages

ACM Computing Classification System
F. Theory of Computation
1. Computation by Abstract Devices
1.1 Models of Computation
1.2 Complexity Measures and Completeness
1.2.1 Complexity Hierarchies
1.2.2 Machine-Independent Complexity
1.2.3 Reducibility and Completeness
1.2.4 Relations among Complexity Classes

ACM Computing Classification System
F. Theory of Computation
2. Analysis of Algorithms and Problem Complexity
2.1 Numerical Algorithms
2.2 Non-numerical Algorithms and Problems
2.2.1 Complexity of Proof Procedures
2.2.2 Computations on Discrete Structures
2.2.3 Geometrical Problems
2.2.4 Pattern Matching
2.2.5 Routing and Layout
2.2.6 Sequencing and Scheduling
2.2.7 Sorting and Searching

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
G. Mathematics of Computing
1.
2.
3.
4.

Numerical Analysis
Discrete Mathematics
Probability and Statistics
Mathematical Software

ACM Computing Classification System
G. Mathematics of Computing
2. Discrete Mathematics
2.1 Combinatorics

2.1.1 Combinatorial Algorithms
2.1.2 Counting Problems
2.1.3 Generating Functions
2.1.4 Permutations and Combinations
2.1.5 Recurrences and Difference Equations

2.2 Graph Theory
2.2.1 Graph Algorithms
2.2.2 Graph Labeling

2.2.5 Path and Circuit Problems
2.2.6 Trees

2.3 Applications

a world FULL of NP-hard problems
Problem: I want to travel among a set of
cities driving the fewest possible number
of KMs. IT’S DIFFICULT!!

Problem: I want to put a set of objects
into some bags, knowing that each bag
can not afford more than 10 KGs and
trying to use as few bags as possible.
IT’S DIFFICULT!!

How to Deal with NP-hard problems?
• Exact Algorithms
• Randomized Algorithms
• Approximation Algorithms
• Fixed-Parameter Tractable Algorithms
• …

Approximation Algorithms

Approximation Algorithms
• We want a solution “close” to the
optimal one.
• Given a minimization problem Π, an
algorithm is an α-approximation for Π if,
for every instance I of Π, it outputs a
solution SOL(I) such that
SOL(I)/OPT(I) ≤ α

Vertex Cover
• Problem: Given a graph G(V,E), find a
minimum vertex cover, that is, a set V’  V
such that every edge e  E has an
endvertex in V’.

NP-hard 
[Karp]

How to Guarantee an Approximation?
• We want an approximation algorithm
for Vertex Cover.
• The cost of the solution produced by the
algorithm should be compared with the
cost of an optimal solution.

• But computing the cost of an optimal
solution is NP-HARD!!
LOWER BOUNDS!

Lower Bound for Vertex Cover
• Given a graph G(V,E), a matching M is
a set of edges M  E such that no two
edges share an endvertex.
• A matching is maximal if no matching M’
exists such that M  M’.

• The size of a matching
is a lower bound on the
size of an optimal
solution to Vertex
Cover!

An Approximation Algorithm
for Vertex Cover

• Algorithm: Find a maximal matching M
and output the set S of matched vertices

An Approximation Algorithm
for Vertex Cover
• Theorem: The previous algorithm is a
2-approximation algorithm for Vertex Cover
• Proof:
• S is a vertex cover, otherwhise the
matching would not be maximal.
• OPT≥M, where M is the size of the output
maximal matching.
• SOL=2M, as the number of matched
vertices is twice the size of the matching.

Approximation Algorithms:much more…
• Approximation schemes: (1+ε)-approx.
• Inapproximability results.
• Complexity classes, e.g., APX.

Fixed-Parameter Tractable Algorithms

Easy or Hard?
Problem (optimization): Let G be a graph.
Which is the minimum number of vertices
whose deletion makes G planar?

NP-hard 
[Lewis-Yannakakis ]

Easy or Hard?
Problem (decision): Let G be a graph and k
be an integer. Is there a set of k vertices
whose deletion makes G planar?
Polynomial 
• Easy O(nk+1) time algorithm for solving the problem:
• Consider every set of k vertices. Remove such
vertices. Test the planarity of the resulting graph.

• There are O(nk) such sets. Testing the planarity of
an n-vertex graph takes O(n) time. Then,
T(n,k)= O(nk) O(n) = O(nk+1)

Easy or Hard?
Where is the trick?
In the decision version, k is a constant
parameter part of the input
An O(nk+1)-time algorithm, with k constant, is a
polynomial-time algorithm.

But it is very slow 

Fixed-Parameter Tractability
A problem is fixed-parameter tractable
if it can be solved in f(k) nO(1) time,
where k is a parameter of the problem,
f is an arbitrary function, and nO(1) is a
polynomial (not depending on k).

FPT algorithm for Vertex Cover
Theorem [Melhorn]: There is an O(2k n)time algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• There is a vertex cover with k=0 if and only if G
has no edge.
• Consider any edge e=(u,v). Either u or v belongs
to any vertex cover S.
• Consider both the case in which u S and the
case in which v S.

FPT algorithm for Vertex Cover
u

u

v

v

• u  S -> S is a vertex cover of G if and only if
S-{u} is a vertex cover of G-{u} -> solve the
instance (G-{u}, k-1)
• v  S -> S is a vertex cover of G if and only if
S-{v} is a vertex cover of G-{v} -> solve the
instance (G-{v}, k-1)

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• T(n,0) = O(n)
• T(n,k) = 2 T(n-1, k-1) +O(n) ≤ 2 T(n, k-1) +O(n) ≤
2 (2 T(n, k-2) +O(n)) +O(n) ≤
2 (2 (2 T(n, k-3) +O(n)) +O(n)) +O(n) ≤
2 (2 (2 (…(2 T(n, 0)+O(n)) + … +O(n))
+O(n)) +O(n) ≤
2k O(n) + (2k-1 + 2k-2 + 2k-3 + ... + 1) O(n) =
2k O(n) + (2k - 1) O(n) = O(2k n)

Reduction Rules
Reduction rule : a rule (that is, a polynomial time
algorithm) that transforms an instance (I,k) to
an "equivalent and simpler” instance (I', k’).

Equivalent: (I,k) is a YES instance if and only if
(I', k') is a YES instance.
Simpler: |I'|<|I| or k'occurrences of a particular substructure.

Another FPT algorithm for Vertex Cover
Theorem: There is an O(1.6181k n2)-time
algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• We apply the following two reduction rules:
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k).
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u,N(u)},k-1).

Another FPT algorithm for Vertex Cover
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k). Correctness: if S is a vertex
cover of G and u is in S, then S-{u} is also a
vertex cover of G, as u has no incident edge.
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u, N(u)},k-1). Correctness: if S is a
vertex cover of G and u is in S, then
S-{u}  N(u) is also a vertex cover of G, as u
has no other incident edge.

Another FPT algorithm for Vertex Cover
• If neither of the two rules can be applied,
then every vertex has degree at least 2.
• Pick a vertex u. Any vertex cover of G
contains either u or N(u). Thus, (G,k) is a YES
instance if and only if (G-{u},k-1) or
(G-N(u),k-|N(u)|) is.

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• Since |N(u)|\geq 2,
• T(n,k) ≤ T(n,k-1)+ T(n,k-2)+O(n^2).
• Fibonacci series: every number is the sum of
the previous two xk =xk-1 +xk-2 +c.

• The k-th number of the Fibonacci series
tends to the golden ratio to the power of k.
• T(n,k)=Φk O(n2)=((1+√5)/2)k O(n2) =
O(1.6181k n2).

Kernelization
• Sometimes the reduction rules work till the size
of the problem is reduced really a lot. That is,
after the reduction rules have been applied,
the problem has size g(k), for some function k.
In this case the problem has a g(k)-kernel.

• Kernel: given a problem and an instance (I,k), a
kernel is an algorithm that outputs in polynomial
time an instance (I',k') such that (a) (I',k') is a
YES instance if and only if (I,k) is; (b) |I'|and k'
Kernelization
• Theorem [Niedermaier]: Every fixed-parameter
tractable problem has a g(k)-kernel.
• Proof: Suppose that there exists a FPT
algorithm with running time f(k) nc, for some
function f and some constant c. Consider an
instance (I,k) with |I|=n.
• If n>f(k), we run the decision algorithm in time
f(k) nc < nc+1. If it returns YES (NO), the
kernelization algorithm outputs a constant size
YES (resp. NO) instance.
• If n≤f(k), the the kernelization algorithm
returns (I,k).

Kernelization
• The last theorem implies that every problem
that is FPT has a kernel.
• However, the goal is to obtain kernels that are
"small", that is, polynomial in k, or even constant.

FPT: much more…
• Some problems are not FPT (e.g., graph coloring).
• Complexity classes: W[1] -> Can a nondeterministic Turing machine accept an unary
string s in at most k steps?
• Independent Set is W[1]-hard.
• Reductions to W[1]-hard problems give new
W[1]-hard problems.
• Lower bounds for FPT tractability
• Upper and lower bounds for the size of the
kernels

FPT: much more…
• Theorem [Robertson and Seymour]: Every graph
problem with parameter k whose YES istances
are closed under taking minors can be solved in
O(f(k) n3)


Slide 15

Tecniche Algoritmiche per Grafi e Reti
Fabrizio Frati

Dipartimento di Informatica e Automazione
Università degli Studi Roma Tre

• 3 CREDITI
• I° periodo:
• Lunedì 9:45-11:15 aula N13

• II° periodo:
• Venerdì 8:00-9:45 aula N7

• Contatti:
• {angelini,gdb,frati,ratm} @dia.uniroma3.it
• Ricevimento: mercoledì dalle 17 alle 19

• Struttura del Corso
• ~ 8 seminari
• algoritmi, strutture dati, combinatorica,
graph drawing…

• progetti a gruppi di 2 - 4 persone
• problema di ricerca

• Materiale Didattico
• slides
• G. Di Battista, P. Eades, R. Tamassia, I. G.
Tollis, Graph Drawing: Algorithms for the
Visualization of Graphs, 1999. Prentice Hall.

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
C. Computer System Organization
1.
2.
3.
4.
5.

Processor Architectures
Computer-Communication Networks
Application-Based Systems
Performance of Systems
Computer System Implementations

ACM Computing Classification System
C. Computer System Organization
2. Computer-Communication Networks
2.1 Network Architectures
2.2 Network Protocols
2.3 Network Operations
2.4 Distributed Systems
2.5 LAN & WAN
2.6 Internetworking

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
E. Data
1.
2.
3.
4.
5.

Data Structures
Data Storage Representations
Data Encryption
Coding and Information Theory
Files

ACM Computing Classification System
E. Data
1. Data Structures
1.1 Arrays
1.2 Distributed Data Structures
1.3 Graphs and Networks
1.4 Lists, Stacks, and Queues
1.5 Records
1.6 Tables
1.7 Trees

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
F. Theory of Computation
1.
2.
3.
4.

Computation by Abstract Devices
Analysis of Algorithms and Problem Complexity
Logics and Meanings of Programs
Mathematical Logic and Formal Languages

ACM Computing Classification System
F. Theory of Computation
1. Computation by Abstract Devices
1.1 Models of Computation
1.2 Complexity Measures and Completeness
1.2.1 Complexity Hierarchies
1.2.2 Machine-Independent Complexity
1.2.3 Reducibility and Completeness
1.2.4 Relations among Complexity Classes

ACM Computing Classification System
F. Theory of Computation
2. Analysis of Algorithms and Problem Complexity
2.1 Numerical Algorithms
2.2 Non-numerical Algorithms and Problems
2.2.1 Complexity of Proof Procedures
2.2.2 Computations on Discrete Structures
2.2.3 Geometrical Problems
2.2.4 Pattern Matching
2.2.5 Routing and Layout
2.2.6 Sequencing and Scheduling
2.2.7 Sorting and Searching

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
G. Mathematics of Computing
1.
2.
3.
4.

Numerical Analysis
Discrete Mathematics
Probability and Statistics
Mathematical Software

ACM Computing Classification System
G. Mathematics of Computing
2. Discrete Mathematics
2.1 Combinatorics

2.1.1 Combinatorial Algorithms
2.1.2 Counting Problems
2.1.3 Generating Functions
2.1.4 Permutations and Combinations
2.1.5 Recurrences and Difference Equations

2.2 Graph Theory
2.2.1 Graph Algorithms
2.2.2 Graph Labeling

2.2.5 Path and Circuit Problems
2.2.6 Trees

2.3 Applications

a world FULL of NP-hard problems
Problem: I want to travel among a set of
cities driving the fewest possible number
of KMs. IT’S DIFFICULT!!

Problem: I want to put a set of objects
into some bags, knowing that each bag
can not afford more than 10 KGs and
trying to use as few bags as possible.
IT’S DIFFICULT!!

How to Deal with NP-hard problems?
• Exact Algorithms
• Randomized Algorithms
• Approximation Algorithms
• Fixed-Parameter Tractable Algorithms
• …

Approximation Algorithms

Approximation Algorithms
• We want a solution “close” to the
optimal one.
• Given a minimization problem Π, an
algorithm is an α-approximation for Π if,
for every instance I of Π, it outputs a
solution SOL(I) such that
SOL(I)/OPT(I) ≤ α

Vertex Cover
• Problem: Given a graph G(V,E), find a
minimum vertex cover, that is, a set V’  V
such that every edge e  E has an
endvertex in V’.

NP-hard 
[Karp]

How to Guarantee an Approximation?
• We want an approximation algorithm
for Vertex Cover.
• The cost of the solution produced by the
algorithm should be compared with the
cost of an optimal solution.

• But computing the cost of an optimal
solution is NP-HARD!!
LOWER BOUNDS!

Lower Bound for Vertex Cover
• Given a graph G(V,E), a matching M is
a set of edges M  E such that no two
edges share an endvertex.
• A matching is maximal if no matching M’
exists such that M  M’.

• The size of a matching
is a lower bound on the
size of an optimal
solution to Vertex
Cover!

An Approximation Algorithm
for Vertex Cover

• Algorithm: Find a maximal matching M
and output the set S of matched vertices

An Approximation Algorithm
for Vertex Cover
• Theorem: The previous algorithm is a
2-approximation algorithm for Vertex Cover
• Proof:
• S is a vertex cover, otherwhise the
matching would not be maximal.
• OPT≥M, where M is the size of the output
maximal matching.
• SOL=2M, as the number of matched
vertices is twice the size of the matching.

Approximation Algorithms:much more…
• Approximation schemes: (1+ε)-approx.
• Inapproximability results.
• Complexity classes, e.g., APX.

Fixed-Parameter Tractable Algorithms

Easy or Hard?
Problem (optimization): Let G be a graph.
Which is the minimum number of vertices
whose deletion makes G planar?

NP-hard 
[Lewis-Yannakakis ]

Easy or Hard?
Problem (decision): Let G be a graph and k
be an integer. Is there a set of k vertices
whose deletion makes G planar?
Polynomial 
• Easy O(nk+1) time algorithm for solving the problem:
• Consider every set of k vertices. Remove such
vertices. Test the planarity of the resulting graph.

• There are O(nk) such sets. Testing the planarity of
an n-vertex graph takes O(n) time. Then,
T(n,k)= O(nk) O(n) = O(nk+1)

Easy or Hard?
Where is the trick?
In the decision version, k is a constant
parameter part of the input
An O(nk+1)-time algorithm, with k constant, is a
polynomial-time algorithm.

But it is very slow 

Fixed-Parameter Tractability
A problem is fixed-parameter tractable
if it can be solved in f(k) nO(1) time,
where k is a parameter of the problem,
f is an arbitrary function, and nO(1) is a
polynomial (not depending on k).

FPT algorithm for Vertex Cover
Theorem [Melhorn]: There is an O(2k n)time algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• There is a vertex cover with k=0 if and only if G
has no edge.
• Consider any edge e=(u,v). Either u or v belongs
to any vertex cover S.
• Consider both the case in which u S and the
case in which v S.

FPT algorithm for Vertex Cover
u

u

v

v

• u  S -> S is a vertex cover of G if and only if
S-{u} is a vertex cover of G-{u} -> solve the
instance (G-{u}, k-1)
• v  S -> S is a vertex cover of G if and only if
S-{v} is a vertex cover of G-{v} -> solve the
instance (G-{v}, k-1)

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• T(n,0) = O(n)
• T(n,k) = 2 T(n-1, k-1) +O(n) ≤ 2 T(n, k-1) +O(n) ≤
2 (2 T(n, k-2) +O(n)) +O(n) ≤
2 (2 (2 T(n, k-3) +O(n)) +O(n)) +O(n) ≤
2 (2 (2 (…(2 T(n, 0)+O(n)) + … +O(n))
+O(n)) +O(n) ≤
2k O(n) + (2k-1 + 2k-2 + 2k-3 + ... + 1) O(n) =
2k O(n) + (2k - 1) O(n) = O(2k n)

Reduction Rules
Reduction rule : a rule (that is, a polynomial time
algorithm) that transforms an instance (I,k) to
an "equivalent and simpler” instance (I', k’).

Equivalent: (I,k) is a YES instance if and only if
(I', k') is a YES instance.
Simpler: |I'|<|I| or k'occurrences of a particular substructure.

Another FPT algorithm for Vertex Cover
Theorem: There is an O(1.6181k n2)-time
algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• We apply the following two reduction rules:
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k).
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u,N(u)},k-1).

Another FPT algorithm for Vertex Cover
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k). Correctness: if S is a vertex
cover of G and u is in S, then S-{u} is also a
vertex cover of G, as u has no incident edge.
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u, N(u)},k-1). Correctness: if S is a
vertex cover of G and u is in S, then
S-{u}  N(u) is also a vertex cover of G, as u
has no other incident edge.

Another FPT algorithm for Vertex Cover
• If neither of the two rules can be applied,
then every vertex has degree at least 2.
• Pick a vertex u. Any vertex cover of G
contains either u or N(u). Thus, (G,k) is a YES
instance if and only if (G-{u},k-1) or
(G-N(u),k-|N(u)|) is.

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• Since |N(u)|\geq 2,
• T(n,k) ≤ T(n,k-1)+ T(n,k-2)+O(n^2).
• Fibonacci series: every number is the sum of
the previous two xk =xk-1 +xk-2 +c.

• The k-th number of the Fibonacci series
tends to the golden ratio to the power of k.
• T(n,k)=Φk O(n2)=((1+√5)/2)k O(n2) =
O(1.6181k n2).

Kernelization
• Sometimes the reduction rules work till the size
of the problem is reduced really a lot. That is,
after the reduction rules have been applied,
the problem has size g(k), for some function k.
In this case the problem has a g(k)-kernel.

• Kernel: given a problem and an instance (I,k), a
kernel is an algorithm that outputs in polynomial
time an instance (I',k') such that (a) (I',k') is a
YES instance if and only if (I,k) is; (b) |I'|and k'
Kernelization
• Theorem [Niedermaier]: Every fixed-parameter
tractable problem has a g(k)-kernel.
• Proof: Suppose that there exists a FPT
algorithm with running time f(k) nc, for some
function f and some constant c. Consider an
instance (I,k) with |I|=n.
• If n>f(k), we run the decision algorithm in time
f(k) nc < nc+1. If it returns YES (NO), the
kernelization algorithm outputs a constant size
YES (resp. NO) instance.
• If n≤f(k), the the kernelization algorithm
returns (I,k).

Kernelization
• The last theorem implies that every problem
that is FPT has a kernel.
• However, the goal is to obtain kernels that are
"small", that is, polynomial in k, or even constant.

FPT: much more…
• Some problems are not FPT (e.g., graph coloring).
• Complexity classes: W[1] -> Can a nondeterministic Turing machine accept an unary
string s in at most k steps?
• Independent Set is W[1]-hard.
• Reductions to W[1]-hard problems give new
W[1]-hard problems.
• Lower bounds for FPT tractability
• Upper and lower bounds for the size of the
kernels

FPT: much more…
• Theorem [Robertson and Seymour]: Every graph
problem with parameter k whose YES istances
are closed under taking minors can be solved in
O(f(k) n3)


Slide 16

Tecniche Algoritmiche per Grafi e Reti
Fabrizio Frati

Dipartimento di Informatica e Automazione
Università degli Studi Roma Tre

• 3 CREDITI
• I° periodo:
• Lunedì 9:45-11:15 aula N13

• II° periodo:
• Venerdì 8:00-9:45 aula N7

• Contatti:
• {angelini,gdb,frati,ratm} @dia.uniroma3.it
• Ricevimento: mercoledì dalle 17 alle 19

• Struttura del Corso
• ~ 8 seminari
• algoritmi, strutture dati, combinatorica,
graph drawing…

• progetti a gruppi di 2 - 4 persone
• problema di ricerca

• Materiale Didattico
• slides
• G. Di Battista, P. Eades, R. Tamassia, I. G.
Tollis, Graph Drawing: Algorithms for the
Visualization of Graphs, 1999. Prentice Hall.

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
C. Computer System Organization
1.
2.
3.
4.
5.

Processor Architectures
Computer-Communication Networks
Application-Based Systems
Performance of Systems
Computer System Implementations

ACM Computing Classification System
C. Computer System Organization
2. Computer-Communication Networks
2.1 Network Architectures
2.2 Network Protocols
2.3 Network Operations
2.4 Distributed Systems
2.5 LAN & WAN
2.6 Internetworking

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
E. Data
1.
2.
3.
4.
5.

Data Structures
Data Storage Representations
Data Encryption
Coding and Information Theory
Files

ACM Computing Classification System
E. Data
1. Data Structures
1.1 Arrays
1.2 Distributed Data Structures
1.3 Graphs and Networks
1.4 Lists, Stacks, and Queues
1.5 Records
1.6 Tables
1.7 Trees

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
F. Theory of Computation
1.
2.
3.
4.

Computation by Abstract Devices
Analysis of Algorithms and Problem Complexity
Logics and Meanings of Programs
Mathematical Logic and Formal Languages

ACM Computing Classification System
F. Theory of Computation
1. Computation by Abstract Devices
1.1 Models of Computation
1.2 Complexity Measures and Completeness
1.2.1 Complexity Hierarchies
1.2.2 Machine-Independent Complexity
1.2.3 Reducibility and Completeness
1.2.4 Relations among Complexity Classes

ACM Computing Classification System
F. Theory of Computation
2. Analysis of Algorithms and Problem Complexity
2.1 Numerical Algorithms
2.2 Non-numerical Algorithms and Problems
2.2.1 Complexity of Proof Procedures
2.2.2 Computations on Discrete Structures
2.2.3 Geometrical Problems
2.2.4 Pattern Matching
2.2.5 Routing and Layout
2.2.6 Sequencing and Scheduling
2.2.7 Sorting and Searching

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
G. Mathematics of Computing
1.
2.
3.
4.

Numerical Analysis
Discrete Mathematics
Probability and Statistics
Mathematical Software

ACM Computing Classification System
G. Mathematics of Computing
2. Discrete Mathematics
2.1 Combinatorics

2.1.1 Combinatorial Algorithms
2.1.2 Counting Problems
2.1.3 Generating Functions
2.1.4 Permutations and Combinations
2.1.5 Recurrences and Difference Equations

2.2 Graph Theory
2.2.1 Graph Algorithms
2.2.2 Graph Labeling

2.2.5 Path and Circuit Problems
2.2.6 Trees

2.3 Applications

a world FULL of NP-hard problems
Problem: I want to travel among a set of
cities driving the fewest possible number
of KMs. IT’S DIFFICULT!!

Problem: I want to put a set of objects
into some bags, knowing that each bag
can not afford more than 10 KGs and
trying to use as few bags as possible.
IT’S DIFFICULT!!

How to Deal with NP-hard problems?
• Exact Algorithms
• Randomized Algorithms
• Approximation Algorithms
• Fixed-Parameter Tractable Algorithms
• …

Approximation Algorithms

Approximation Algorithms
• We want a solution “close” to the
optimal one.
• Given a minimization problem Π, an
algorithm is an α-approximation for Π if,
for every instance I of Π, it outputs a
solution SOL(I) such that
SOL(I)/OPT(I) ≤ α

Vertex Cover
• Problem: Given a graph G(V,E), find a
minimum vertex cover, that is, a set V’  V
such that every edge e  E has an
endvertex in V’.

NP-hard 
[Karp]

How to Guarantee an Approximation?
• We want an approximation algorithm
for Vertex Cover.
• The cost of the solution produced by the
algorithm should be compared with the
cost of an optimal solution.

• But computing the cost of an optimal
solution is NP-HARD!!
LOWER BOUNDS!

Lower Bound for Vertex Cover
• Given a graph G(V,E), a matching M is
a set of edges M  E such that no two
edges share an endvertex.
• A matching is maximal if no matching M’
exists such that M  M’.

• The size of a matching
is a lower bound on the
size of an optimal
solution to Vertex
Cover!

An Approximation Algorithm
for Vertex Cover

• Algorithm: Find a maximal matching M
and output the set S of matched vertices

An Approximation Algorithm
for Vertex Cover
• Theorem: The previous algorithm is a
2-approximation algorithm for Vertex Cover
• Proof:
• S is a vertex cover, otherwhise the
matching would not be maximal.
• OPT≥M, where M is the size of the output
maximal matching.
• SOL=2M, as the number of matched
vertices is twice the size of the matching.

Approximation Algorithms:much more…
• Approximation schemes: (1+ε)-approx.
• Inapproximability results.
• Complexity classes, e.g., APX.

Fixed-Parameter Tractable Algorithms

Easy or Hard?
Problem (optimization): Let G be a graph.
Which is the minimum number of vertices
whose deletion makes G planar?

NP-hard 
[Lewis-Yannakakis ]

Easy or Hard?
Problem (decision): Let G be a graph and k
be an integer. Is there a set of k vertices
whose deletion makes G planar?
Polynomial 
• Easy O(nk+1) time algorithm for solving the problem:
• Consider every set of k vertices. Remove such
vertices. Test the planarity of the resulting graph.

• There are O(nk) such sets. Testing the planarity of
an n-vertex graph takes O(n) time. Then,
T(n,k)= O(nk) O(n) = O(nk+1)

Easy or Hard?
Where is the trick?
In the decision version, k is a constant
parameter part of the input
An O(nk+1)-time algorithm, with k constant, is a
polynomial-time algorithm.

But it is very slow 

Fixed-Parameter Tractability
A problem is fixed-parameter tractable
if it can be solved in f(k) nO(1) time,
where k is a parameter of the problem,
f is an arbitrary function, and nO(1) is a
polynomial (not depending on k).

FPT algorithm for Vertex Cover
Theorem [Melhorn]: There is an O(2k n)time algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• There is a vertex cover with k=0 if and only if G
has no edge.
• Consider any edge e=(u,v). Either u or v belongs
to any vertex cover S.
• Consider both the case in which u S and the
case in which v S.

FPT algorithm for Vertex Cover
u

u

v

v

• u  S -> S is a vertex cover of G if and only if
S-{u} is a vertex cover of G-{u} -> solve the
instance (G-{u}, k-1)
• v  S -> S is a vertex cover of G if and only if
S-{v} is a vertex cover of G-{v} -> solve the
instance (G-{v}, k-1)

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• T(n,0) = O(n)
• T(n,k) = 2 T(n-1, k-1) +O(n) ≤ 2 T(n, k-1) +O(n) ≤
2 (2 T(n, k-2) +O(n)) +O(n) ≤
2 (2 (2 T(n, k-3) +O(n)) +O(n)) +O(n) ≤
2 (2 (2 (…(2 T(n, 0)+O(n)) + … +O(n))
+O(n)) +O(n) ≤
2k O(n) + (2k-1 + 2k-2 + 2k-3 + ... + 1) O(n) =
2k O(n) + (2k - 1) O(n) = O(2k n)

Reduction Rules
Reduction rule : a rule (that is, a polynomial time
algorithm) that transforms an instance (I,k) to
an "equivalent and simpler” instance (I', k’).

Equivalent: (I,k) is a YES instance if and only if
(I', k') is a YES instance.
Simpler: |I'|<|I| or k'occurrences of a particular substructure.

Another FPT algorithm for Vertex Cover
Theorem: There is an O(1.6181k n2)-time
algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• We apply the following two reduction rules:
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k).
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u,N(u)},k-1).

Another FPT algorithm for Vertex Cover
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k). Correctness: if S is a vertex
cover of G and u is in S, then S-{u} is also a
vertex cover of G, as u has no incident edge.
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u, N(u)},k-1). Correctness: if S is a
vertex cover of G and u is in S, then
S-{u}  N(u) is also a vertex cover of G, as u
has no other incident edge.

Another FPT algorithm for Vertex Cover
• If neither of the two rules can be applied,
then every vertex has degree at least 2.
• Pick a vertex u. Any vertex cover of G
contains either u or N(u). Thus, (G,k) is a YES
instance if and only if (G-{u},k-1) or
(G-N(u),k-|N(u)|) is.

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• Since |N(u)|\geq 2,
• T(n,k) ≤ T(n,k-1)+ T(n,k-2)+O(n^2).
• Fibonacci series: every number is the sum of
the previous two xk =xk-1 +xk-2 +c.

• The k-th number of the Fibonacci series
tends to the golden ratio to the power of k.
• T(n,k)=Φk O(n2)=((1+√5)/2)k O(n2) =
O(1.6181k n2).

Kernelization
• Sometimes the reduction rules work till the size
of the problem is reduced really a lot. That is,
after the reduction rules have been applied,
the problem has size g(k), for some function k.
In this case the problem has a g(k)-kernel.

• Kernel: given a problem and an instance (I,k), a
kernel is an algorithm that outputs in polynomial
time an instance (I',k') such that (a) (I',k') is a
YES instance if and only if (I,k) is; (b) |I'|and k'
Kernelization
• Theorem [Niedermaier]: Every fixed-parameter
tractable problem has a g(k)-kernel.
• Proof: Suppose that there exists a FPT
algorithm with running time f(k) nc, for some
function f and some constant c. Consider an
instance (I,k) with |I|=n.
• If n>f(k), we run the decision algorithm in time
f(k) nc < nc+1. If it returns YES (NO), the
kernelization algorithm outputs a constant size
YES (resp. NO) instance.
• If n≤f(k), the the kernelization algorithm
returns (I,k).

Kernelization
• The last theorem implies that every problem
that is FPT has a kernel.
• However, the goal is to obtain kernels that are
"small", that is, polynomial in k, or even constant.

FPT: much more…
• Some problems are not FPT (e.g., graph coloring).
• Complexity classes: W[1] -> Can a nondeterministic Turing machine accept an unary
string s in at most k steps?
• Independent Set is W[1]-hard.
• Reductions to W[1]-hard problems give new
W[1]-hard problems.
• Lower bounds for FPT tractability
• Upper and lower bounds for the size of the
kernels

FPT: much more…
• Theorem [Robertson and Seymour]: Every graph
problem with parameter k whose YES istances
are closed under taking minors can be solved in
O(f(k) n3)


Slide 17

Tecniche Algoritmiche per Grafi e Reti
Fabrizio Frati

Dipartimento di Informatica e Automazione
Università degli Studi Roma Tre

• 3 CREDITI
• I° periodo:
• Lunedì 9:45-11:15 aula N13

• II° periodo:
• Venerdì 8:00-9:45 aula N7

• Contatti:
• {angelini,gdb,frati,ratm} @dia.uniroma3.it
• Ricevimento: mercoledì dalle 17 alle 19

• Struttura del Corso
• ~ 8 seminari
• algoritmi, strutture dati, combinatorica,
graph drawing…

• progetti a gruppi di 2 - 4 persone
• problema di ricerca

• Materiale Didattico
• slides
• G. Di Battista, P. Eades, R. Tamassia, I. G.
Tollis, Graph Drawing: Algorithms for the
Visualization of Graphs, 1999. Prentice Hall.

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
C. Computer System Organization
1.
2.
3.
4.
5.

Processor Architectures
Computer-Communication Networks
Application-Based Systems
Performance of Systems
Computer System Implementations

ACM Computing Classification System
C. Computer System Organization
2. Computer-Communication Networks
2.1 Network Architectures
2.2 Network Protocols
2.3 Network Operations
2.4 Distributed Systems
2.5 LAN & WAN
2.6 Internetworking

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
E. Data
1.
2.
3.
4.
5.

Data Structures
Data Storage Representations
Data Encryption
Coding and Information Theory
Files

ACM Computing Classification System
E. Data
1. Data Structures
1.1 Arrays
1.2 Distributed Data Structures
1.3 Graphs and Networks
1.4 Lists, Stacks, and Queues
1.5 Records
1.6 Tables
1.7 Trees

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
F. Theory of Computation
1.
2.
3.
4.

Computation by Abstract Devices
Analysis of Algorithms and Problem Complexity
Logics and Meanings of Programs
Mathematical Logic and Formal Languages

ACM Computing Classification System
F. Theory of Computation
1. Computation by Abstract Devices
1.1 Models of Computation
1.2 Complexity Measures and Completeness
1.2.1 Complexity Hierarchies
1.2.2 Machine-Independent Complexity
1.2.3 Reducibility and Completeness
1.2.4 Relations among Complexity Classes

ACM Computing Classification System
F. Theory of Computation
2. Analysis of Algorithms and Problem Complexity
2.1 Numerical Algorithms
2.2 Non-numerical Algorithms and Problems
2.2.1 Complexity of Proof Procedures
2.2.2 Computations on Discrete Structures
2.2.3 Geometrical Problems
2.2.4 Pattern Matching
2.2.5 Routing and Layout
2.2.6 Sequencing and Scheduling
2.2.7 Sorting and Searching

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
G. Mathematics of Computing
1.
2.
3.
4.

Numerical Analysis
Discrete Mathematics
Probability and Statistics
Mathematical Software

ACM Computing Classification System
G. Mathematics of Computing
2. Discrete Mathematics
2.1 Combinatorics

2.1.1 Combinatorial Algorithms
2.1.2 Counting Problems
2.1.3 Generating Functions
2.1.4 Permutations and Combinations
2.1.5 Recurrences and Difference Equations

2.2 Graph Theory
2.2.1 Graph Algorithms
2.2.2 Graph Labeling

2.2.5 Path and Circuit Problems
2.2.6 Trees

2.3 Applications

a world FULL of NP-hard problems
Problem: I want to travel among a set of
cities driving the fewest possible number
of KMs. IT’S DIFFICULT!!

Problem: I want to put a set of objects
into some bags, knowing that each bag
can not afford more than 10 KGs and
trying to use as few bags as possible.
IT’S DIFFICULT!!

How to Deal with NP-hard problems?
• Exact Algorithms
• Randomized Algorithms
• Approximation Algorithms
• Fixed-Parameter Tractable Algorithms
• …

Approximation Algorithms

Approximation Algorithms
• We want a solution “close” to the
optimal one.
• Given a minimization problem Π, an
algorithm is an α-approximation for Π if,
for every instance I of Π, it outputs a
solution SOL(I) such that
SOL(I)/OPT(I) ≤ α

Vertex Cover
• Problem: Given a graph G(V,E), find a
minimum vertex cover, that is, a set V’  V
such that every edge e  E has an
endvertex in V’.

NP-hard 
[Karp]

How to Guarantee an Approximation?
• We want an approximation algorithm
for Vertex Cover.
• The cost of the solution produced by the
algorithm should be compared with the
cost of an optimal solution.

• But computing the cost of an optimal
solution is NP-HARD!!
LOWER BOUNDS!

Lower Bound for Vertex Cover
• Given a graph G(V,E), a matching M is
a set of edges M  E such that no two
edges share an endvertex.
• A matching is maximal if no matching M’
exists such that M  M’.

• The size of a matching
is a lower bound on the
size of an optimal
solution to Vertex
Cover!

An Approximation Algorithm
for Vertex Cover

• Algorithm: Find a maximal matching M
and output the set S of matched vertices

An Approximation Algorithm
for Vertex Cover
• Theorem: The previous algorithm is a
2-approximation algorithm for Vertex Cover
• Proof:
• S is a vertex cover, otherwhise the
matching would not be maximal.
• OPT≥M, where M is the size of the output
maximal matching.
• SOL=2M, as the number of matched
vertices is twice the size of the matching.

Approximation Algorithms:much more…
• Approximation schemes: (1+ε)-approx.
• Inapproximability results.
• Complexity classes, e.g., APX.

Fixed-Parameter Tractable Algorithms

Easy or Hard?
Problem (optimization): Let G be a graph.
Which is the minimum number of vertices
whose deletion makes G planar?

NP-hard 
[Lewis-Yannakakis ]

Easy or Hard?
Problem (decision): Let G be a graph and k
be an integer. Is there a set of k vertices
whose deletion makes G planar?
Polynomial 
• Easy O(nk+1) time algorithm for solving the problem:
• Consider every set of k vertices. Remove such
vertices. Test the planarity of the resulting graph.

• There are O(nk) such sets. Testing the planarity of
an n-vertex graph takes O(n) time. Then,
T(n,k)= O(nk) O(n) = O(nk+1)

Easy or Hard?
Where is the trick?
In the decision version, k is a constant
parameter part of the input
An O(nk+1)-time algorithm, with k constant, is a
polynomial-time algorithm.

But it is very slow 

Fixed-Parameter Tractability
A problem is fixed-parameter tractable
if it can be solved in f(k) nO(1) time,
where k is a parameter of the problem,
f is an arbitrary function, and nO(1) is a
polynomial (not depending on k).

FPT algorithm for Vertex Cover
Theorem [Melhorn]: There is an O(2k n)time algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• There is a vertex cover with k=0 if and only if G
has no edge.
• Consider any edge e=(u,v). Either u or v belongs
to any vertex cover S.
• Consider both the case in which u S and the
case in which v S.

FPT algorithm for Vertex Cover
u

u

v

v

• u  S -> S is a vertex cover of G if and only if
S-{u} is a vertex cover of G-{u} -> solve the
instance (G-{u}, k-1)
• v  S -> S is a vertex cover of G if and only if
S-{v} is a vertex cover of G-{v} -> solve the
instance (G-{v}, k-1)

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• T(n,0) = O(n)
• T(n,k) = 2 T(n-1, k-1) +O(n) ≤ 2 T(n, k-1) +O(n) ≤
2 (2 T(n, k-2) +O(n)) +O(n) ≤
2 (2 (2 T(n, k-3) +O(n)) +O(n)) +O(n) ≤
2 (2 (2 (…(2 T(n, 0)+O(n)) + … +O(n))
+O(n)) +O(n) ≤
2k O(n) + (2k-1 + 2k-2 + 2k-3 + ... + 1) O(n) =
2k O(n) + (2k - 1) O(n) = O(2k n)

Reduction Rules
Reduction rule : a rule (that is, a polynomial time
algorithm) that transforms an instance (I,k) to
an "equivalent and simpler” instance (I', k’).

Equivalent: (I,k) is a YES instance if and only if
(I', k') is a YES instance.
Simpler: |I'|<|I| or k'occurrences of a particular substructure.

Another FPT algorithm for Vertex Cover
Theorem: There is an O(1.6181k n2)-time
algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• We apply the following two reduction rules:
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k).
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u,N(u)},k-1).

Another FPT algorithm for Vertex Cover
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k). Correctness: if S is a vertex
cover of G and u is in S, then S-{u} is also a
vertex cover of G, as u has no incident edge.
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u, N(u)},k-1). Correctness: if S is a
vertex cover of G and u is in S, then
S-{u}  N(u) is also a vertex cover of G, as u
has no other incident edge.

Another FPT algorithm for Vertex Cover
• If neither of the two rules can be applied,
then every vertex has degree at least 2.
• Pick a vertex u. Any vertex cover of G
contains either u or N(u). Thus, (G,k) is a YES
instance if and only if (G-{u},k-1) or
(G-N(u),k-|N(u)|) is.

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• Since |N(u)|\geq 2,
• T(n,k) ≤ T(n,k-1)+ T(n,k-2)+O(n^2).
• Fibonacci series: every number is the sum of
the previous two xk =xk-1 +xk-2 +c.

• The k-th number of the Fibonacci series
tends to the golden ratio to the power of k.
• T(n,k)=Φk O(n2)=((1+√5)/2)k O(n2) =
O(1.6181k n2).

Kernelization
• Sometimes the reduction rules work till the size
of the problem is reduced really a lot. That is,
after the reduction rules have been applied,
the problem has size g(k), for some function k.
In this case the problem has a g(k)-kernel.

• Kernel: given a problem and an instance (I,k), a
kernel is an algorithm that outputs in polynomial
time an instance (I',k') such that (a) (I',k') is a
YES instance if and only if (I,k) is; (b) |I'|and k'
Kernelization
• Theorem [Niedermaier]: Every fixed-parameter
tractable problem has a g(k)-kernel.
• Proof: Suppose that there exists a FPT
algorithm with running time f(k) nc, for some
function f and some constant c. Consider an
instance (I,k) with |I|=n.
• If n>f(k), we run the decision algorithm in time
f(k) nc < nc+1. If it returns YES (NO), the
kernelization algorithm outputs a constant size
YES (resp. NO) instance.
• If n≤f(k), the the kernelization algorithm
returns (I,k).

Kernelization
• The last theorem implies that every problem
that is FPT has a kernel.
• However, the goal is to obtain kernels that are
"small", that is, polynomial in k, or even constant.

FPT: much more…
• Some problems are not FPT (e.g., graph coloring).
• Complexity classes: W[1] -> Can a nondeterministic Turing machine accept an unary
string s in at most k steps?
• Independent Set is W[1]-hard.
• Reductions to W[1]-hard problems give new
W[1]-hard problems.
• Lower bounds for FPT tractability
• Upper and lower bounds for the size of the
kernels

FPT: much more…
• Theorem [Robertson and Seymour]: Every graph
problem with parameter k whose YES istances
are closed under taking minors can be solved in
O(f(k) n3)


Slide 18

Tecniche Algoritmiche per Grafi e Reti
Fabrizio Frati

Dipartimento di Informatica e Automazione
Università degli Studi Roma Tre

• 3 CREDITI
• I° periodo:
• Lunedì 9:45-11:15 aula N13

• II° periodo:
• Venerdì 8:00-9:45 aula N7

• Contatti:
• {angelini,gdb,frati,ratm} @dia.uniroma3.it
• Ricevimento: mercoledì dalle 17 alle 19

• Struttura del Corso
• ~ 8 seminari
• algoritmi, strutture dati, combinatorica,
graph drawing…

• progetti a gruppi di 2 - 4 persone
• problema di ricerca

• Materiale Didattico
• slides
• G. Di Battista, P. Eades, R. Tamassia, I. G.
Tollis, Graph Drawing: Algorithms for the
Visualization of Graphs, 1999. Prentice Hall.

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
C. Computer System Organization
1.
2.
3.
4.
5.

Processor Architectures
Computer-Communication Networks
Application-Based Systems
Performance of Systems
Computer System Implementations

ACM Computing Classification System
C. Computer System Organization
2. Computer-Communication Networks
2.1 Network Architectures
2.2 Network Protocols
2.3 Network Operations
2.4 Distributed Systems
2.5 LAN & WAN
2.6 Internetworking

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
E. Data
1.
2.
3.
4.
5.

Data Structures
Data Storage Representations
Data Encryption
Coding and Information Theory
Files

ACM Computing Classification System
E. Data
1. Data Structures
1.1 Arrays
1.2 Distributed Data Structures
1.3 Graphs and Networks
1.4 Lists, Stacks, and Queues
1.5 Records
1.6 Tables
1.7 Trees

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
F. Theory of Computation
1.
2.
3.
4.

Computation by Abstract Devices
Analysis of Algorithms and Problem Complexity
Logics and Meanings of Programs
Mathematical Logic and Formal Languages

ACM Computing Classification System
F. Theory of Computation
1. Computation by Abstract Devices
1.1 Models of Computation
1.2 Complexity Measures and Completeness
1.2.1 Complexity Hierarchies
1.2.2 Machine-Independent Complexity
1.2.3 Reducibility and Completeness
1.2.4 Relations among Complexity Classes

ACM Computing Classification System
F. Theory of Computation
2. Analysis of Algorithms and Problem Complexity
2.1 Numerical Algorithms
2.2 Non-numerical Algorithms and Problems
2.2.1 Complexity of Proof Procedures
2.2.2 Computations on Discrete Structures
2.2.3 Geometrical Problems
2.2.4 Pattern Matching
2.2.5 Routing and Layout
2.2.6 Sequencing and Scheduling
2.2.7 Sorting and Searching

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
G. Mathematics of Computing
1.
2.
3.
4.

Numerical Analysis
Discrete Mathematics
Probability and Statistics
Mathematical Software

ACM Computing Classification System
G. Mathematics of Computing
2. Discrete Mathematics
2.1 Combinatorics

2.1.1 Combinatorial Algorithms
2.1.2 Counting Problems
2.1.3 Generating Functions
2.1.4 Permutations and Combinations
2.1.5 Recurrences and Difference Equations

2.2 Graph Theory
2.2.1 Graph Algorithms
2.2.2 Graph Labeling

2.2.5 Path and Circuit Problems
2.2.6 Trees

2.3 Applications

a world FULL of NP-hard problems
Problem: I want to travel among a set of
cities driving the fewest possible number
of KMs. IT’S DIFFICULT!!

Problem: I want to put a set of objects
into some bags, knowing that each bag
can not afford more than 10 KGs and
trying to use as few bags as possible.
IT’S DIFFICULT!!

How to Deal with NP-hard problems?
• Exact Algorithms
• Randomized Algorithms
• Approximation Algorithms
• Fixed-Parameter Tractable Algorithms
• …

Approximation Algorithms

Approximation Algorithms
• We want a solution “close” to the
optimal one.
• Given a minimization problem Π, an
algorithm is an α-approximation for Π if,
for every instance I of Π, it outputs a
solution SOL(I) such that
SOL(I)/OPT(I) ≤ α

Vertex Cover
• Problem: Given a graph G(V,E), find a
minimum vertex cover, that is, a set V’  V
such that every edge e  E has an
endvertex in V’.

NP-hard 
[Karp]

How to Guarantee an Approximation?
• We want an approximation algorithm
for Vertex Cover.
• The cost of the solution produced by the
algorithm should be compared with the
cost of an optimal solution.

• But computing the cost of an optimal
solution is NP-HARD!!
LOWER BOUNDS!

Lower Bound for Vertex Cover
• Given a graph G(V,E), a matching M is
a set of edges M  E such that no two
edges share an endvertex.
• A matching is maximal if no matching M’
exists such that M  M’.

• The size of a matching
is a lower bound on the
size of an optimal
solution to Vertex
Cover!

An Approximation Algorithm
for Vertex Cover

• Algorithm: Find a maximal matching M
and output the set S of matched vertices

An Approximation Algorithm
for Vertex Cover
• Theorem: The previous algorithm is a
2-approximation algorithm for Vertex Cover
• Proof:
• S is a vertex cover, otherwhise the
matching would not be maximal.
• OPT≥M, where M is the size of the output
maximal matching.
• SOL=2M, as the number of matched
vertices is twice the size of the matching.

Approximation Algorithms:much more…
• Approximation schemes: (1+ε)-approx.
• Inapproximability results.
• Complexity classes, e.g., APX.

Fixed-Parameter Tractable Algorithms

Easy or Hard?
Problem (optimization): Let G be a graph.
Which is the minimum number of vertices
whose deletion makes G planar?

NP-hard 
[Lewis-Yannakakis ]

Easy or Hard?
Problem (decision): Let G be a graph and k
be an integer. Is there a set of k vertices
whose deletion makes G planar?
Polynomial 
• Easy O(nk+1) time algorithm for solving the problem:
• Consider every set of k vertices. Remove such
vertices. Test the planarity of the resulting graph.

• There are O(nk) such sets. Testing the planarity of
an n-vertex graph takes O(n) time. Then,
T(n,k)= O(nk) O(n) = O(nk+1)

Easy or Hard?
Where is the trick?
In the decision version, k is a constant
parameter part of the input
An O(nk+1)-time algorithm, with k constant, is a
polynomial-time algorithm.

But it is very slow 

Fixed-Parameter Tractability
A problem is fixed-parameter tractable
if it can be solved in f(k) nO(1) time,
where k is a parameter of the problem,
f is an arbitrary function, and nO(1) is a
polynomial (not depending on k).

FPT algorithm for Vertex Cover
Theorem [Melhorn]: There is an O(2k n)time algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• There is a vertex cover with k=0 if and only if G
has no edge.
• Consider any edge e=(u,v). Either u or v belongs
to any vertex cover S.
• Consider both the case in which u S and the
case in which v S.

FPT algorithm for Vertex Cover
u

u

v

v

• u  S -> S is a vertex cover of G if and only if
S-{u} is a vertex cover of G-{u} -> solve the
instance (G-{u}, k-1)
• v  S -> S is a vertex cover of G if and only if
S-{v} is a vertex cover of G-{v} -> solve the
instance (G-{v}, k-1)

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• T(n,0) = O(n)
• T(n,k) = 2 T(n-1, k-1) +O(n) ≤ 2 T(n, k-1) +O(n) ≤
2 (2 T(n, k-2) +O(n)) +O(n) ≤
2 (2 (2 T(n, k-3) +O(n)) +O(n)) +O(n) ≤
2 (2 (2 (…(2 T(n, 0)+O(n)) + … +O(n))
+O(n)) +O(n) ≤
2k O(n) + (2k-1 + 2k-2 + 2k-3 + ... + 1) O(n) =
2k O(n) + (2k - 1) O(n) = O(2k n)

Reduction Rules
Reduction rule : a rule (that is, a polynomial time
algorithm) that transforms an instance (I,k) to
an "equivalent and simpler” instance (I', k’).

Equivalent: (I,k) is a YES instance if and only if
(I', k') is a YES instance.
Simpler: |I'|<|I| or k'occurrences of a particular substructure.

Another FPT algorithm for Vertex Cover
Theorem: There is an O(1.6181k n2)-time
algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• We apply the following two reduction rules:
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k).
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u,N(u)},k-1).

Another FPT algorithm for Vertex Cover
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k). Correctness: if S is a vertex
cover of G and u is in S, then S-{u} is also a
vertex cover of G, as u has no incident edge.
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u, N(u)},k-1). Correctness: if S is a
vertex cover of G and u is in S, then
S-{u}  N(u) is also a vertex cover of G, as u
has no other incident edge.

Another FPT algorithm for Vertex Cover
• If neither of the two rules can be applied,
then every vertex has degree at least 2.
• Pick a vertex u. Any vertex cover of G
contains either u or N(u). Thus, (G,k) is a YES
instance if and only if (G-{u},k-1) or
(G-N(u),k-|N(u)|) is.

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• Since |N(u)|\geq 2,
• T(n,k) ≤ T(n,k-1)+ T(n,k-2)+O(n^2).
• Fibonacci series: every number is the sum of
the previous two xk =xk-1 +xk-2 +c.

• The k-th number of the Fibonacci series
tends to the golden ratio to the power of k.
• T(n,k)=Φk O(n2)=((1+√5)/2)k O(n2) =
O(1.6181k n2).

Kernelization
• Sometimes the reduction rules work till the size
of the problem is reduced really a lot. That is,
after the reduction rules have been applied,
the problem has size g(k), for some function k.
In this case the problem has a g(k)-kernel.

• Kernel: given a problem and an instance (I,k), a
kernel is an algorithm that outputs in polynomial
time an instance (I',k') such that (a) (I',k') is a
YES instance if and only if (I,k) is; (b) |I'|and k'
Kernelization
• Theorem [Niedermaier]: Every fixed-parameter
tractable problem has a g(k)-kernel.
• Proof: Suppose that there exists a FPT
algorithm with running time f(k) nc, for some
function f and some constant c. Consider an
instance (I,k) with |I|=n.
• If n>f(k), we run the decision algorithm in time
f(k) nc < nc+1. If it returns YES (NO), the
kernelization algorithm outputs a constant size
YES (resp. NO) instance.
• If n≤f(k), the the kernelization algorithm
returns (I,k).

Kernelization
• The last theorem implies that every problem
that is FPT has a kernel.
• However, the goal is to obtain kernels that are
"small", that is, polynomial in k, or even constant.

FPT: much more…
• Some problems are not FPT (e.g., graph coloring).
• Complexity classes: W[1] -> Can a nondeterministic Turing machine accept an unary
string s in at most k steps?
• Independent Set is W[1]-hard.
• Reductions to W[1]-hard problems give new
W[1]-hard problems.
• Lower bounds for FPT tractability
• Upper and lower bounds for the size of the
kernels

FPT: much more…
• Theorem [Robertson and Seymour]: Every graph
problem with parameter k whose YES istances
are closed under taking minors can be solved in
O(f(k) n3)


Slide 19

Tecniche Algoritmiche per Grafi e Reti
Fabrizio Frati

Dipartimento di Informatica e Automazione
Università degli Studi Roma Tre

• 3 CREDITI
• I° periodo:
• Lunedì 9:45-11:15 aula N13

• II° periodo:
• Venerdì 8:00-9:45 aula N7

• Contatti:
• {angelini,gdb,frati,ratm} @dia.uniroma3.it
• Ricevimento: mercoledì dalle 17 alle 19

• Struttura del Corso
• ~ 8 seminari
• algoritmi, strutture dati, combinatorica,
graph drawing…

• progetti a gruppi di 2 - 4 persone
• problema di ricerca

• Materiale Didattico
• slides
• G. Di Battista, P. Eades, R. Tamassia, I. G.
Tollis, Graph Drawing: Algorithms for the
Visualization of Graphs, 1999. Prentice Hall.

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
C. Computer System Organization
1.
2.
3.
4.
5.

Processor Architectures
Computer-Communication Networks
Application-Based Systems
Performance of Systems
Computer System Implementations

ACM Computing Classification System
C. Computer System Organization
2. Computer-Communication Networks
2.1 Network Architectures
2.2 Network Protocols
2.3 Network Operations
2.4 Distributed Systems
2.5 LAN & WAN
2.6 Internetworking

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
E. Data
1.
2.
3.
4.
5.

Data Structures
Data Storage Representations
Data Encryption
Coding and Information Theory
Files

ACM Computing Classification System
E. Data
1. Data Structures
1.1 Arrays
1.2 Distributed Data Structures
1.3 Graphs and Networks
1.4 Lists, Stacks, and Queues
1.5 Records
1.6 Tables
1.7 Trees

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
F. Theory of Computation
1.
2.
3.
4.

Computation by Abstract Devices
Analysis of Algorithms and Problem Complexity
Logics and Meanings of Programs
Mathematical Logic and Formal Languages

ACM Computing Classification System
F. Theory of Computation
1. Computation by Abstract Devices
1.1 Models of Computation
1.2 Complexity Measures and Completeness
1.2.1 Complexity Hierarchies
1.2.2 Machine-Independent Complexity
1.2.3 Reducibility and Completeness
1.2.4 Relations among Complexity Classes

ACM Computing Classification System
F. Theory of Computation
2. Analysis of Algorithms and Problem Complexity
2.1 Numerical Algorithms
2.2 Non-numerical Algorithms and Problems
2.2.1 Complexity of Proof Procedures
2.2.2 Computations on Discrete Structures
2.2.3 Geometrical Problems
2.2.4 Pattern Matching
2.2.5 Routing and Layout
2.2.6 Sequencing and Scheduling
2.2.7 Sorting and Searching

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
G. Mathematics of Computing
1.
2.
3.
4.

Numerical Analysis
Discrete Mathematics
Probability and Statistics
Mathematical Software

ACM Computing Classification System
G. Mathematics of Computing
2. Discrete Mathematics
2.1 Combinatorics

2.1.1 Combinatorial Algorithms
2.1.2 Counting Problems
2.1.3 Generating Functions
2.1.4 Permutations and Combinations
2.1.5 Recurrences and Difference Equations

2.2 Graph Theory
2.2.1 Graph Algorithms
2.2.2 Graph Labeling

2.2.5 Path and Circuit Problems
2.2.6 Trees

2.3 Applications

a world FULL of NP-hard problems
Problem: I want to travel among a set of
cities driving the fewest possible number
of KMs. IT’S DIFFICULT!!

Problem: I want to put a set of objects
into some bags, knowing that each bag
can not afford more than 10 KGs and
trying to use as few bags as possible.
IT’S DIFFICULT!!

How to Deal with NP-hard problems?
• Exact Algorithms
• Randomized Algorithms
• Approximation Algorithms
• Fixed-Parameter Tractable Algorithms
• …

Approximation Algorithms

Approximation Algorithms
• We want a solution “close” to the
optimal one.
• Given a minimization problem Π, an
algorithm is an α-approximation for Π if,
for every instance I of Π, it outputs a
solution SOL(I) such that
SOL(I)/OPT(I) ≤ α

Vertex Cover
• Problem: Given a graph G(V,E), find a
minimum vertex cover, that is, a set V’  V
such that every edge e  E has an
endvertex in V’.

NP-hard 
[Karp]

How to Guarantee an Approximation?
• We want an approximation algorithm
for Vertex Cover.
• The cost of the solution produced by the
algorithm should be compared with the
cost of an optimal solution.

• But computing the cost of an optimal
solution is NP-HARD!!
LOWER BOUNDS!

Lower Bound for Vertex Cover
• Given a graph G(V,E), a matching M is
a set of edges M  E such that no two
edges share an endvertex.
• A matching is maximal if no matching M’
exists such that M  M’.

• The size of a matching
is a lower bound on the
size of an optimal
solution to Vertex
Cover!

An Approximation Algorithm
for Vertex Cover

• Algorithm: Find a maximal matching M
and output the set S of matched vertices

An Approximation Algorithm
for Vertex Cover
• Theorem: The previous algorithm is a
2-approximation algorithm for Vertex Cover
• Proof:
• S is a vertex cover, otherwhise the
matching would not be maximal.
• OPT≥M, where M is the size of the output
maximal matching.
• SOL=2M, as the number of matched
vertices is twice the size of the matching.

Approximation Algorithms:much more…
• Approximation schemes: (1+ε)-approx.
• Inapproximability results.
• Complexity classes, e.g., APX.

Fixed-Parameter Tractable Algorithms

Easy or Hard?
Problem (optimization): Let G be a graph.
Which is the minimum number of vertices
whose deletion makes G planar?

NP-hard 
[Lewis-Yannakakis ]

Easy or Hard?
Problem (decision): Let G be a graph and k
be an integer. Is there a set of k vertices
whose deletion makes G planar?
Polynomial 
• Easy O(nk+1) time algorithm for solving the problem:
• Consider every set of k vertices. Remove such
vertices. Test the planarity of the resulting graph.

• There are O(nk) such sets. Testing the planarity of
an n-vertex graph takes O(n) time. Then,
T(n,k)= O(nk) O(n) = O(nk+1)

Easy or Hard?
Where is the trick?
In the decision version, k is a constant
parameter part of the input
An O(nk+1)-time algorithm, with k constant, is a
polynomial-time algorithm.

But it is very slow 

Fixed-Parameter Tractability
A problem is fixed-parameter tractable
if it can be solved in f(k) nO(1) time,
where k is a parameter of the problem,
f is an arbitrary function, and nO(1) is a
polynomial (not depending on k).

FPT algorithm for Vertex Cover
Theorem [Melhorn]: There is an O(2k n)time algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• There is a vertex cover with k=0 if and only if G
has no edge.
• Consider any edge e=(u,v). Either u or v belongs
to any vertex cover S.
• Consider both the case in which u S and the
case in which v S.

FPT algorithm for Vertex Cover
u

u

v

v

• u  S -> S is a vertex cover of G if and only if
S-{u} is a vertex cover of G-{u} -> solve the
instance (G-{u}, k-1)
• v  S -> S is a vertex cover of G if and only if
S-{v} is a vertex cover of G-{v} -> solve the
instance (G-{v}, k-1)

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• T(n,0) = O(n)
• T(n,k) = 2 T(n-1, k-1) +O(n) ≤ 2 T(n, k-1) +O(n) ≤
2 (2 T(n, k-2) +O(n)) +O(n) ≤
2 (2 (2 T(n, k-3) +O(n)) +O(n)) +O(n) ≤
2 (2 (2 (…(2 T(n, 0)+O(n)) + … +O(n))
+O(n)) +O(n) ≤
2k O(n) + (2k-1 + 2k-2 + 2k-3 + ... + 1) O(n) =
2k O(n) + (2k - 1) O(n) = O(2k n)

Reduction Rules
Reduction rule : a rule (that is, a polynomial time
algorithm) that transforms an instance (I,k) to
an "equivalent and simpler” instance (I', k’).

Equivalent: (I,k) is a YES instance if and only if
(I', k') is a YES instance.
Simpler: |I'|<|I| or k'occurrences of a particular substructure.

Another FPT algorithm for Vertex Cover
Theorem: There is an O(1.6181k n2)-time
algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• We apply the following two reduction rules:
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k).
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u,N(u)},k-1).

Another FPT algorithm for Vertex Cover
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k). Correctness: if S is a vertex
cover of G and u is in S, then S-{u} is also a
vertex cover of G, as u has no incident edge.
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u, N(u)},k-1). Correctness: if S is a
vertex cover of G and u is in S, then
S-{u}  N(u) is also a vertex cover of G, as u
has no other incident edge.

Another FPT algorithm for Vertex Cover
• If neither of the two rules can be applied,
then every vertex has degree at least 2.
• Pick a vertex u. Any vertex cover of G
contains either u or N(u). Thus, (G,k) is a YES
instance if and only if (G-{u},k-1) or
(G-N(u),k-|N(u)|) is.

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• Since |N(u)|\geq 2,
• T(n,k) ≤ T(n,k-1)+ T(n,k-2)+O(n^2).
• Fibonacci series: every number is the sum of
the previous two xk =xk-1 +xk-2 +c.

• The k-th number of the Fibonacci series
tends to the golden ratio to the power of k.
• T(n,k)=Φk O(n2)=((1+√5)/2)k O(n2) =
O(1.6181k n2).

Kernelization
• Sometimes the reduction rules work till the size
of the problem is reduced really a lot. That is,
after the reduction rules have been applied,
the problem has size g(k), for some function k.
In this case the problem has a g(k)-kernel.

• Kernel: given a problem and an instance (I,k), a
kernel is an algorithm that outputs in polynomial
time an instance (I',k') such that (a) (I',k') is a
YES instance if and only if (I,k) is; (b) |I'|and k'
Kernelization
• Theorem [Niedermaier]: Every fixed-parameter
tractable problem has a g(k)-kernel.
• Proof: Suppose that there exists a FPT
algorithm with running time f(k) nc, for some
function f and some constant c. Consider an
instance (I,k) with |I|=n.
• If n>f(k), we run the decision algorithm in time
f(k) nc < nc+1. If it returns YES (NO), the
kernelization algorithm outputs a constant size
YES (resp. NO) instance.
• If n≤f(k), the the kernelization algorithm
returns (I,k).

Kernelization
• The last theorem implies that every problem
that is FPT has a kernel.
• However, the goal is to obtain kernels that are
"small", that is, polynomial in k, or even constant.

FPT: much more…
• Some problems are not FPT (e.g., graph coloring).
• Complexity classes: W[1] -> Can a nondeterministic Turing machine accept an unary
string s in at most k steps?
• Independent Set is W[1]-hard.
• Reductions to W[1]-hard problems give new
W[1]-hard problems.
• Lower bounds for FPT tractability
• Upper and lower bounds for the size of the
kernels

FPT: much more…
• Theorem [Robertson and Seymour]: Every graph
problem with parameter k whose YES istances
are closed under taking minors can be solved in
O(f(k) n3)


Slide 20

Tecniche Algoritmiche per Grafi e Reti
Fabrizio Frati

Dipartimento di Informatica e Automazione
Università degli Studi Roma Tre

• 3 CREDITI
• I° periodo:
• Lunedì 9:45-11:15 aula N13

• II° periodo:
• Venerdì 8:00-9:45 aula N7

• Contatti:
• {angelini,gdb,frati,ratm} @dia.uniroma3.it
• Ricevimento: mercoledì dalle 17 alle 19

• Struttura del Corso
• ~ 8 seminari
• algoritmi, strutture dati, combinatorica,
graph drawing…

• progetti a gruppi di 2 - 4 persone
• problema di ricerca

• Materiale Didattico
• slides
• G. Di Battista, P. Eades, R. Tamassia, I. G.
Tollis, Graph Drawing: Algorithms for the
Visualization of Graphs, 1999. Prentice Hall.

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
C. Computer System Organization
1.
2.
3.
4.
5.

Processor Architectures
Computer-Communication Networks
Application-Based Systems
Performance of Systems
Computer System Implementations

ACM Computing Classification System
C. Computer System Organization
2. Computer-Communication Networks
2.1 Network Architectures
2.2 Network Protocols
2.3 Network Operations
2.4 Distributed Systems
2.5 LAN & WAN
2.6 Internetworking

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
E. Data
1.
2.
3.
4.
5.

Data Structures
Data Storage Representations
Data Encryption
Coding and Information Theory
Files

ACM Computing Classification System
E. Data
1. Data Structures
1.1 Arrays
1.2 Distributed Data Structures
1.3 Graphs and Networks
1.4 Lists, Stacks, and Queues
1.5 Records
1.6 Tables
1.7 Trees

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
F. Theory of Computation
1.
2.
3.
4.

Computation by Abstract Devices
Analysis of Algorithms and Problem Complexity
Logics and Meanings of Programs
Mathematical Logic and Formal Languages

ACM Computing Classification System
F. Theory of Computation
1. Computation by Abstract Devices
1.1 Models of Computation
1.2 Complexity Measures and Completeness
1.2.1 Complexity Hierarchies
1.2.2 Machine-Independent Complexity
1.2.3 Reducibility and Completeness
1.2.4 Relations among Complexity Classes

ACM Computing Classification System
F. Theory of Computation
2. Analysis of Algorithms and Problem Complexity
2.1 Numerical Algorithms
2.2 Non-numerical Algorithms and Problems
2.2.1 Complexity of Proof Procedures
2.2.2 Computations on Discrete Structures
2.2.3 Geometrical Problems
2.2.4 Pattern Matching
2.2.5 Routing and Layout
2.2.6 Sequencing and Scheduling
2.2.7 Sorting and Searching

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
G. Mathematics of Computing
1.
2.
3.
4.

Numerical Analysis
Discrete Mathematics
Probability and Statistics
Mathematical Software

ACM Computing Classification System
G. Mathematics of Computing
2. Discrete Mathematics
2.1 Combinatorics

2.1.1 Combinatorial Algorithms
2.1.2 Counting Problems
2.1.3 Generating Functions
2.1.4 Permutations and Combinations
2.1.5 Recurrences and Difference Equations

2.2 Graph Theory
2.2.1 Graph Algorithms
2.2.2 Graph Labeling

2.2.5 Path and Circuit Problems
2.2.6 Trees

2.3 Applications

a world FULL of NP-hard problems
Problem: I want to travel among a set of
cities driving the fewest possible number
of KMs. IT’S DIFFICULT!!

Problem: I want to put a set of objects
into some bags, knowing that each bag
can not afford more than 10 KGs and
trying to use as few bags as possible.
IT’S DIFFICULT!!

How to Deal with NP-hard problems?
• Exact Algorithms
• Randomized Algorithms
• Approximation Algorithms
• Fixed-Parameter Tractable Algorithms
• …

Approximation Algorithms

Approximation Algorithms
• We want a solution “close” to the
optimal one.
• Given a minimization problem Π, an
algorithm is an α-approximation for Π if,
for every instance I of Π, it outputs a
solution SOL(I) such that
SOL(I)/OPT(I) ≤ α

Vertex Cover
• Problem: Given a graph G(V,E), find a
minimum vertex cover, that is, a set V’  V
such that every edge e  E has an
endvertex in V’.

NP-hard 
[Karp]

How to Guarantee an Approximation?
• We want an approximation algorithm
for Vertex Cover.
• The cost of the solution produced by the
algorithm should be compared with the
cost of an optimal solution.

• But computing the cost of an optimal
solution is NP-HARD!!
LOWER BOUNDS!

Lower Bound for Vertex Cover
• Given a graph G(V,E), a matching M is
a set of edges M  E such that no two
edges share an endvertex.
• A matching is maximal if no matching M’
exists such that M  M’.

• The size of a matching
is a lower bound on the
size of an optimal
solution to Vertex
Cover!

An Approximation Algorithm
for Vertex Cover

• Algorithm: Find a maximal matching M
and output the set S of matched vertices

An Approximation Algorithm
for Vertex Cover
• Theorem: The previous algorithm is a
2-approximation algorithm for Vertex Cover
• Proof:
• S is a vertex cover, otherwhise the
matching would not be maximal.
• OPT≥M, where M is the size of the output
maximal matching.
• SOL=2M, as the number of matched
vertices is twice the size of the matching.

Approximation Algorithms:much more…
• Approximation schemes: (1+ε)-approx.
• Inapproximability results.
• Complexity classes, e.g., APX.

Fixed-Parameter Tractable Algorithms

Easy or Hard?
Problem (optimization): Let G be a graph.
Which is the minimum number of vertices
whose deletion makes G planar?

NP-hard 
[Lewis-Yannakakis ]

Easy or Hard?
Problem (decision): Let G be a graph and k
be an integer. Is there a set of k vertices
whose deletion makes G planar?
Polynomial 
• Easy O(nk+1) time algorithm for solving the problem:
• Consider every set of k vertices. Remove such
vertices. Test the planarity of the resulting graph.

• There are O(nk) such sets. Testing the planarity of
an n-vertex graph takes O(n) time. Then,
T(n,k)= O(nk) O(n) = O(nk+1)

Easy or Hard?
Where is the trick?
In the decision version, k is a constant
parameter part of the input
An O(nk+1)-time algorithm, with k constant, is a
polynomial-time algorithm.

But it is very slow 

Fixed-Parameter Tractability
A problem is fixed-parameter tractable
if it can be solved in f(k) nO(1) time,
where k is a parameter of the problem,
f is an arbitrary function, and nO(1) is a
polynomial (not depending on k).

FPT algorithm for Vertex Cover
Theorem [Melhorn]: There is an O(2k n)time algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• There is a vertex cover with k=0 if and only if G
has no edge.
• Consider any edge e=(u,v). Either u or v belongs
to any vertex cover S.
• Consider both the case in which u S and the
case in which v S.

FPT algorithm for Vertex Cover
u

u

v

v

• u  S -> S is a vertex cover of G if and only if
S-{u} is a vertex cover of G-{u} -> solve the
instance (G-{u}, k-1)
• v  S -> S is a vertex cover of G if and only if
S-{v} is a vertex cover of G-{v} -> solve the
instance (G-{v}, k-1)

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• T(n,0) = O(n)
• T(n,k) = 2 T(n-1, k-1) +O(n) ≤ 2 T(n, k-1) +O(n) ≤
2 (2 T(n, k-2) +O(n)) +O(n) ≤
2 (2 (2 T(n, k-3) +O(n)) +O(n)) +O(n) ≤
2 (2 (2 (…(2 T(n, 0)+O(n)) + … +O(n))
+O(n)) +O(n) ≤
2k O(n) + (2k-1 + 2k-2 + 2k-3 + ... + 1) O(n) =
2k O(n) + (2k - 1) O(n) = O(2k n)

Reduction Rules
Reduction rule : a rule (that is, a polynomial time
algorithm) that transforms an instance (I,k) to
an "equivalent and simpler” instance (I', k’).

Equivalent: (I,k) is a YES instance if and only if
(I', k') is a YES instance.
Simpler: |I'|<|I| or k'occurrences of a particular substructure.

Another FPT algorithm for Vertex Cover
Theorem: There is an O(1.6181k n2)-time
algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• We apply the following two reduction rules:
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k).
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u,N(u)},k-1).

Another FPT algorithm for Vertex Cover
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k). Correctness: if S is a vertex
cover of G and u is in S, then S-{u} is also a
vertex cover of G, as u has no incident edge.
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u, N(u)},k-1). Correctness: if S is a
vertex cover of G and u is in S, then
S-{u}  N(u) is also a vertex cover of G, as u
has no other incident edge.

Another FPT algorithm for Vertex Cover
• If neither of the two rules can be applied,
then every vertex has degree at least 2.
• Pick a vertex u. Any vertex cover of G
contains either u or N(u). Thus, (G,k) is a YES
instance if and only if (G-{u},k-1) or
(G-N(u),k-|N(u)|) is.

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• Since |N(u)|\geq 2,
• T(n,k) ≤ T(n,k-1)+ T(n,k-2)+O(n^2).
• Fibonacci series: every number is the sum of
the previous two xk =xk-1 +xk-2 +c.

• The k-th number of the Fibonacci series
tends to the golden ratio to the power of k.
• T(n,k)=Φk O(n2)=((1+√5)/2)k O(n2) =
O(1.6181k n2).

Kernelization
• Sometimes the reduction rules work till the size
of the problem is reduced really a lot. That is,
after the reduction rules have been applied,
the problem has size g(k), for some function k.
In this case the problem has a g(k)-kernel.

• Kernel: given a problem and an instance (I,k), a
kernel is an algorithm that outputs in polynomial
time an instance (I',k') such that (a) (I',k') is a
YES instance if and only if (I,k) is; (b) |I'|and k'
Kernelization
• Theorem [Niedermaier]: Every fixed-parameter
tractable problem has a g(k)-kernel.
• Proof: Suppose that there exists a FPT
algorithm with running time f(k) nc, for some
function f and some constant c. Consider an
instance (I,k) with |I|=n.
• If n>f(k), we run the decision algorithm in time
f(k) nc < nc+1. If it returns YES (NO), the
kernelization algorithm outputs a constant size
YES (resp. NO) instance.
• If n≤f(k), the the kernelization algorithm
returns (I,k).

Kernelization
• The last theorem implies that every problem
that is FPT has a kernel.
• However, the goal is to obtain kernels that are
"small", that is, polynomial in k, or even constant.

FPT: much more…
• Some problems are not FPT (e.g., graph coloring).
• Complexity classes: W[1] -> Can a nondeterministic Turing machine accept an unary
string s in at most k steps?
• Independent Set is W[1]-hard.
• Reductions to W[1]-hard problems give new
W[1]-hard problems.
• Lower bounds for FPT tractability
• Upper and lower bounds for the size of the
kernels

FPT: much more…
• Theorem [Robertson and Seymour]: Every graph
problem with parameter k whose YES istances
are closed under taking minors can be solved in
O(f(k) n3)


Slide 21

Tecniche Algoritmiche per Grafi e Reti
Fabrizio Frati

Dipartimento di Informatica e Automazione
Università degli Studi Roma Tre

• 3 CREDITI
• I° periodo:
• Lunedì 9:45-11:15 aula N13

• II° periodo:
• Venerdì 8:00-9:45 aula N7

• Contatti:
• {angelini,gdb,frati,ratm} @dia.uniroma3.it
• Ricevimento: mercoledì dalle 17 alle 19

• Struttura del Corso
• ~ 8 seminari
• algoritmi, strutture dati, combinatorica,
graph drawing…

• progetti a gruppi di 2 - 4 persone
• problema di ricerca

• Materiale Didattico
• slides
• G. Di Battista, P. Eades, R. Tamassia, I. G.
Tollis, Graph Drawing: Algorithms for the
Visualization of Graphs, 1999. Prentice Hall.

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
C. Computer System Organization
1.
2.
3.
4.
5.

Processor Architectures
Computer-Communication Networks
Application-Based Systems
Performance of Systems
Computer System Implementations

ACM Computing Classification System
C. Computer System Organization
2. Computer-Communication Networks
2.1 Network Architectures
2.2 Network Protocols
2.3 Network Operations
2.4 Distributed Systems
2.5 LAN & WAN
2.6 Internetworking

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
E. Data
1.
2.
3.
4.
5.

Data Structures
Data Storage Representations
Data Encryption
Coding and Information Theory
Files

ACM Computing Classification System
E. Data
1. Data Structures
1.1 Arrays
1.2 Distributed Data Structures
1.3 Graphs and Networks
1.4 Lists, Stacks, and Queues
1.5 Records
1.6 Tables
1.7 Trees

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
F. Theory of Computation
1.
2.
3.
4.

Computation by Abstract Devices
Analysis of Algorithms and Problem Complexity
Logics and Meanings of Programs
Mathematical Logic and Formal Languages

ACM Computing Classification System
F. Theory of Computation
1. Computation by Abstract Devices
1.1 Models of Computation
1.2 Complexity Measures and Completeness
1.2.1 Complexity Hierarchies
1.2.2 Machine-Independent Complexity
1.2.3 Reducibility and Completeness
1.2.4 Relations among Complexity Classes

ACM Computing Classification System
F. Theory of Computation
2. Analysis of Algorithms and Problem Complexity
2.1 Numerical Algorithms
2.2 Non-numerical Algorithms and Problems
2.2.1 Complexity of Proof Procedures
2.2.2 Computations on Discrete Structures
2.2.3 Geometrical Problems
2.2.4 Pattern Matching
2.2.5 Routing and Layout
2.2.6 Sequencing and Scheduling
2.2.7 Sorting and Searching

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
G. Mathematics of Computing
1.
2.
3.
4.

Numerical Analysis
Discrete Mathematics
Probability and Statistics
Mathematical Software

ACM Computing Classification System
G. Mathematics of Computing
2. Discrete Mathematics
2.1 Combinatorics

2.1.1 Combinatorial Algorithms
2.1.2 Counting Problems
2.1.3 Generating Functions
2.1.4 Permutations and Combinations
2.1.5 Recurrences and Difference Equations

2.2 Graph Theory
2.2.1 Graph Algorithms
2.2.2 Graph Labeling

2.2.5 Path and Circuit Problems
2.2.6 Trees

2.3 Applications

a world FULL of NP-hard problems
Problem: I want to travel among a set of
cities driving the fewest possible number
of KMs. IT’S DIFFICULT!!

Problem: I want to put a set of objects
into some bags, knowing that each bag
can not afford more than 10 KGs and
trying to use as few bags as possible.
IT’S DIFFICULT!!

How to Deal with NP-hard problems?
• Exact Algorithms
• Randomized Algorithms
• Approximation Algorithms
• Fixed-Parameter Tractable Algorithms
• …

Approximation Algorithms

Approximation Algorithms
• We want a solution “close” to the
optimal one.
• Given a minimization problem Π, an
algorithm is an α-approximation for Π if,
for every instance I of Π, it outputs a
solution SOL(I) such that
SOL(I)/OPT(I) ≤ α

Vertex Cover
• Problem: Given a graph G(V,E), find a
minimum vertex cover, that is, a set V’  V
such that every edge e  E has an
endvertex in V’.

NP-hard 
[Karp]

How to Guarantee an Approximation?
• We want an approximation algorithm
for Vertex Cover.
• The cost of the solution produced by the
algorithm should be compared with the
cost of an optimal solution.

• But computing the cost of an optimal
solution is NP-HARD!!
LOWER BOUNDS!

Lower Bound for Vertex Cover
• Given a graph G(V,E), a matching M is
a set of edges M  E such that no two
edges share an endvertex.
• A matching is maximal if no matching M’
exists such that M  M’.

• The size of a matching
is a lower bound on the
size of an optimal
solution to Vertex
Cover!

An Approximation Algorithm
for Vertex Cover

• Algorithm: Find a maximal matching M
and output the set S of matched vertices

An Approximation Algorithm
for Vertex Cover
• Theorem: The previous algorithm is a
2-approximation algorithm for Vertex Cover
• Proof:
• S is a vertex cover, otherwhise the
matching would not be maximal.
• OPT≥M, where M is the size of the output
maximal matching.
• SOL=2M, as the number of matched
vertices is twice the size of the matching.

Approximation Algorithms:much more…
• Approximation schemes: (1+ε)-approx.
• Inapproximability results.
• Complexity classes, e.g., APX.

Fixed-Parameter Tractable Algorithms

Easy or Hard?
Problem (optimization): Let G be a graph.
Which is the minimum number of vertices
whose deletion makes G planar?

NP-hard 
[Lewis-Yannakakis ]

Easy or Hard?
Problem (decision): Let G be a graph and k
be an integer. Is there a set of k vertices
whose deletion makes G planar?
Polynomial 
• Easy O(nk+1) time algorithm for solving the problem:
• Consider every set of k vertices. Remove such
vertices. Test the planarity of the resulting graph.

• There are O(nk) such sets. Testing the planarity of
an n-vertex graph takes O(n) time. Then,
T(n,k)= O(nk) O(n) = O(nk+1)

Easy or Hard?
Where is the trick?
In the decision version, k is a constant
parameter part of the input
An O(nk+1)-time algorithm, with k constant, is a
polynomial-time algorithm.

But it is very slow 

Fixed-Parameter Tractability
A problem is fixed-parameter tractable
if it can be solved in f(k) nO(1) time,
where k is a parameter of the problem,
f is an arbitrary function, and nO(1) is a
polynomial (not depending on k).

FPT algorithm for Vertex Cover
Theorem [Melhorn]: There is an O(2k n)time algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• There is a vertex cover with k=0 if and only if G
has no edge.
• Consider any edge e=(u,v). Either u or v belongs
to any vertex cover S.
• Consider both the case in which u S and the
case in which v S.

FPT algorithm for Vertex Cover
u

u

v

v

• u  S -> S is a vertex cover of G if and only if
S-{u} is a vertex cover of G-{u} -> solve the
instance (G-{u}, k-1)
• v  S -> S is a vertex cover of G if and only if
S-{v} is a vertex cover of G-{v} -> solve the
instance (G-{v}, k-1)

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• T(n,0) = O(n)
• T(n,k) = 2 T(n-1, k-1) +O(n) ≤ 2 T(n, k-1) +O(n) ≤
2 (2 T(n, k-2) +O(n)) +O(n) ≤
2 (2 (2 T(n, k-3) +O(n)) +O(n)) +O(n) ≤
2 (2 (2 (…(2 T(n, 0)+O(n)) + … +O(n))
+O(n)) +O(n) ≤
2k O(n) + (2k-1 + 2k-2 + 2k-3 + ... + 1) O(n) =
2k O(n) + (2k - 1) O(n) = O(2k n)

Reduction Rules
Reduction rule : a rule (that is, a polynomial time
algorithm) that transforms an instance (I,k) to
an "equivalent and simpler” instance (I', k’).

Equivalent: (I,k) is a YES instance if and only if
(I', k') is a YES instance.
Simpler: |I'|<|I| or k'occurrences of a particular substructure.

Another FPT algorithm for Vertex Cover
Theorem: There is an O(1.6181k n2)-time
algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• We apply the following two reduction rules:
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k).
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u,N(u)},k-1).

Another FPT algorithm for Vertex Cover
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k). Correctness: if S is a vertex
cover of G and u is in S, then S-{u} is also a
vertex cover of G, as u has no incident edge.
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u, N(u)},k-1). Correctness: if S is a
vertex cover of G and u is in S, then
S-{u}  N(u) is also a vertex cover of G, as u
has no other incident edge.

Another FPT algorithm for Vertex Cover
• If neither of the two rules can be applied,
then every vertex has degree at least 2.
• Pick a vertex u. Any vertex cover of G
contains either u or N(u). Thus, (G,k) is a YES
instance if and only if (G-{u},k-1) or
(G-N(u),k-|N(u)|) is.

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• Since |N(u)|\geq 2,
• T(n,k) ≤ T(n,k-1)+ T(n,k-2)+O(n^2).
• Fibonacci series: every number is the sum of
the previous two xk =xk-1 +xk-2 +c.

• The k-th number of the Fibonacci series
tends to the golden ratio to the power of k.
• T(n,k)=Φk O(n2)=((1+√5)/2)k O(n2) =
O(1.6181k n2).

Kernelization
• Sometimes the reduction rules work till the size
of the problem is reduced really a lot. That is,
after the reduction rules have been applied,
the problem has size g(k), for some function k.
In this case the problem has a g(k)-kernel.

• Kernel: given a problem and an instance (I,k), a
kernel is an algorithm that outputs in polynomial
time an instance (I',k') such that (a) (I',k') is a
YES instance if and only if (I,k) is; (b) |I'|and k'
Kernelization
• Theorem [Niedermaier]: Every fixed-parameter
tractable problem has a g(k)-kernel.
• Proof: Suppose that there exists a FPT
algorithm with running time f(k) nc, for some
function f and some constant c. Consider an
instance (I,k) with |I|=n.
• If n>f(k), we run the decision algorithm in time
f(k) nc < nc+1. If it returns YES (NO), the
kernelization algorithm outputs a constant size
YES (resp. NO) instance.
• If n≤f(k), the the kernelization algorithm
returns (I,k).

Kernelization
• The last theorem implies that every problem
that is FPT has a kernel.
• However, the goal is to obtain kernels that are
"small", that is, polynomial in k, or even constant.

FPT: much more…
• Some problems are not FPT (e.g., graph coloring).
• Complexity classes: W[1] -> Can a nondeterministic Turing machine accept an unary
string s in at most k steps?
• Independent Set is W[1]-hard.
• Reductions to W[1]-hard problems give new
W[1]-hard problems.
• Lower bounds for FPT tractability
• Upper and lower bounds for the size of the
kernels

FPT: much more…
• Theorem [Robertson and Seymour]: Every graph
problem with parameter k whose YES istances
are closed under taking minors can be solved in
O(f(k) n3)


Slide 22

Tecniche Algoritmiche per Grafi e Reti
Fabrizio Frati

Dipartimento di Informatica e Automazione
Università degli Studi Roma Tre

• 3 CREDITI
• I° periodo:
• Lunedì 9:45-11:15 aula N13

• II° periodo:
• Venerdì 8:00-9:45 aula N7

• Contatti:
• {angelini,gdb,frati,ratm} @dia.uniroma3.it
• Ricevimento: mercoledì dalle 17 alle 19

• Struttura del Corso
• ~ 8 seminari
• algoritmi, strutture dati, combinatorica,
graph drawing…

• progetti a gruppi di 2 - 4 persone
• problema di ricerca

• Materiale Didattico
• slides
• G. Di Battista, P. Eades, R. Tamassia, I. G.
Tollis, Graph Drawing: Algorithms for the
Visualization of Graphs, 1999. Prentice Hall.

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
C. Computer System Organization
1.
2.
3.
4.
5.

Processor Architectures
Computer-Communication Networks
Application-Based Systems
Performance of Systems
Computer System Implementations

ACM Computing Classification System
C. Computer System Organization
2. Computer-Communication Networks
2.1 Network Architectures
2.2 Network Protocols
2.3 Network Operations
2.4 Distributed Systems
2.5 LAN & WAN
2.6 Internetworking

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
E. Data
1.
2.
3.
4.
5.

Data Structures
Data Storage Representations
Data Encryption
Coding and Information Theory
Files

ACM Computing Classification System
E. Data
1. Data Structures
1.1 Arrays
1.2 Distributed Data Structures
1.3 Graphs and Networks
1.4 Lists, Stacks, and Queues
1.5 Records
1.6 Tables
1.7 Trees

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
F. Theory of Computation
1.
2.
3.
4.

Computation by Abstract Devices
Analysis of Algorithms and Problem Complexity
Logics and Meanings of Programs
Mathematical Logic and Formal Languages

ACM Computing Classification System
F. Theory of Computation
1. Computation by Abstract Devices
1.1 Models of Computation
1.2 Complexity Measures and Completeness
1.2.1 Complexity Hierarchies
1.2.2 Machine-Independent Complexity
1.2.3 Reducibility and Completeness
1.2.4 Relations among Complexity Classes

ACM Computing Classification System
F. Theory of Computation
2. Analysis of Algorithms and Problem Complexity
2.1 Numerical Algorithms
2.2 Non-numerical Algorithms and Problems
2.2.1 Complexity of Proof Procedures
2.2.2 Computations on Discrete Structures
2.2.3 Geometrical Problems
2.2.4 Pattern Matching
2.2.5 Routing and Layout
2.2.6 Sequencing and Scheduling
2.2.7 Sorting and Searching

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
G. Mathematics of Computing
1.
2.
3.
4.

Numerical Analysis
Discrete Mathematics
Probability and Statistics
Mathematical Software

ACM Computing Classification System
G. Mathematics of Computing
2. Discrete Mathematics
2.1 Combinatorics

2.1.1 Combinatorial Algorithms
2.1.2 Counting Problems
2.1.3 Generating Functions
2.1.4 Permutations and Combinations
2.1.5 Recurrences and Difference Equations

2.2 Graph Theory
2.2.1 Graph Algorithms
2.2.2 Graph Labeling

2.2.5 Path and Circuit Problems
2.2.6 Trees

2.3 Applications

a world FULL of NP-hard problems
Problem: I want to travel among a set of
cities driving the fewest possible number
of KMs. IT’S DIFFICULT!!

Problem: I want to put a set of objects
into some bags, knowing that each bag
can not afford more than 10 KGs and
trying to use as few bags as possible.
IT’S DIFFICULT!!

How to Deal with NP-hard problems?
• Exact Algorithms
• Randomized Algorithms
• Approximation Algorithms
• Fixed-Parameter Tractable Algorithms
• …

Approximation Algorithms

Approximation Algorithms
• We want a solution “close” to the
optimal one.
• Given a minimization problem Π, an
algorithm is an α-approximation for Π if,
for every instance I of Π, it outputs a
solution SOL(I) such that
SOL(I)/OPT(I) ≤ α

Vertex Cover
• Problem: Given a graph G(V,E), find a
minimum vertex cover, that is, a set V’  V
such that every edge e  E has an
endvertex in V’.

NP-hard 
[Karp]

How to Guarantee an Approximation?
• We want an approximation algorithm
for Vertex Cover.
• The cost of the solution produced by the
algorithm should be compared with the
cost of an optimal solution.

• But computing the cost of an optimal
solution is NP-HARD!!
LOWER BOUNDS!

Lower Bound for Vertex Cover
• Given a graph G(V,E), a matching M is
a set of edges M  E such that no two
edges share an endvertex.
• A matching is maximal if no matching M’
exists such that M  M’.

• The size of a matching
is a lower bound on the
size of an optimal
solution to Vertex
Cover!

An Approximation Algorithm
for Vertex Cover

• Algorithm: Find a maximal matching M
and output the set S of matched vertices

An Approximation Algorithm
for Vertex Cover
• Theorem: The previous algorithm is a
2-approximation algorithm for Vertex Cover
• Proof:
• S is a vertex cover, otherwhise the
matching would not be maximal.
• OPT≥M, where M is the size of the output
maximal matching.
• SOL=2M, as the number of matched
vertices is twice the size of the matching.

Approximation Algorithms:much more…
• Approximation schemes: (1+ε)-approx.
• Inapproximability results.
• Complexity classes, e.g., APX.

Fixed-Parameter Tractable Algorithms

Easy or Hard?
Problem (optimization): Let G be a graph.
Which is the minimum number of vertices
whose deletion makes G planar?

NP-hard 
[Lewis-Yannakakis ]

Easy or Hard?
Problem (decision): Let G be a graph and k
be an integer. Is there a set of k vertices
whose deletion makes G planar?
Polynomial 
• Easy O(nk+1) time algorithm for solving the problem:
• Consider every set of k vertices. Remove such
vertices. Test the planarity of the resulting graph.

• There are O(nk) such sets. Testing the planarity of
an n-vertex graph takes O(n) time. Then,
T(n,k)= O(nk) O(n) = O(nk+1)

Easy or Hard?
Where is the trick?
In the decision version, k is a constant
parameter part of the input
An O(nk+1)-time algorithm, with k constant, is a
polynomial-time algorithm.

But it is very slow 

Fixed-Parameter Tractability
A problem is fixed-parameter tractable
if it can be solved in f(k) nO(1) time,
where k is a parameter of the problem,
f is an arbitrary function, and nO(1) is a
polynomial (not depending on k).

FPT algorithm for Vertex Cover
Theorem [Melhorn]: There is an O(2k n)time algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• There is a vertex cover with k=0 if and only if G
has no edge.
• Consider any edge e=(u,v). Either u or v belongs
to any vertex cover S.
• Consider both the case in which u S and the
case in which v S.

FPT algorithm for Vertex Cover
u

u

v

v

• u  S -> S is a vertex cover of G if and only if
S-{u} is a vertex cover of G-{u} -> solve the
instance (G-{u}, k-1)
• v  S -> S is a vertex cover of G if and only if
S-{v} is a vertex cover of G-{v} -> solve the
instance (G-{v}, k-1)

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• T(n,0) = O(n)
• T(n,k) = 2 T(n-1, k-1) +O(n) ≤ 2 T(n, k-1) +O(n) ≤
2 (2 T(n, k-2) +O(n)) +O(n) ≤
2 (2 (2 T(n, k-3) +O(n)) +O(n)) +O(n) ≤
2 (2 (2 (…(2 T(n, 0)+O(n)) + … +O(n))
+O(n)) +O(n) ≤
2k O(n) + (2k-1 + 2k-2 + 2k-3 + ... + 1) O(n) =
2k O(n) + (2k - 1) O(n) = O(2k n)

Reduction Rules
Reduction rule : a rule (that is, a polynomial time
algorithm) that transforms an instance (I,k) to
an "equivalent and simpler” instance (I', k’).

Equivalent: (I,k) is a YES instance if and only if
(I', k') is a YES instance.
Simpler: |I'|<|I| or k'occurrences of a particular substructure.

Another FPT algorithm for Vertex Cover
Theorem: There is an O(1.6181k n2)-time
algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• We apply the following two reduction rules:
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k).
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u,N(u)},k-1).

Another FPT algorithm for Vertex Cover
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k). Correctness: if S is a vertex
cover of G and u is in S, then S-{u} is also a
vertex cover of G, as u has no incident edge.
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u, N(u)},k-1). Correctness: if S is a
vertex cover of G and u is in S, then
S-{u}  N(u) is also a vertex cover of G, as u
has no other incident edge.

Another FPT algorithm for Vertex Cover
• If neither of the two rules can be applied,
then every vertex has degree at least 2.
• Pick a vertex u. Any vertex cover of G
contains either u or N(u). Thus, (G,k) is a YES
instance if and only if (G-{u},k-1) or
(G-N(u),k-|N(u)|) is.

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• Since |N(u)|\geq 2,
• T(n,k) ≤ T(n,k-1)+ T(n,k-2)+O(n^2).
• Fibonacci series: every number is the sum of
the previous two xk =xk-1 +xk-2 +c.

• The k-th number of the Fibonacci series
tends to the golden ratio to the power of k.
• T(n,k)=Φk O(n2)=((1+√5)/2)k O(n2) =
O(1.6181k n2).

Kernelization
• Sometimes the reduction rules work till the size
of the problem is reduced really a lot. That is,
after the reduction rules have been applied,
the problem has size g(k), for some function k.
In this case the problem has a g(k)-kernel.

• Kernel: given a problem and an instance (I,k), a
kernel is an algorithm that outputs in polynomial
time an instance (I',k') such that (a) (I',k') is a
YES instance if and only if (I,k) is; (b) |I'|and k'
Kernelization
• Theorem [Niedermaier]: Every fixed-parameter
tractable problem has a g(k)-kernel.
• Proof: Suppose that there exists a FPT
algorithm with running time f(k) nc, for some
function f and some constant c. Consider an
instance (I,k) with |I|=n.
• If n>f(k), we run the decision algorithm in time
f(k) nc < nc+1. If it returns YES (NO), the
kernelization algorithm outputs a constant size
YES (resp. NO) instance.
• If n≤f(k), the the kernelization algorithm
returns (I,k).

Kernelization
• The last theorem implies that every problem
that is FPT has a kernel.
• However, the goal is to obtain kernels that are
"small", that is, polynomial in k, or even constant.

FPT: much more…
• Some problems are not FPT (e.g., graph coloring).
• Complexity classes: W[1] -> Can a nondeterministic Turing machine accept an unary
string s in at most k steps?
• Independent Set is W[1]-hard.
• Reductions to W[1]-hard problems give new
W[1]-hard problems.
• Lower bounds for FPT tractability
• Upper and lower bounds for the size of the
kernels

FPT: much more…
• Theorem [Robertson and Seymour]: Every graph
problem with parameter k whose YES istances
are closed under taking minors can be solved in
O(f(k) n3)


Slide 23

Tecniche Algoritmiche per Grafi e Reti
Fabrizio Frati

Dipartimento di Informatica e Automazione
Università degli Studi Roma Tre

• 3 CREDITI
• I° periodo:
• Lunedì 9:45-11:15 aula N13

• II° periodo:
• Venerdì 8:00-9:45 aula N7

• Contatti:
• {angelini,gdb,frati,ratm} @dia.uniroma3.it
• Ricevimento: mercoledì dalle 17 alle 19

• Struttura del Corso
• ~ 8 seminari
• algoritmi, strutture dati, combinatorica,
graph drawing…

• progetti a gruppi di 2 - 4 persone
• problema di ricerca

• Materiale Didattico
• slides
• G. Di Battista, P. Eades, R. Tamassia, I. G.
Tollis, Graph Drawing: Algorithms for the
Visualization of Graphs, 1999. Prentice Hall.

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
C. Computer System Organization
1.
2.
3.
4.
5.

Processor Architectures
Computer-Communication Networks
Application-Based Systems
Performance of Systems
Computer System Implementations

ACM Computing Classification System
C. Computer System Organization
2. Computer-Communication Networks
2.1 Network Architectures
2.2 Network Protocols
2.3 Network Operations
2.4 Distributed Systems
2.5 LAN & WAN
2.6 Internetworking

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
E. Data
1.
2.
3.
4.
5.

Data Structures
Data Storage Representations
Data Encryption
Coding and Information Theory
Files

ACM Computing Classification System
E. Data
1. Data Structures
1.1 Arrays
1.2 Distributed Data Structures
1.3 Graphs and Networks
1.4 Lists, Stacks, and Queues
1.5 Records
1.6 Tables
1.7 Trees

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
F. Theory of Computation
1.
2.
3.
4.

Computation by Abstract Devices
Analysis of Algorithms and Problem Complexity
Logics and Meanings of Programs
Mathematical Logic and Formal Languages

ACM Computing Classification System
F. Theory of Computation
1. Computation by Abstract Devices
1.1 Models of Computation
1.2 Complexity Measures and Completeness
1.2.1 Complexity Hierarchies
1.2.2 Machine-Independent Complexity
1.2.3 Reducibility and Completeness
1.2.4 Relations among Complexity Classes

ACM Computing Classification System
F. Theory of Computation
2. Analysis of Algorithms and Problem Complexity
2.1 Numerical Algorithms
2.2 Non-numerical Algorithms and Problems
2.2.1 Complexity of Proof Procedures
2.2.2 Computations on Discrete Structures
2.2.3 Geometrical Problems
2.2.4 Pattern Matching
2.2.5 Routing and Layout
2.2.6 Sequencing and Scheduling
2.2.7 Sorting and Searching

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
G. Mathematics of Computing
1.
2.
3.
4.

Numerical Analysis
Discrete Mathematics
Probability and Statistics
Mathematical Software

ACM Computing Classification System
G. Mathematics of Computing
2. Discrete Mathematics
2.1 Combinatorics

2.1.1 Combinatorial Algorithms
2.1.2 Counting Problems
2.1.3 Generating Functions
2.1.4 Permutations and Combinations
2.1.5 Recurrences and Difference Equations

2.2 Graph Theory
2.2.1 Graph Algorithms
2.2.2 Graph Labeling

2.2.5 Path and Circuit Problems
2.2.6 Trees

2.3 Applications

a world FULL of NP-hard problems
Problem: I want to travel among a set of
cities driving the fewest possible number
of KMs. IT’S DIFFICULT!!

Problem: I want to put a set of objects
into some bags, knowing that each bag
can not afford more than 10 KGs and
trying to use as few bags as possible.
IT’S DIFFICULT!!

How to Deal with NP-hard problems?
• Exact Algorithms
• Randomized Algorithms
• Approximation Algorithms
• Fixed-Parameter Tractable Algorithms
• …

Approximation Algorithms

Approximation Algorithms
• We want a solution “close” to the
optimal one.
• Given a minimization problem Π, an
algorithm is an α-approximation for Π if,
for every instance I of Π, it outputs a
solution SOL(I) such that
SOL(I)/OPT(I) ≤ α

Vertex Cover
• Problem: Given a graph G(V,E), find a
minimum vertex cover, that is, a set V’  V
such that every edge e  E has an
endvertex in V’.

NP-hard 
[Karp]

How to Guarantee an Approximation?
• We want an approximation algorithm
for Vertex Cover.
• The cost of the solution produced by the
algorithm should be compared with the
cost of an optimal solution.

• But computing the cost of an optimal
solution is NP-HARD!!
LOWER BOUNDS!

Lower Bound for Vertex Cover
• Given a graph G(V,E), a matching M is
a set of edges M  E such that no two
edges share an endvertex.
• A matching is maximal if no matching M’
exists such that M  M’.

• The size of a matching
is a lower bound on the
size of an optimal
solution to Vertex
Cover!

An Approximation Algorithm
for Vertex Cover

• Algorithm: Find a maximal matching M
and output the set S of matched vertices

An Approximation Algorithm
for Vertex Cover
• Theorem: The previous algorithm is a
2-approximation algorithm for Vertex Cover
• Proof:
• S is a vertex cover, otherwhise the
matching would not be maximal.
• OPT≥M, where M is the size of the output
maximal matching.
• SOL=2M, as the number of matched
vertices is twice the size of the matching.

Approximation Algorithms:much more…
• Approximation schemes: (1+ε)-approx.
• Inapproximability results.
• Complexity classes, e.g., APX.

Fixed-Parameter Tractable Algorithms

Easy or Hard?
Problem (optimization): Let G be a graph.
Which is the minimum number of vertices
whose deletion makes G planar?

NP-hard 
[Lewis-Yannakakis ]

Easy or Hard?
Problem (decision): Let G be a graph and k
be an integer. Is there a set of k vertices
whose deletion makes G planar?
Polynomial 
• Easy O(nk+1) time algorithm for solving the problem:
• Consider every set of k vertices. Remove such
vertices. Test the planarity of the resulting graph.

• There are O(nk) such sets. Testing the planarity of
an n-vertex graph takes O(n) time. Then,
T(n,k)= O(nk) O(n) = O(nk+1)

Easy or Hard?
Where is the trick?
In the decision version, k is a constant
parameter part of the input
An O(nk+1)-time algorithm, with k constant, is a
polynomial-time algorithm.

But it is very slow 

Fixed-Parameter Tractability
A problem is fixed-parameter tractable
if it can be solved in f(k) nO(1) time,
where k is a parameter of the problem,
f is an arbitrary function, and nO(1) is a
polynomial (not depending on k).

FPT algorithm for Vertex Cover
Theorem [Melhorn]: There is an O(2k n)time algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• There is a vertex cover with k=0 if and only if G
has no edge.
• Consider any edge e=(u,v). Either u or v belongs
to any vertex cover S.
• Consider both the case in which u S and the
case in which v S.

FPT algorithm for Vertex Cover
u

u

v

v

• u  S -> S is a vertex cover of G if and only if
S-{u} is a vertex cover of G-{u} -> solve the
instance (G-{u}, k-1)
• v  S -> S is a vertex cover of G if and only if
S-{v} is a vertex cover of G-{v} -> solve the
instance (G-{v}, k-1)

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• T(n,0) = O(n)
• T(n,k) = 2 T(n-1, k-1) +O(n) ≤ 2 T(n, k-1) +O(n) ≤
2 (2 T(n, k-2) +O(n)) +O(n) ≤
2 (2 (2 T(n, k-3) +O(n)) +O(n)) +O(n) ≤
2 (2 (2 (…(2 T(n, 0)+O(n)) + … +O(n))
+O(n)) +O(n) ≤
2k O(n) + (2k-1 + 2k-2 + 2k-3 + ... + 1) O(n) =
2k O(n) + (2k - 1) O(n) = O(2k n)

Reduction Rules
Reduction rule : a rule (that is, a polynomial time
algorithm) that transforms an instance (I,k) to
an "equivalent and simpler” instance (I', k’).

Equivalent: (I,k) is a YES instance if and only if
(I', k') is a YES instance.
Simpler: |I'|<|I| or k'occurrences of a particular substructure.

Another FPT algorithm for Vertex Cover
Theorem: There is an O(1.6181k n2)-time
algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• We apply the following two reduction rules:
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k).
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u,N(u)},k-1).

Another FPT algorithm for Vertex Cover
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k). Correctness: if S is a vertex
cover of G and u is in S, then S-{u} is also a
vertex cover of G, as u has no incident edge.
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u, N(u)},k-1). Correctness: if S is a
vertex cover of G and u is in S, then
S-{u}  N(u) is also a vertex cover of G, as u
has no other incident edge.

Another FPT algorithm for Vertex Cover
• If neither of the two rules can be applied,
then every vertex has degree at least 2.
• Pick a vertex u. Any vertex cover of G
contains either u or N(u). Thus, (G,k) is a YES
instance if and only if (G-{u},k-1) or
(G-N(u),k-|N(u)|) is.

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• Since |N(u)|\geq 2,
• T(n,k) ≤ T(n,k-1)+ T(n,k-2)+O(n^2).
• Fibonacci series: every number is the sum of
the previous two xk =xk-1 +xk-2 +c.

• The k-th number of the Fibonacci series
tends to the golden ratio to the power of k.
• T(n,k)=Φk O(n2)=((1+√5)/2)k O(n2) =
O(1.6181k n2).

Kernelization
• Sometimes the reduction rules work till the size
of the problem is reduced really a lot. That is,
after the reduction rules have been applied,
the problem has size g(k), for some function k.
In this case the problem has a g(k)-kernel.

• Kernel: given a problem and an instance (I,k), a
kernel is an algorithm that outputs in polynomial
time an instance (I',k') such that (a) (I',k') is a
YES instance if and only if (I,k) is; (b) |I'|and k'
Kernelization
• Theorem [Niedermaier]: Every fixed-parameter
tractable problem has a g(k)-kernel.
• Proof: Suppose that there exists a FPT
algorithm with running time f(k) nc, for some
function f and some constant c. Consider an
instance (I,k) with |I|=n.
• If n>f(k), we run the decision algorithm in time
f(k) nc < nc+1. If it returns YES (NO), the
kernelization algorithm outputs a constant size
YES (resp. NO) instance.
• If n≤f(k), the the kernelization algorithm
returns (I,k).

Kernelization
• The last theorem implies that every problem
that is FPT has a kernel.
• However, the goal is to obtain kernels that are
"small", that is, polynomial in k, or even constant.

FPT: much more…
• Some problems are not FPT (e.g., graph coloring).
• Complexity classes: W[1] -> Can a nondeterministic Turing machine accept an unary
string s in at most k steps?
• Independent Set is W[1]-hard.
• Reductions to W[1]-hard problems give new
W[1]-hard problems.
• Lower bounds for FPT tractability
• Upper and lower bounds for the size of the
kernels

FPT: much more…
• Theorem [Robertson and Seymour]: Every graph
problem with parameter k whose YES istances
are closed under taking minors can be solved in
O(f(k) n3)


Slide 24

Tecniche Algoritmiche per Grafi e Reti
Fabrizio Frati

Dipartimento di Informatica e Automazione
Università degli Studi Roma Tre

• 3 CREDITI
• I° periodo:
• Lunedì 9:45-11:15 aula N13

• II° periodo:
• Venerdì 8:00-9:45 aula N7

• Contatti:
• {angelini,gdb,frati,ratm} @dia.uniroma3.it
• Ricevimento: mercoledì dalle 17 alle 19

• Struttura del Corso
• ~ 8 seminari
• algoritmi, strutture dati, combinatorica,
graph drawing…

• progetti a gruppi di 2 - 4 persone
• problema di ricerca

• Materiale Didattico
• slides
• G. Di Battista, P. Eades, R. Tamassia, I. G.
Tollis, Graph Drawing: Algorithms for the
Visualization of Graphs, 1999. Prentice Hall.

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
C. Computer System Organization
1.
2.
3.
4.
5.

Processor Architectures
Computer-Communication Networks
Application-Based Systems
Performance of Systems
Computer System Implementations

ACM Computing Classification System
C. Computer System Organization
2. Computer-Communication Networks
2.1 Network Architectures
2.2 Network Protocols
2.3 Network Operations
2.4 Distributed Systems
2.5 LAN & WAN
2.6 Internetworking

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
E. Data
1.
2.
3.
4.
5.

Data Structures
Data Storage Representations
Data Encryption
Coding and Information Theory
Files

ACM Computing Classification System
E. Data
1. Data Structures
1.1 Arrays
1.2 Distributed Data Structures
1.3 Graphs and Networks
1.4 Lists, Stacks, and Queues
1.5 Records
1.6 Tables
1.7 Trees

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
F. Theory of Computation
1.
2.
3.
4.

Computation by Abstract Devices
Analysis of Algorithms and Problem Complexity
Logics and Meanings of Programs
Mathematical Logic and Formal Languages

ACM Computing Classification System
F. Theory of Computation
1. Computation by Abstract Devices
1.1 Models of Computation
1.2 Complexity Measures and Completeness
1.2.1 Complexity Hierarchies
1.2.2 Machine-Independent Complexity
1.2.3 Reducibility and Completeness
1.2.4 Relations among Complexity Classes

ACM Computing Classification System
F. Theory of Computation
2. Analysis of Algorithms and Problem Complexity
2.1 Numerical Algorithms
2.2 Non-numerical Algorithms and Problems
2.2.1 Complexity of Proof Procedures
2.2.2 Computations on Discrete Structures
2.2.3 Geometrical Problems
2.2.4 Pattern Matching
2.2.5 Routing and Layout
2.2.6 Sequencing and Scheduling
2.2.7 Sorting and Searching

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
G. Mathematics of Computing
1.
2.
3.
4.

Numerical Analysis
Discrete Mathematics
Probability and Statistics
Mathematical Software

ACM Computing Classification System
G. Mathematics of Computing
2. Discrete Mathematics
2.1 Combinatorics

2.1.1 Combinatorial Algorithms
2.1.2 Counting Problems
2.1.3 Generating Functions
2.1.4 Permutations and Combinations
2.1.5 Recurrences and Difference Equations

2.2 Graph Theory
2.2.1 Graph Algorithms
2.2.2 Graph Labeling

2.2.5 Path and Circuit Problems
2.2.6 Trees

2.3 Applications

a world FULL of NP-hard problems
Problem: I want to travel among a set of
cities driving the fewest possible number
of KMs. IT’S DIFFICULT!!

Problem: I want to put a set of objects
into some bags, knowing that each bag
can not afford more than 10 KGs and
trying to use as few bags as possible.
IT’S DIFFICULT!!

How to Deal with NP-hard problems?
• Exact Algorithms
• Randomized Algorithms
• Approximation Algorithms
• Fixed-Parameter Tractable Algorithms
• …

Approximation Algorithms

Approximation Algorithms
• We want a solution “close” to the
optimal one.
• Given a minimization problem Π, an
algorithm is an α-approximation for Π if,
for every instance I of Π, it outputs a
solution SOL(I) such that
SOL(I)/OPT(I) ≤ α

Vertex Cover
• Problem: Given a graph G(V,E), find a
minimum vertex cover, that is, a set V’  V
such that every edge e  E has an
endvertex in V’.

NP-hard 
[Karp]

How to Guarantee an Approximation?
• We want an approximation algorithm
for Vertex Cover.
• The cost of the solution produced by the
algorithm should be compared with the
cost of an optimal solution.

• But computing the cost of an optimal
solution is NP-HARD!!
LOWER BOUNDS!

Lower Bound for Vertex Cover
• Given a graph G(V,E), a matching M is
a set of edges M  E such that no two
edges share an endvertex.
• A matching is maximal if no matching M’
exists such that M  M’.

• The size of a matching
is a lower bound on the
size of an optimal
solution to Vertex
Cover!

An Approximation Algorithm
for Vertex Cover

• Algorithm: Find a maximal matching M
and output the set S of matched vertices

An Approximation Algorithm
for Vertex Cover
• Theorem: The previous algorithm is a
2-approximation algorithm for Vertex Cover
• Proof:
• S is a vertex cover, otherwhise the
matching would not be maximal.
• OPT≥M, where M is the size of the output
maximal matching.
• SOL=2M, as the number of matched
vertices is twice the size of the matching.

Approximation Algorithms:much more…
• Approximation schemes: (1+ε)-approx.
• Inapproximability results.
• Complexity classes, e.g., APX.

Fixed-Parameter Tractable Algorithms

Easy or Hard?
Problem (optimization): Let G be a graph.
Which is the minimum number of vertices
whose deletion makes G planar?

NP-hard 
[Lewis-Yannakakis ]

Easy or Hard?
Problem (decision): Let G be a graph and k
be an integer. Is there a set of k vertices
whose deletion makes G planar?
Polynomial 
• Easy O(nk+1) time algorithm for solving the problem:
• Consider every set of k vertices. Remove such
vertices. Test the planarity of the resulting graph.

• There are O(nk) such sets. Testing the planarity of
an n-vertex graph takes O(n) time. Then,
T(n,k)= O(nk) O(n) = O(nk+1)

Easy or Hard?
Where is the trick?
In the decision version, k is a constant
parameter part of the input
An O(nk+1)-time algorithm, with k constant, is a
polynomial-time algorithm.

But it is very slow 

Fixed-Parameter Tractability
A problem is fixed-parameter tractable
if it can be solved in f(k) nO(1) time,
where k is a parameter of the problem,
f is an arbitrary function, and nO(1) is a
polynomial (not depending on k).

FPT algorithm for Vertex Cover
Theorem [Melhorn]: There is an O(2k n)time algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• There is a vertex cover with k=0 if and only if G
has no edge.
• Consider any edge e=(u,v). Either u or v belongs
to any vertex cover S.
• Consider both the case in which u S and the
case in which v S.

FPT algorithm for Vertex Cover
u

u

v

v

• u  S -> S is a vertex cover of G if and only if
S-{u} is a vertex cover of G-{u} -> solve the
instance (G-{u}, k-1)
• v  S -> S is a vertex cover of G if and only if
S-{v} is a vertex cover of G-{v} -> solve the
instance (G-{v}, k-1)

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• T(n,0) = O(n)
• T(n,k) = 2 T(n-1, k-1) +O(n) ≤ 2 T(n, k-1) +O(n) ≤
2 (2 T(n, k-2) +O(n)) +O(n) ≤
2 (2 (2 T(n, k-3) +O(n)) +O(n)) +O(n) ≤
2 (2 (2 (…(2 T(n, 0)+O(n)) + … +O(n))
+O(n)) +O(n) ≤
2k O(n) + (2k-1 + 2k-2 + 2k-3 + ... + 1) O(n) =
2k O(n) + (2k - 1) O(n) = O(2k n)

Reduction Rules
Reduction rule : a rule (that is, a polynomial time
algorithm) that transforms an instance (I,k) to
an "equivalent and simpler” instance (I', k’).

Equivalent: (I,k) is a YES instance if and only if
(I', k') is a YES instance.
Simpler: |I'|<|I| or k'occurrences of a particular substructure.

Another FPT algorithm for Vertex Cover
Theorem: There is an O(1.6181k n2)-time
algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• We apply the following two reduction rules:
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k).
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u,N(u)},k-1).

Another FPT algorithm for Vertex Cover
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k). Correctness: if S is a vertex
cover of G and u is in S, then S-{u} is also a
vertex cover of G, as u has no incident edge.
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u, N(u)},k-1). Correctness: if S is a
vertex cover of G and u is in S, then
S-{u}  N(u) is also a vertex cover of G, as u
has no other incident edge.

Another FPT algorithm for Vertex Cover
• If neither of the two rules can be applied,
then every vertex has degree at least 2.
• Pick a vertex u. Any vertex cover of G
contains either u or N(u). Thus, (G,k) is a YES
instance if and only if (G-{u},k-1) or
(G-N(u),k-|N(u)|) is.

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• Since |N(u)|\geq 2,
• T(n,k) ≤ T(n,k-1)+ T(n,k-2)+O(n^2).
• Fibonacci series: every number is the sum of
the previous two xk =xk-1 +xk-2 +c.

• The k-th number of the Fibonacci series
tends to the golden ratio to the power of k.
• T(n,k)=Φk O(n2)=((1+√5)/2)k O(n2) =
O(1.6181k n2).

Kernelization
• Sometimes the reduction rules work till the size
of the problem is reduced really a lot. That is,
after the reduction rules have been applied,
the problem has size g(k), for some function k.
In this case the problem has a g(k)-kernel.

• Kernel: given a problem and an instance (I,k), a
kernel is an algorithm that outputs in polynomial
time an instance (I',k') such that (a) (I',k') is a
YES instance if and only if (I,k) is; (b) |I'|and k'
Kernelization
• Theorem [Niedermaier]: Every fixed-parameter
tractable problem has a g(k)-kernel.
• Proof: Suppose that there exists a FPT
algorithm with running time f(k) nc, for some
function f and some constant c. Consider an
instance (I,k) with |I|=n.
• If n>f(k), we run the decision algorithm in time
f(k) nc < nc+1. If it returns YES (NO), the
kernelization algorithm outputs a constant size
YES (resp. NO) instance.
• If n≤f(k), the the kernelization algorithm
returns (I,k).

Kernelization
• The last theorem implies that every problem
that is FPT has a kernel.
• However, the goal is to obtain kernels that are
"small", that is, polynomial in k, or even constant.

FPT: much more…
• Some problems are not FPT (e.g., graph coloring).
• Complexity classes: W[1] -> Can a nondeterministic Turing machine accept an unary
string s in at most k steps?
• Independent Set is W[1]-hard.
• Reductions to W[1]-hard problems give new
W[1]-hard problems.
• Lower bounds for FPT tractability
• Upper and lower bounds for the size of the
kernels

FPT: much more…
• Theorem [Robertson and Seymour]: Every graph
problem with parameter k whose YES istances
are closed under taking minors can be solved in
O(f(k) n3)


Slide 25

Tecniche Algoritmiche per Grafi e Reti
Fabrizio Frati

Dipartimento di Informatica e Automazione
Università degli Studi Roma Tre

• 3 CREDITI
• I° periodo:
• Lunedì 9:45-11:15 aula N13

• II° periodo:
• Venerdì 8:00-9:45 aula N7

• Contatti:
• {angelini,gdb,frati,ratm} @dia.uniroma3.it
• Ricevimento: mercoledì dalle 17 alle 19

• Struttura del Corso
• ~ 8 seminari
• algoritmi, strutture dati, combinatorica,
graph drawing…

• progetti a gruppi di 2 - 4 persone
• problema di ricerca

• Materiale Didattico
• slides
• G. Di Battista, P. Eades, R. Tamassia, I. G.
Tollis, Graph Drawing: Algorithms for the
Visualization of Graphs, 1999. Prentice Hall.

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
C. Computer System Organization
1.
2.
3.
4.
5.

Processor Architectures
Computer-Communication Networks
Application-Based Systems
Performance of Systems
Computer System Implementations

ACM Computing Classification System
C. Computer System Organization
2. Computer-Communication Networks
2.1 Network Architectures
2.2 Network Protocols
2.3 Network Operations
2.4 Distributed Systems
2.5 LAN & WAN
2.6 Internetworking

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
E. Data
1.
2.
3.
4.
5.

Data Structures
Data Storage Representations
Data Encryption
Coding and Information Theory
Files

ACM Computing Classification System
E. Data
1. Data Structures
1.1 Arrays
1.2 Distributed Data Structures
1.3 Graphs and Networks
1.4 Lists, Stacks, and Queues
1.5 Records
1.6 Tables
1.7 Trees

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
F. Theory of Computation
1.
2.
3.
4.

Computation by Abstract Devices
Analysis of Algorithms and Problem Complexity
Logics and Meanings of Programs
Mathematical Logic and Formal Languages

ACM Computing Classification System
F. Theory of Computation
1. Computation by Abstract Devices
1.1 Models of Computation
1.2 Complexity Measures and Completeness
1.2.1 Complexity Hierarchies
1.2.2 Machine-Independent Complexity
1.2.3 Reducibility and Completeness
1.2.4 Relations among Complexity Classes

ACM Computing Classification System
F. Theory of Computation
2. Analysis of Algorithms and Problem Complexity
2.1 Numerical Algorithms
2.2 Non-numerical Algorithms and Problems
2.2.1 Complexity of Proof Procedures
2.2.2 Computations on Discrete Structures
2.2.3 Geometrical Problems
2.2.4 Pattern Matching
2.2.5 Routing and Layout
2.2.6 Sequencing and Scheduling
2.2.7 Sorting and Searching

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
G. Mathematics of Computing
1.
2.
3.
4.

Numerical Analysis
Discrete Mathematics
Probability and Statistics
Mathematical Software

ACM Computing Classification System
G. Mathematics of Computing
2. Discrete Mathematics
2.1 Combinatorics

2.1.1 Combinatorial Algorithms
2.1.2 Counting Problems
2.1.3 Generating Functions
2.1.4 Permutations and Combinations
2.1.5 Recurrences and Difference Equations

2.2 Graph Theory
2.2.1 Graph Algorithms
2.2.2 Graph Labeling

2.2.5 Path and Circuit Problems
2.2.6 Trees

2.3 Applications

a world FULL of NP-hard problems
Problem: I want to travel among a set of
cities driving the fewest possible number
of KMs. IT’S DIFFICULT!!

Problem: I want to put a set of objects
into some bags, knowing that each bag
can not afford more than 10 KGs and
trying to use as few bags as possible.
IT’S DIFFICULT!!

How to Deal with NP-hard problems?
• Exact Algorithms
• Randomized Algorithms
• Approximation Algorithms
• Fixed-Parameter Tractable Algorithms
• …

Approximation Algorithms

Approximation Algorithms
• We want a solution “close” to the
optimal one.
• Given a minimization problem Π, an
algorithm is an α-approximation for Π if,
for every instance I of Π, it outputs a
solution SOL(I) such that
SOL(I)/OPT(I) ≤ α

Vertex Cover
• Problem: Given a graph G(V,E), find a
minimum vertex cover, that is, a set V’  V
such that every edge e  E has an
endvertex in V’.

NP-hard 
[Karp]

How to Guarantee an Approximation?
• We want an approximation algorithm
for Vertex Cover.
• The cost of the solution produced by the
algorithm should be compared with the
cost of an optimal solution.

• But computing the cost of an optimal
solution is NP-HARD!!
LOWER BOUNDS!

Lower Bound for Vertex Cover
• Given a graph G(V,E), a matching M is
a set of edges M  E such that no two
edges share an endvertex.
• A matching is maximal if no matching M’
exists such that M  M’.

• The size of a matching
is a lower bound on the
size of an optimal
solution to Vertex
Cover!

An Approximation Algorithm
for Vertex Cover

• Algorithm: Find a maximal matching M
and output the set S of matched vertices

An Approximation Algorithm
for Vertex Cover
• Theorem: The previous algorithm is a
2-approximation algorithm for Vertex Cover
• Proof:
• S is a vertex cover, otherwhise the
matching would not be maximal.
• OPT≥M, where M is the size of the output
maximal matching.
• SOL=2M, as the number of matched
vertices is twice the size of the matching.

Approximation Algorithms:much more…
• Approximation schemes: (1+ε)-approx.
• Inapproximability results.
• Complexity classes, e.g., APX.

Fixed-Parameter Tractable Algorithms

Easy or Hard?
Problem (optimization): Let G be a graph.
Which is the minimum number of vertices
whose deletion makes G planar?

NP-hard 
[Lewis-Yannakakis ]

Easy or Hard?
Problem (decision): Let G be a graph and k
be an integer. Is there a set of k vertices
whose deletion makes G planar?
Polynomial 
• Easy O(nk+1) time algorithm for solving the problem:
• Consider every set of k vertices. Remove such
vertices. Test the planarity of the resulting graph.

• There are O(nk) such sets. Testing the planarity of
an n-vertex graph takes O(n) time. Then,
T(n,k)= O(nk) O(n) = O(nk+1)

Easy or Hard?
Where is the trick?
In the decision version, k is a constant
parameter part of the input
An O(nk+1)-time algorithm, with k constant, is a
polynomial-time algorithm.

But it is very slow 

Fixed-Parameter Tractability
A problem is fixed-parameter tractable
if it can be solved in f(k) nO(1) time,
where k is a parameter of the problem,
f is an arbitrary function, and nO(1) is a
polynomial (not depending on k).

FPT algorithm for Vertex Cover
Theorem [Melhorn]: There is an O(2k n)time algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• There is a vertex cover with k=0 if and only if G
has no edge.
• Consider any edge e=(u,v). Either u or v belongs
to any vertex cover S.
• Consider both the case in which u S and the
case in which v S.

FPT algorithm for Vertex Cover
u

u

v

v

• u  S -> S is a vertex cover of G if and only if
S-{u} is a vertex cover of G-{u} -> solve the
instance (G-{u}, k-1)
• v  S -> S is a vertex cover of G if and only if
S-{v} is a vertex cover of G-{v} -> solve the
instance (G-{v}, k-1)

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• T(n,0) = O(n)
• T(n,k) = 2 T(n-1, k-1) +O(n) ≤ 2 T(n, k-1) +O(n) ≤
2 (2 T(n, k-2) +O(n)) +O(n) ≤
2 (2 (2 T(n, k-3) +O(n)) +O(n)) +O(n) ≤
2 (2 (2 (…(2 T(n, 0)+O(n)) + … +O(n))
+O(n)) +O(n) ≤
2k O(n) + (2k-1 + 2k-2 + 2k-3 + ... + 1) O(n) =
2k O(n) + (2k - 1) O(n) = O(2k n)

Reduction Rules
Reduction rule : a rule (that is, a polynomial time
algorithm) that transforms an instance (I,k) to
an "equivalent and simpler” instance (I', k’).

Equivalent: (I,k) is a YES instance if and only if
(I', k') is a YES instance.
Simpler: |I'|<|I| or k'occurrences of a particular substructure.

Another FPT algorithm for Vertex Cover
Theorem: There is an O(1.6181k n2)-time
algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• We apply the following two reduction rules:
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k).
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u,N(u)},k-1).

Another FPT algorithm for Vertex Cover
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k). Correctness: if S is a vertex
cover of G and u is in S, then S-{u} is also a
vertex cover of G, as u has no incident edge.
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u, N(u)},k-1). Correctness: if S is a
vertex cover of G and u is in S, then
S-{u}  N(u) is also a vertex cover of G, as u
has no other incident edge.

Another FPT algorithm for Vertex Cover
• If neither of the two rules can be applied,
then every vertex has degree at least 2.
• Pick a vertex u. Any vertex cover of G
contains either u or N(u). Thus, (G,k) is a YES
instance if and only if (G-{u},k-1) or
(G-N(u),k-|N(u)|) is.

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• Since |N(u)|\geq 2,
• T(n,k) ≤ T(n,k-1)+ T(n,k-2)+O(n^2).
• Fibonacci series: every number is the sum of
the previous two xk =xk-1 +xk-2 +c.

• The k-th number of the Fibonacci series
tends to the golden ratio to the power of k.
• T(n,k)=Φk O(n2)=((1+√5)/2)k O(n2) =
O(1.6181k n2).

Kernelization
• Sometimes the reduction rules work till the size
of the problem is reduced really a lot. That is,
after the reduction rules have been applied,
the problem has size g(k), for some function k.
In this case the problem has a g(k)-kernel.

• Kernel: given a problem and an instance (I,k), a
kernel is an algorithm that outputs in polynomial
time an instance (I',k') such that (a) (I',k') is a
YES instance if and only if (I,k) is; (b) |I'|and k'
Kernelization
• Theorem [Niedermaier]: Every fixed-parameter
tractable problem has a g(k)-kernel.
• Proof: Suppose that there exists a FPT
algorithm with running time f(k) nc, for some
function f and some constant c. Consider an
instance (I,k) with |I|=n.
• If n>f(k), we run the decision algorithm in time
f(k) nc < nc+1. If it returns YES (NO), the
kernelization algorithm outputs a constant size
YES (resp. NO) instance.
• If n≤f(k), the the kernelization algorithm
returns (I,k).

Kernelization
• The last theorem implies that every problem
that is FPT has a kernel.
• However, the goal is to obtain kernels that are
"small", that is, polynomial in k, or even constant.

FPT: much more…
• Some problems are not FPT (e.g., graph coloring).
• Complexity classes: W[1] -> Can a nondeterministic Turing machine accept an unary
string s in at most k steps?
• Independent Set is W[1]-hard.
• Reductions to W[1]-hard problems give new
W[1]-hard problems.
• Lower bounds for FPT tractability
• Upper and lower bounds for the size of the
kernels

FPT: much more…
• Theorem [Robertson and Seymour]: Every graph
problem with parameter k whose YES istances
are closed under taking minors can be solved in
O(f(k) n3)


Slide 26

Tecniche Algoritmiche per Grafi e Reti
Fabrizio Frati

Dipartimento di Informatica e Automazione
Università degli Studi Roma Tre

• 3 CREDITI
• I° periodo:
• Lunedì 9:45-11:15 aula N13

• II° periodo:
• Venerdì 8:00-9:45 aula N7

• Contatti:
• {angelini,gdb,frati,ratm} @dia.uniroma3.it
• Ricevimento: mercoledì dalle 17 alle 19

• Struttura del Corso
• ~ 8 seminari
• algoritmi, strutture dati, combinatorica,
graph drawing…

• progetti a gruppi di 2 - 4 persone
• problema di ricerca

• Materiale Didattico
• slides
• G. Di Battista, P. Eades, R. Tamassia, I. G.
Tollis, Graph Drawing: Algorithms for the
Visualization of Graphs, 1999. Prentice Hall.

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
C. Computer System Organization
1.
2.
3.
4.
5.

Processor Architectures
Computer-Communication Networks
Application-Based Systems
Performance of Systems
Computer System Implementations

ACM Computing Classification System
C. Computer System Organization
2. Computer-Communication Networks
2.1 Network Architectures
2.2 Network Protocols
2.3 Network Operations
2.4 Distributed Systems
2.5 LAN & WAN
2.6 Internetworking

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
E. Data
1.
2.
3.
4.
5.

Data Structures
Data Storage Representations
Data Encryption
Coding and Information Theory
Files

ACM Computing Classification System
E. Data
1. Data Structures
1.1 Arrays
1.2 Distributed Data Structures
1.3 Graphs and Networks
1.4 Lists, Stacks, and Queues
1.5 Records
1.6 Tables
1.7 Trees

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
F. Theory of Computation
1.
2.
3.
4.

Computation by Abstract Devices
Analysis of Algorithms and Problem Complexity
Logics and Meanings of Programs
Mathematical Logic and Formal Languages

ACM Computing Classification System
F. Theory of Computation
1. Computation by Abstract Devices
1.1 Models of Computation
1.2 Complexity Measures and Completeness
1.2.1 Complexity Hierarchies
1.2.2 Machine-Independent Complexity
1.2.3 Reducibility and Completeness
1.2.4 Relations among Complexity Classes

ACM Computing Classification System
F. Theory of Computation
2. Analysis of Algorithms and Problem Complexity
2.1 Numerical Algorithms
2.2 Non-numerical Algorithms and Problems
2.2.1 Complexity of Proof Procedures
2.2.2 Computations on Discrete Structures
2.2.3 Geometrical Problems
2.2.4 Pattern Matching
2.2.5 Routing and Layout
2.2.6 Sequencing and Scheduling
2.2.7 Sorting and Searching

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
G. Mathematics of Computing
1.
2.
3.
4.

Numerical Analysis
Discrete Mathematics
Probability and Statistics
Mathematical Software

ACM Computing Classification System
G. Mathematics of Computing
2. Discrete Mathematics
2.1 Combinatorics

2.1.1 Combinatorial Algorithms
2.1.2 Counting Problems
2.1.3 Generating Functions
2.1.4 Permutations and Combinations
2.1.5 Recurrences and Difference Equations

2.2 Graph Theory
2.2.1 Graph Algorithms
2.2.2 Graph Labeling

2.2.5 Path and Circuit Problems
2.2.6 Trees

2.3 Applications

a world FULL of NP-hard problems
Problem: I want to travel among a set of
cities driving the fewest possible number
of KMs. IT’S DIFFICULT!!

Problem: I want to put a set of objects
into some bags, knowing that each bag
can not afford more than 10 KGs and
trying to use as few bags as possible.
IT’S DIFFICULT!!

How to Deal with NP-hard problems?
• Exact Algorithms
• Randomized Algorithms
• Approximation Algorithms
• Fixed-Parameter Tractable Algorithms
• …

Approximation Algorithms

Approximation Algorithms
• We want a solution “close” to the
optimal one.
• Given a minimization problem Π, an
algorithm is an α-approximation for Π if,
for every instance I of Π, it outputs a
solution SOL(I) such that
SOL(I)/OPT(I) ≤ α

Vertex Cover
• Problem: Given a graph G(V,E), find a
minimum vertex cover, that is, a set V’  V
such that every edge e  E has an
endvertex in V’.

NP-hard 
[Karp]

How to Guarantee an Approximation?
• We want an approximation algorithm
for Vertex Cover.
• The cost of the solution produced by the
algorithm should be compared with the
cost of an optimal solution.

• But computing the cost of an optimal
solution is NP-HARD!!
LOWER BOUNDS!

Lower Bound for Vertex Cover
• Given a graph G(V,E), a matching M is
a set of edges M  E such that no two
edges share an endvertex.
• A matching is maximal if no matching M’
exists such that M  M’.

• The size of a matching
is a lower bound on the
size of an optimal
solution to Vertex
Cover!

An Approximation Algorithm
for Vertex Cover

• Algorithm: Find a maximal matching M
and output the set S of matched vertices

An Approximation Algorithm
for Vertex Cover
• Theorem: The previous algorithm is a
2-approximation algorithm for Vertex Cover
• Proof:
• S is a vertex cover, otherwhise the
matching would not be maximal.
• OPT≥M, where M is the size of the output
maximal matching.
• SOL=2M, as the number of matched
vertices is twice the size of the matching.

Approximation Algorithms:much more…
• Approximation schemes: (1+ε)-approx.
• Inapproximability results.
• Complexity classes, e.g., APX.

Fixed-Parameter Tractable Algorithms

Easy or Hard?
Problem (optimization): Let G be a graph.
Which is the minimum number of vertices
whose deletion makes G planar?

NP-hard 
[Lewis-Yannakakis ]

Easy or Hard?
Problem (decision): Let G be a graph and k
be an integer. Is there a set of k vertices
whose deletion makes G planar?
Polynomial 
• Easy O(nk+1) time algorithm for solving the problem:
• Consider every set of k vertices. Remove such
vertices. Test the planarity of the resulting graph.

• There are O(nk) such sets. Testing the planarity of
an n-vertex graph takes O(n) time. Then,
T(n,k)= O(nk) O(n) = O(nk+1)

Easy or Hard?
Where is the trick?
In the decision version, k is a constant
parameter part of the input
An O(nk+1)-time algorithm, with k constant, is a
polynomial-time algorithm.

But it is very slow 

Fixed-Parameter Tractability
A problem is fixed-parameter tractable
if it can be solved in f(k) nO(1) time,
where k is a parameter of the problem,
f is an arbitrary function, and nO(1) is a
polynomial (not depending on k).

FPT algorithm for Vertex Cover
Theorem [Melhorn]: There is an O(2k n)time algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• There is a vertex cover with k=0 if and only if G
has no edge.
• Consider any edge e=(u,v). Either u or v belongs
to any vertex cover S.
• Consider both the case in which u S and the
case in which v S.

FPT algorithm for Vertex Cover
u

u

v

v

• u  S -> S is a vertex cover of G if and only if
S-{u} is a vertex cover of G-{u} -> solve the
instance (G-{u}, k-1)
• v  S -> S is a vertex cover of G if and only if
S-{v} is a vertex cover of G-{v} -> solve the
instance (G-{v}, k-1)

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• T(n,0) = O(n)
• T(n,k) = 2 T(n-1, k-1) +O(n) ≤ 2 T(n, k-1) +O(n) ≤
2 (2 T(n, k-2) +O(n)) +O(n) ≤
2 (2 (2 T(n, k-3) +O(n)) +O(n)) +O(n) ≤
2 (2 (2 (…(2 T(n, 0)+O(n)) + … +O(n))
+O(n)) +O(n) ≤
2k O(n) + (2k-1 + 2k-2 + 2k-3 + ... + 1) O(n) =
2k O(n) + (2k - 1) O(n) = O(2k n)

Reduction Rules
Reduction rule : a rule (that is, a polynomial time
algorithm) that transforms an instance (I,k) to
an "equivalent and simpler” instance (I', k’).

Equivalent: (I,k) is a YES instance if and only if
(I', k') is a YES instance.
Simpler: |I'|<|I| or k'occurrences of a particular substructure.

Another FPT algorithm for Vertex Cover
Theorem: There is an O(1.6181k n2)-time
algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• We apply the following two reduction rules:
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k).
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u,N(u)},k-1).

Another FPT algorithm for Vertex Cover
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k). Correctness: if S is a vertex
cover of G and u is in S, then S-{u} is also a
vertex cover of G, as u has no incident edge.
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u, N(u)},k-1). Correctness: if S is a
vertex cover of G and u is in S, then
S-{u}  N(u) is also a vertex cover of G, as u
has no other incident edge.

Another FPT algorithm for Vertex Cover
• If neither of the two rules can be applied,
then every vertex has degree at least 2.
• Pick a vertex u. Any vertex cover of G
contains either u or N(u). Thus, (G,k) is a YES
instance if and only if (G-{u},k-1) or
(G-N(u),k-|N(u)|) is.

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• Since |N(u)|\geq 2,
• T(n,k) ≤ T(n,k-1)+ T(n,k-2)+O(n^2).
• Fibonacci series: every number is the sum of
the previous two xk =xk-1 +xk-2 +c.

• The k-th number of the Fibonacci series
tends to the golden ratio to the power of k.
• T(n,k)=Φk O(n2)=((1+√5)/2)k O(n2) =
O(1.6181k n2).

Kernelization
• Sometimes the reduction rules work till the size
of the problem is reduced really a lot. That is,
after the reduction rules have been applied,
the problem has size g(k), for some function k.
In this case the problem has a g(k)-kernel.

• Kernel: given a problem and an instance (I,k), a
kernel is an algorithm that outputs in polynomial
time an instance (I',k') such that (a) (I',k') is a
YES instance if and only if (I,k) is; (b) |I'|and k'
Kernelization
• Theorem [Niedermaier]: Every fixed-parameter
tractable problem has a g(k)-kernel.
• Proof: Suppose that there exists a FPT
algorithm with running time f(k) nc, for some
function f and some constant c. Consider an
instance (I,k) with |I|=n.
• If n>f(k), we run the decision algorithm in time
f(k) nc < nc+1. If it returns YES (NO), the
kernelization algorithm outputs a constant size
YES (resp. NO) instance.
• If n≤f(k), the the kernelization algorithm
returns (I,k).

Kernelization
• The last theorem implies that every problem
that is FPT has a kernel.
• However, the goal is to obtain kernels that are
"small", that is, polynomial in k, or even constant.

FPT: much more…
• Some problems are not FPT (e.g., graph coloring).
• Complexity classes: W[1] -> Can a nondeterministic Turing machine accept an unary
string s in at most k steps?
• Independent Set is W[1]-hard.
• Reductions to W[1]-hard problems give new
W[1]-hard problems.
• Lower bounds for FPT tractability
• Upper and lower bounds for the size of the
kernels

FPT: much more…
• Theorem [Robertson and Seymour]: Every graph
problem with parameter k whose YES istances
are closed under taking minors can be solved in
O(f(k) n3)


Slide 27

Tecniche Algoritmiche per Grafi e Reti
Fabrizio Frati

Dipartimento di Informatica e Automazione
Università degli Studi Roma Tre

• 3 CREDITI
• I° periodo:
• Lunedì 9:45-11:15 aula N13

• II° periodo:
• Venerdì 8:00-9:45 aula N7

• Contatti:
• {angelini,gdb,frati,ratm} @dia.uniroma3.it
• Ricevimento: mercoledì dalle 17 alle 19

• Struttura del Corso
• ~ 8 seminari
• algoritmi, strutture dati, combinatorica,
graph drawing…

• progetti a gruppi di 2 - 4 persone
• problema di ricerca

• Materiale Didattico
• slides
• G. Di Battista, P. Eades, R. Tamassia, I. G.
Tollis, Graph Drawing: Algorithms for the
Visualization of Graphs, 1999. Prentice Hall.

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
C. Computer System Organization
1.
2.
3.
4.
5.

Processor Architectures
Computer-Communication Networks
Application-Based Systems
Performance of Systems
Computer System Implementations

ACM Computing Classification System
C. Computer System Organization
2. Computer-Communication Networks
2.1 Network Architectures
2.2 Network Protocols
2.3 Network Operations
2.4 Distributed Systems
2.5 LAN & WAN
2.6 Internetworking

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
E. Data
1.
2.
3.
4.
5.

Data Structures
Data Storage Representations
Data Encryption
Coding and Information Theory
Files

ACM Computing Classification System
E. Data
1. Data Structures
1.1 Arrays
1.2 Distributed Data Structures
1.3 Graphs and Networks
1.4 Lists, Stacks, and Queues
1.5 Records
1.6 Tables
1.7 Trees

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
F. Theory of Computation
1.
2.
3.
4.

Computation by Abstract Devices
Analysis of Algorithms and Problem Complexity
Logics and Meanings of Programs
Mathematical Logic and Formal Languages

ACM Computing Classification System
F. Theory of Computation
1. Computation by Abstract Devices
1.1 Models of Computation
1.2 Complexity Measures and Completeness
1.2.1 Complexity Hierarchies
1.2.2 Machine-Independent Complexity
1.2.3 Reducibility and Completeness
1.2.4 Relations among Complexity Classes

ACM Computing Classification System
F. Theory of Computation
2. Analysis of Algorithms and Problem Complexity
2.1 Numerical Algorithms
2.2 Non-numerical Algorithms and Problems
2.2.1 Complexity of Proof Procedures
2.2.2 Computations on Discrete Structures
2.2.3 Geometrical Problems
2.2.4 Pattern Matching
2.2.5 Routing and Layout
2.2.6 Sequencing and Scheduling
2.2.7 Sorting and Searching

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
G. Mathematics of Computing
1.
2.
3.
4.

Numerical Analysis
Discrete Mathematics
Probability and Statistics
Mathematical Software

ACM Computing Classification System
G. Mathematics of Computing
2. Discrete Mathematics
2.1 Combinatorics

2.1.1 Combinatorial Algorithms
2.1.2 Counting Problems
2.1.3 Generating Functions
2.1.4 Permutations and Combinations
2.1.5 Recurrences and Difference Equations

2.2 Graph Theory
2.2.1 Graph Algorithms
2.2.2 Graph Labeling

2.2.5 Path and Circuit Problems
2.2.6 Trees

2.3 Applications

a world FULL of NP-hard problems
Problem: I want to travel among a set of
cities driving the fewest possible number
of KMs. IT’S DIFFICULT!!

Problem: I want to put a set of objects
into some bags, knowing that each bag
can not afford more than 10 KGs and
trying to use as few bags as possible.
IT’S DIFFICULT!!

How to Deal with NP-hard problems?
• Exact Algorithms
• Randomized Algorithms
• Approximation Algorithms
• Fixed-Parameter Tractable Algorithms
• …

Approximation Algorithms

Approximation Algorithms
• We want a solution “close” to the
optimal one.
• Given a minimization problem Π, an
algorithm is an α-approximation for Π if,
for every instance I of Π, it outputs a
solution SOL(I) such that
SOL(I)/OPT(I) ≤ α

Vertex Cover
• Problem: Given a graph G(V,E), find a
minimum vertex cover, that is, a set V’  V
such that every edge e  E has an
endvertex in V’.

NP-hard 
[Karp]

How to Guarantee an Approximation?
• We want an approximation algorithm
for Vertex Cover.
• The cost of the solution produced by the
algorithm should be compared with the
cost of an optimal solution.

• But computing the cost of an optimal
solution is NP-HARD!!
LOWER BOUNDS!

Lower Bound for Vertex Cover
• Given a graph G(V,E), a matching M is
a set of edges M  E such that no two
edges share an endvertex.
• A matching is maximal if no matching M’
exists such that M  M’.

• The size of a matching
is a lower bound on the
size of an optimal
solution to Vertex
Cover!

An Approximation Algorithm
for Vertex Cover

• Algorithm: Find a maximal matching M
and output the set S of matched vertices

An Approximation Algorithm
for Vertex Cover
• Theorem: The previous algorithm is a
2-approximation algorithm for Vertex Cover
• Proof:
• S is a vertex cover, otherwhise the
matching would not be maximal.
• OPT≥M, where M is the size of the output
maximal matching.
• SOL=2M, as the number of matched
vertices is twice the size of the matching.

Approximation Algorithms:much more…
• Approximation schemes: (1+ε)-approx.
• Inapproximability results.
• Complexity classes, e.g., APX.

Fixed-Parameter Tractable Algorithms

Easy or Hard?
Problem (optimization): Let G be a graph.
Which is the minimum number of vertices
whose deletion makes G planar?

NP-hard 
[Lewis-Yannakakis ]

Easy or Hard?
Problem (decision): Let G be a graph and k
be an integer. Is there a set of k vertices
whose deletion makes G planar?
Polynomial 
• Easy O(nk+1) time algorithm for solving the problem:
• Consider every set of k vertices. Remove such
vertices. Test the planarity of the resulting graph.

• There are O(nk) such sets. Testing the planarity of
an n-vertex graph takes O(n) time. Then,
T(n,k)= O(nk) O(n) = O(nk+1)

Easy or Hard?
Where is the trick?
In the decision version, k is a constant
parameter part of the input
An O(nk+1)-time algorithm, with k constant, is a
polynomial-time algorithm.

But it is very slow 

Fixed-Parameter Tractability
A problem is fixed-parameter tractable
if it can be solved in f(k) nO(1) time,
where k is a parameter of the problem,
f is an arbitrary function, and nO(1) is a
polynomial (not depending on k).

FPT algorithm for Vertex Cover
Theorem [Melhorn]: There is an O(2k n)time algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• There is a vertex cover with k=0 if and only if G
has no edge.
• Consider any edge e=(u,v). Either u or v belongs
to any vertex cover S.
• Consider both the case in which u S and the
case in which v S.

FPT algorithm for Vertex Cover
u

u

v

v

• u  S -> S is a vertex cover of G if and only if
S-{u} is a vertex cover of G-{u} -> solve the
instance (G-{u}, k-1)
• v  S -> S is a vertex cover of G if and only if
S-{v} is a vertex cover of G-{v} -> solve the
instance (G-{v}, k-1)

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• T(n,0) = O(n)
• T(n,k) = 2 T(n-1, k-1) +O(n) ≤ 2 T(n, k-1) +O(n) ≤
2 (2 T(n, k-2) +O(n)) +O(n) ≤
2 (2 (2 T(n, k-3) +O(n)) +O(n)) +O(n) ≤
2 (2 (2 (…(2 T(n, 0)+O(n)) + … +O(n))
+O(n)) +O(n) ≤
2k O(n) + (2k-1 + 2k-2 + 2k-3 + ... + 1) O(n) =
2k O(n) + (2k - 1) O(n) = O(2k n)

Reduction Rules
Reduction rule : a rule (that is, a polynomial time
algorithm) that transforms an instance (I,k) to
an "equivalent and simpler” instance (I', k’).

Equivalent: (I,k) is a YES instance if and only if
(I', k') is a YES instance.
Simpler: |I'|<|I| or k'occurrences of a particular substructure.

Another FPT algorithm for Vertex Cover
Theorem: There is an O(1.6181k n2)-time
algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• We apply the following two reduction rules:
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k).
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u,N(u)},k-1).

Another FPT algorithm for Vertex Cover
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k). Correctness: if S is a vertex
cover of G and u is in S, then S-{u} is also a
vertex cover of G, as u has no incident edge.
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u, N(u)},k-1). Correctness: if S is a
vertex cover of G and u is in S, then
S-{u}  N(u) is also a vertex cover of G, as u
has no other incident edge.

Another FPT algorithm for Vertex Cover
• If neither of the two rules can be applied,
then every vertex has degree at least 2.
• Pick a vertex u. Any vertex cover of G
contains either u or N(u). Thus, (G,k) is a YES
instance if and only if (G-{u},k-1) or
(G-N(u),k-|N(u)|) is.

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• Since |N(u)|\geq 2,
• T(n,k) ≤ T(n,k-1)+ T(n,k-2)+O(n^2).
• Fibonacci series: every number is the sum of
the previous two xk =xk-1 +xk-2 +c.

• The k-th number of the Fibonacci series
tends to the golden ratio to the power of k.
• T(n,k)=Φk O(n2)=((1+√5)/2)k O(n2) =
O(1.6181k n2).

Kernelization
• Sometimes the reduction rules work till the size
of the problem is reduced really a lot. That is,
after the reduction rules have been applied,
the problem has size g(k), for some function k.
In this case the problem has a g(k)-kernel.

• Kernel: given a problem and an instance (I,k), a
kernel is an algorithm that outputs in polynomial
time an instance (I',k') such that (a) (I',k') is a
YES instance if and only if (I,k) is; (b) |I'|and k'
Kernelization
• Theorem [Niedermaier]: Every fixed-parameter
tractable problem has a g(k)-kernel.
• Proof: Suppose that there exists a FPT
algorithm with running time f(k) nc, for some
function f and some constant c. Consider an
instance (I,k) with |I|=n.
• If n>f(k), we run the decision algorithm in time
f(k) nc < nc+1. If it returns YES (NO), the
kernelization algorithm outputs a constant size
YES (resp. NO) instance.
• If n≤f(k), the the kernelization algorithm
returns (I,k).

Kernelization
• The last theorem implies that every problem
that is FPT has a kernel.
• However, the goal is to obtain kernels that are
"small", that is, polynomial in k, or even constant.

FPT: much more…
• Some problems are not FPT (e.g., graph coloring).
• Complexity classes: W[1] -> Can a nondeterministic Turing machine accept an unary
string s in at most k steps?
• Independent Set is W[1]-hard.
• Reductions to W[1]-hard problems give new
W[1]-hard problems.
• Lower bounds for FPT tractability
• Upper and lower bounds for the size of the
kernels

FPT: much more…
• Theorem [Robertson and Seymour]: Every graph
problem with parameter k whose YES istances
are closed under taking minors can be solved in
O(f(k) n3)


Slide 28

Tecniche Algoritmiche per Grafi e Reti
Fabrizio Frati

Dipartimento di Informatica e Automazione
Università degli Studi Roma Tre

• 3 CREDITI
• I° periodo:
• Lunedì 9:45-11:15 aula N13

• II° periodo:
• Venerdì 8:00-9:45 aula N7

• Contatti:
• {angelini,gdb,frati,ratm} @dia.uniroma3.it
• Ricevimento: mercoledì dalle 17 alle 19

• Struttura del Corso
• ~ 8 seminari
• algoritmi, strutture dati, combinatorica,
graph drawing…

• progetti a gruppi di 2 - 4 persone
• problema di ricerca

• Materiale Didattico
• slides
• G. Di Battista, P. Eades, R. Tamassia, I. G.
Tollis, Graph Drawing: Algorithms for the
Visualization of Graphs, 1999. Prentice Hall.

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
C. Computer System Organization
1.
2.
3.
4.
5.

Processor Architectures
Computer-Communication Networks
Application-Based Systems
Performance of Systems
Computer System Implementations

ACM Computing Classification System
C. Computer System Organization
2. Computer-Communication Networks
2.1 Network Architectures
2.2 Network Protocols
2.3 Network Operations
2.4 Distributed Systems
2.5 LAN & WAN
2.6 Internetworking

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
E. Data
1.
2.
3.
4.
5.

Data Structures
Data Storage Representations
Data Encryption
Coding and Information Theory
Files

ACM Computing Classification System
E. Data
1. Data Structures
1.1 Arrays
1.2 Distributed Data Structures
1.3 Graphs and Networks
1.4 Lists, Stacks, and Queues
1.5 Records
1.6 Tables
1.7 Trees

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
F. Theory of Computation
1.
2.
3.
4.

Computation by Abstract Devices
Analysis of Algorithms and Problem Complexity
Logics and Meanings of Programs
Mathematical Logic and Formal Languages

ACM Computing Classification System
F. Theory of Computation
1. Computation by Abstract Devices
1.1 Models of Computation
1.2 Complexity Measures and Completeness
1.2.1 Complexity Hierarchies
1.2.2 Machine-Independent Complexity
1.2.3 Reducibility and Completeness
1.2.4 Relations among Complexity Classes

ACM Computing Classification System
F. Theory of Computation
2. Analysis of Algorithms and Problem Complexity
2.1 Numerical Algorithms
2.2 Non-numerical Algorithms and Problems
2.2.1 Complexity of Proof Procedures
2.2.2 Computations on Discrete Structures
2.2.3 Geometrical Problems
2.2.4 Pattern Matching
2.2.5 Routing and Layout
2.2.6 Sequencing and Scheduling
2.2.7 Sorting and Searching

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
G. Mathematics of Computing
1.
2.
3.
4.

Numerical Analysis
Discrete Mathematics
Probability and Statistics
Mathematical Software

ACM Computing Classification System
G. Mathematics of Computing
2. Discrete Mathematics
2.1 Combinatorics

2.1.1 Combinatorial Algorithms
2.1.2 Counting Problems
2.1.3 Generating Functions
2.1.4 Permutations and Combinations
2.1.5 Recurrences and Difference Equations

2.2 Graph Theory
2.2.1 Graph Algorithms
2.2.2 Graph Labeling

2.2.5 Path and Circuit Problems
2.2.6 Trees

2.3 Applications

a world FULL of NP-hard problems
Problem: I want to travel among a set of
cities driving the fewest possible number
of KMs. IT’S DIFFICULT!!

Problem: I want to put a set of objects
into some bags, knowing that each bag
can not afford more than 10 KGs and
trying to use as few bags as possible.
IT’S DIFFICULT!!

How to Deal with NP-hard problems?
• Exact Algorithms
• Randomized Algorithms
• Approximation Algorithms
• Fixed-Parameter Tractable Algorithms
• …

Approximation Algorithms

Approximation Algorithms
• We want a solution “close” to the
optimal one.
• Given a minimization problem Π, an
algorithm is an α-approximation for Π if,
for every instance I of Π, it outputs a
solution SOL(I) such that
SOL(I)/OPT(I) ≤ α

Vertex Cover
• Problem: Given a graph G(V,E), find a
minimum vertex cover, that is, a set V’  V
such that every edge e  E has an
endvertex in V’.

NP-hard 
[Karp]

How to Guarantee an Approximation?
• We want an approximation algorithm
for Vertex Cover.
• The cost of the solution produced by the
algorithm should be compared with the
cost of an optimal solution.

• But computing the cost of an optimal
solution is NP-HARD!!
LOWER BOUNDS!

Lower Bound for Vertex Cover
• Given a graph G(V,E), a matching M is
a set of edges M  E such that no two
edges share an endvertex.
• A matching is maximal if no matching M’
exists such that M  M’.

• The size of a matching
is a lower bound on the
size of an optimal
solution to Vertex
Cover!

An Approximation Algorithm
for Vertex Cover

• Algorithm: Find a maximal matching M
and output the set S of matched vertices

An Approximation Algorithm
for Vertex Cover
• Theorem: The previous algorithm is a
2-approximation algorithm for Vertex Cover
• Proof:
• S is a vertex cover, otherwhise the
matching would not be maximal.
• OPT≥M, where M is the size of the output
maximal matching.
• SOL=2M, as the number of matched
vertices is twice the size of the matching.

Approximation Algorithms:much more…
• Approximation schemes: (1+ε)-approx.
• Inapproximability results.
• Complexity classes, e.g., APX.

Fixed-Parameter Tractable Algorithms

Easy or Hard?
Problem (optimization): Let G be a graph.
Which is the minimum number of vertices
whose deletion makes G planar?

NP-hard 
[Lewis-Yannakakis ]

Easy or Hard?
Problem (decision): Let G be a graph and k
be an integer. Is there a set of k vertices
whose deletion makes G planar?
Polynomial 
• Easy O(nk+1) time algorithm for solving the problem:
• Consider every set of k vertices. Remove such
vertices. Test the planarity of the resulting graph.

• There are O(nk) such sets. Testing the planarity of
an n-vertex graph takes O(n) time. Then,
T(n,k)= O(nk) O(n) = O(nk+1)

Easy or Hard?
Where is the trick?
In the decision version, k is a constant
parameter part of the input
An O(nk+1)-time algorithm, with k constant, is a
polynomial-time algorithm.

But it is very slow 

Fixed-Parameter Tractability
A problem is fixed-parameter tractable
if it can be solved in f(k) nO(1) time,
where k is a parameter of the problem,
f is an arbitrary function, and nO(1) is a
polynomial (not depending on k).

FPT algorithm for Vertex Cover
Theorem [Melhorn]: There is an O(2k n)time algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• There is a vertex cover with k=0 if and only if G
has no edge.
• Consider any edge e=(u,v). Either u or v belongs
to any vertex cover S.
• Consider both the case in which u S and the
case in which v S.

FPT algorithm for Vertex Cover
u

u

v

v

• u  S -> S is a vertex cover of G if and only if
S-{u} is a vertex cover of G-{u} -> solve the
instance (G-{u}, k-1)
• v  S -> S is a vertex cover of G if and only if
S-{v} is a vertex cover of G-{v} -> solve the
instance (G-{v}, k-1)

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• T(n,0) = O(n)
• T(n,k) = 2 T(n-1, k-1) +O(n) ≤ 2 T(n, k-1) +O(n) ≤
2 (2 T(n, k-2) +O(n)) +O(n) ≤
2 (2 (2 T(n, k-3) +O(n)) +O(n)) +O(n) ≤
2 (2 (2 (…(2 T(n, 0)+O(n)) + … +O(n))
+O(n)) +O(n) ≤
2k O(n) + (2k-1 + 2k-2 + 2k-3 + ... + 1) O(n) =
2k O(n) + (2k - 1) O(n) = O(2k n)

Reduction Rules
Reduction rule : a rule (that is, a polynomial time
algorithm) that transforms an instance (I,k) to
an "equivalent and simpler” instance (I', k’).

Equivalent: (I,k) is a YES instance if and only if
(I', k') is a YES instance.
Simpler: |I'|<|I| or k'occurrences of a particular substructure.

Another FPT algorithm for Vertex Cover
Theorem: There is an O(1.6181k n2)-time
algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• We apply the following two reduction rules:
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k).
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u,N(u)},k-1).

Another FPT algorithm for Vertex Cover
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k). Correctness: if S is a vertex
cover of G and u is in S, then S-{u} is also a
vertex cover of G, as u has no incident edge.
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u, N(u)},k-1). Correctness: if S is a
vertex cover of G and u is in S, then
S-{u}  N(u) is also a vertex cover of G, as u
has no other incident edge.

Another FPT algorithm for Vertex Cover
• If neither of the two rules can be applied,
then every vertex has degree at least 2.
• Pick a vertex u. Any vertex cover of G
contains either u or N(u). Thus, (G,k) is a YES
instance if and only if (G-{u},k-1) or
(G-N(u),k-|N(u)|) is.

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• Since |N(u)|\geq 2,
• T(n,k) ≤ T(n,k-1)+ T(n,k-2)+O(n^2).
• Fibonacci series: every number is the sum of
the previous two xk =xk-1 +xk-2 +c.

• The k-th number of the Fibonacci series
tends to the golden ratio to the power of k.
• T(n,k)=Φk O(n2)=((1+√5)/2)k O(n2) =
O(1.6181k n2).

Kernelization
• Sometimes the reduction rules work till the size
of the problem is reduced really a lot. That is,
after the reduction rules have been applied,
the problem has size g(k), for some function k.
In this case the problem has a g(k)-kernel.

• Kernel: given a problem and an instance (I,k), a
kernel is an algorithm that outputs in polynomial
time an instance (I',k') such that (a) (I',k') is a
YES instance if and only if (I,k) is; (b) |I'|and k'
Kernelization
• Theorem [Niedermaier]: Every fixed-parameter
tractable problem has a g(k)-kernel.
• Proof: Suppose that there exists a FPT
algorithm with running time f(k) nc, for some
function f and some constant c. Consider an
instance (I,k) with |I|=n.
• If n>f(k), we run the decision algorithm in time
f(k) nc < nc+1. If it returns YES (NO), the
kernelization algorithm outputs a constant size
YES (resp. NO) instance.
• If n≤f(k), the the kernelization algorithm
returns (I,k).

Kernelization
• The last theorem implies that every problem
that is FPT has a kernel.
• However, the goal is to obtain kernels that are
"small", that is, polynomial in k, or even constant.

FPT: much more…
• Some problems are not FPT (e.g., graph coloring).
• Complexity classes: W[1] -> Can a nondeterministic Turing machine accept an unary
string s in at most k steps?
• Independent Set is W[1]-hard.
• Reductions to W[1]-hard problems give new
W[1]-hard problems.
• Lower bounds for FPT tractability
• Upper and lower bounds for the size of the
kernels

FPT: much more…
• Theorem [Robertson and Seymour]: Every graph
problem with parameter k whose YES istances
are closed under taking minors can be solved in
O(f(k) n3)


Slide 29

Tecniche Algoritmiche per Grafi e Reti
Fabrizio Frati

Dipartimento di Informatica e Automazione
Università degli Studi Roma Tre

• 3 CREDITI
• I° periodo:
• Lunedì 9:45-11:15 aula N13

• II° periodo:
• Venerdì 8:00-9:45 aula N7

• Contatti:
• {angelini,gdb,frati,ratm} @dia.uniroma3.it
• Ricevimento: mercoledì dalle 17 alle 19

• Struttura del Corso
• ~ 8 seminari
• algoritmi, strutture dati, combinatorica,
graph drawing…

• progetti a gruppi di 2 - 4 persone
• problema di ricerca

• Materiale Didattico
• slides
• G. Di Battista, P. Eades, R. Tamassia, I. G.
Tollis, Graph Drawing: Algorithms for the
Visualization of Graphs, 1999. Prentice Hall.

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
C. Computer System Organization
1.
2.
3.
4.
5.

Processor Architectures
Computer-Communication Networks
Application-Based Systems
Performance of Systems
Computer System Implementations

ACM Computing Classification System
C. Computer System Organization
2. Computer-Communication Networks
2.1 Network Architectures
2.2 Network Protocols
2.3 Network Operations
2.4 Distributed Systems
2.5 LAN & WAN
2.6 Internetworking

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
E. Data
1.
2.
3.
4.
5.

Data Structures
Data Storage Representations
Data Encryption
Coding and Information Theory
Files

ACM Computing Classification System
E. Data
1. Data Structures
1.1 Arrays
1.2 Distributed Data Structures
1.3 Graphs and Networks
1.4 Lists, Stacks, and Queues
1.5 Records
1.6 Tables
1.7 Trees

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
F. Theory of Computation
1.
2.
3.
4.

Computation by Abstract Devices
Analysis of Algorithms and Problem Complexity
Logics and Meanings of Programs
Mathematical Logic and Formal Languages

ACM Computing Classification System
F. Theory of Computation
1. Computation by Abstract Devices
1.1 Models of Computation
1.2 Complexity Measures and Completeness
1.2.1 Complexity Hierarchies
1.2.2 Machine-Independent Complexity
1.2.3 Reducibility and Completeness
1.2.4 Relations among Complexity Classes

ACM Computing Classification System
F. Theory of Computation
2. Analysis of Algorithms and Problem Complexity
2.1 Numerical Algorithms
2.2 Non-numerical Algorithms and Problems
2.2.1 Complexity of Proof Procedures
2.2.2 Computations on Discrete Structures
2.2.3 Geometrical Problems
2.2.4 Pattern Matching
2.2.5 Routing and Layout
2.2.6 Sequencing and Scheduling
2.2.7 Sorting and Searching

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
G. Mathematics of Computing
1.
2.
3.
4.

Numerical Analysis
Discrete Mathematics
Probability and Statistics
Mathematical Software

ACM Computing Classification System
G. Mathematics of Computing
2. Discrete Mathematics
2.1 Combinatorics

2.1.1 Combinatorial Algorithms
2.1.2 Counting Problems
2.1.3 Generating Functions
2.1.4 Permutations and Combinations
2.1.5 Recurrences and Difference Equations

2.2 Graph Theory
2.2.1 Graph Algorithms
2.2.2 Graph Labeling

2.2.5 Path and Circuit Problems
2.2.6 Trees

2.3 Applications

a world FULL of NP-hard problems
Problem: I want to travel among a set of
cities driving the fewest possible number
of KMs. IT’S DIFFICULT!!

Problem: I want to put a set of objects
into some bags, knowing that each bag
can not afford more than 10 KGs and
trying to use as few bags as possible.
IT’S DIFFICULT!!

How to Deal with NP-hard problems?
• Exact Algorithms
• Randomized Algorithms
• Approximation Algorithms
• Fixed-Parameter Tractable Algorithms
• …

Approximation Algorithms

Approximation Algorithms
• We want a solution “close” to the
optimal one.
• Given a minimization problem Π, an
algorithm is an α-approximation for Π if,
for every instance I of Π, it outputs a
solution SOL(I) such that
SOL(I)/OPT(I) ≤ α

Vertex Cover
• Problem: Given a graph G(V,E), find a
minimum vertex cover, that is, a set V’  V
such that every edge e  E has an
endvertex in V’.

NP-hard 
[Karp]

How to Guarantee an Approximation?
• We want an approximation algorithm
for Vertex Cover.
• The cost of the solution produced by the
algorithm should be compared with the
cost of an optimal solution.

• But computing the cost of an optimal
solution is NP-HARD!!
LOWER BOUNDS!

Lower Bound for Vertex Cover
• Given a graph G(V,E), a matching M is
a set of edges M  E such that no two
edges share an endvertex.
• A matching is maximal if no matching M’
exists such that M  M’.

• The size of a matching
is a lower bound on the
size of an optimal
solution to Vertex
Cover!

An Approximation Algorithm
for Vertex Cover

• Algorithm: Find a maximal matching M
and output the set S of matched vertices

An Approximation Algorithm
for Vertex Cover
• Theorem: The previous algorithm is a
2-approximation algorithm for Vertex Cover
• Proof:
• S is a vertex cover, otherwhise the
matching would not be maximal.
• OPT≥M, where M is the size of the output
maximal matching.
• SOL=2M, as the number of matched
vertices is twice the size of the matching.

Approximation Algorithms:much more…
• Approximation schemes: (1+ε)-approx.
• Inapproximability results.
• Complexity classes, e.g., APX.

Fixed-Parameter Tractable Algorithms

Easy or Hard?
Problem (optimization): Let G be a graph.
Which is the minimum number of vertices
whose deletion makes G planar?

NP-hard 
[Lewis-Yannakakis ]

Easy or Hard?
Problem (decision): Let G be a graph and k
be an integer. Is there a set of k vertices
whose deletion makes G planar?
Polynomial 
• Easy O(nk+1) time algorithm for solving the problem:
• Consider every set of k vertices. Remove such
vertices. Test the planarity of the resulting graph.

• There are O(nk) such sets. Testing the planarity of
an n-vertex graph takes O(n) time. Then,
T(n,k)= O(nk) O(n) = O(nk+1)

Easy or Hard?
Where is the trick?
In the decision version, k is a constant
parameter part of the input
An O(nk+1)-time algorithm, with k constant, is a
polynomial-time algorithm.

But it is very slow 

Fixed-Parameter Tractability
A problem is fixed-parameter tractable
if it can be solved in f(k) nO(1) time,
where k is a parameter of the problem,
f is an arbitrary function, and nO(1) is a
polynomial (not depending on k).

FPT algorithm for Vertex Cover
Theorem [Melhorn]: There is an O(2k n)time algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• There is a vertex cover with k=0 if and only if G
has no edge.
• Consider any edge e=(u,v). Either u or v belongs
to any vertex cover S.
• Consider both the case in which u S and the
case in which v S.

FPT algorithm for Vertex Cover
u

u

v

v

• u  S -> S is a vertex cover of G if and only if
S-{u} is a vertex cover of G-{u} -> solve the
instance (G-{u}, k-1)
• v  S -> S is a vertex cover of G if and only if
S-{v} is a vertex cover of G-{v} -> solve the
instance (G-{v}, k-1)

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• T(n,0) = O(n)
• T(n,k) = 2 T(n-1, k-1) +O(n) ≤ 2 T(n, k-1) +O(n) ≤
2 (2 T(n, k-2) +O(n)) +O(n) ≤
2 (2 (2 T(n, k-3) +O(n)) +O(n)) +O(n) ≤
2 (2 (2 (…(2 T(n, 0)+O(n)) + … +O(n))
+O(n)) +O(n) ≤
2k O(n) + (2k-1 + 2k-2 + 2k-3 + ... + 1) O(n) =
2k O(n) + (2k - 1) O(n) = O(2k n)

Reduction Rules
Reduction rule : a rule (that is, a polynomial time
algorithm) that transforms an instance (I,k) to
an "equivalent and simpler” instance (I', k’).

Equivalent: (I,k) is a YES instance if and only if
(I', k') is a YES instance.
Simpler: |I'|<|I| or k'occurrences of a particular substructure.

Another FPT algorithm for Vertex Cover
Theorem: There is an O(1.6181k n2)-time
algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• We apply the following two reduction rules:
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k).
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u,N(u)},k-1).

Another FPT algorithm for Vertex Cover
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k). Correctness: if S is a vertex
cover of G and u is in S, then S-{u} is also a
vertex cover of G, as u has no incident edge.
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u, N(u)},k-1). Correctness: if S is a
vertex cover of G and u is in S, then
S-{u}  N(u) is also a vertex cover of G, as u
has no other incident edge.

Another FPT algorithm for Vertex Cover
• If neither of the two rules can be applied,
then every vertex has degree at least 2.
• Pick a vertex u. Any vertex cover of G
contains either u or N(u). Thus, (G,k) is a YES
instance if and only if (G-{u},k-1) or
(G-N(u),k-|N(u)|) is.

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• Since |N(u)|\geq 2,
• T(n,k) ≤ T(n,k-1)+ T(n,k-2)+O(n^2).
• Fibonacci series: every number is the sum of
the previous two xk =xk-1 +xk-2 +c.

• The k-th number of the Fibonacci series
tends to the golden ratio to the power of k.
• T(n,k)=Φk O(n2)=((1+√5)/2)k O(n2) =
O(1.6181k n2).

Kernelization
• Sometimes the reduction rules work till the size
of the problem is reduced really a lot. That is,
after the reduction rules have been applied,
the problem has size g(k), for some function k.
In this case the problem has a g(k)-kernel.

• Kernel: given a problem and an instance (I,k), a
kernel is an algorithm that outputs in polynomial
time an instance (I',k') such that (a) (I',k') is a
YES instance if and only if (I,k) is; (b) |I'|and k'
Kernelization
• Theorem [Niedermaier]: Every fixed-parameter
tractable problem has a g(k)-kernel.
• Proof: Suppose that there exists a FPT
algorithm with running time f(k) nc, for some
function f and some constant c. Consider an
instance (I,k) with |I|=n.
• If n>f(k), we run the decision algorithm in time
f(k) nc < nc+1. If it returns YES (NO), the
kernelization algorithm outputs a constant size
YES (resp. NO) instance.
• If n≤f(k), the the kernelization algorithm
returns (I,k).

Kernelization
• The last theorem implies that every problem
that is FPT has a kernel.
• However, the goal is to obtain kernels that are
"small", that is, polynomial in k, or even constant.

FPT: much more…
• Some problems are not FPT (e.g., graph coloring).
• Complexity classes: W[1] -> Can a nondeterministic Turing machine accept an unary
string s in at most k steps?
• Independent Set is W[1]-hard.
• Reductions to W[1]-hard problems give new
W[1]-hard problems.
• Lower bounds for FPT tractability
• Upper and lower bounds for the size of the
kernels

FPT: much more…
• Theorem [Robertson and Seymour]: Every graph
problem with parameter k whose YES istances
are closed under taking minors can be solved in
O(f(k) n3)


Slide 30

Tecniche Algoritmiche per Grafi e Reti
Fabrizio Frati

Dipartimento di Informatica e Automazione
Università degli Studi Roma Tre

• 3 CREDITI
• I° periodo:
• Lunedì 9:45-11:15 aula N13

• II° periodo:
• Venerdì 8:00-9:45 aula N7

• Contatti:
• {angelini,gdb,frati,ratm} @dia.uniroma3.it
• Ricevimento: mercoledì dalle 17 alle 19

• Struttura del Corso
• ~ 8 seminari
• algoritmi, strutture dati, combinatorica,
graph drawing…

• progetti a gruppi di 2 - 4 persone
• problema di ricerca

• Materiale Didattico
• slides
• G. Di Battista, P. Eades, R. Tamassia, I. G.
Tollis, Graph Drawing: Algorithms for the
Visualization of Graphs, 1999. Prentice Hall.

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
C. Computer System Organization
1.
2.
3.
4.
5.

Processor Architectures
Computer-Communication Networks
Application-Based Systems
Performance of Systems
Computer System Implementations

ACM Computing Classification System
C. Computer System Organization
2. Computer-Communication Networks
2.1 Network Architectures
2.2 Network Protocols
2.3 Network Operations
2.4 Distributed Systems
2.5 LAN & WAN
2.6 Internetworking

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
E. Data
1.
2.
3.
4.
5.

Data Structures
Data Storage Representations
Data Encryption
Coding and Information Theory
Files

ACM Computing Classification System
E. Data
1. Data Structures
1.1 Arrays
1.2 Distributed Data Structures
1.3 Graphs and Networks
1.4 Lists, Stacks, and Queues
1.5 Records
1.6 Tables
1.7 Trees

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
F. Theory of Computation
1.
2.
3.
4.

Computation by Abstract Devices
Analysis of Algorithms and Problem Complexity
Logics and Meanings of Programs
Mathematical Logic and Formal Languages

ACM Computing Classification System
F. Theory of Computation
1. Computation by Abstract Devices
1.1 Models of Computation
1.2 Complexity Measures and Completeness
1.2.1 Complexity Hierarchies
1.2.2 Machine-Independent Complexity
1.2.3 Reducibility and Completeness
1.2.4 Relations among Complexity Classes

ACM Computing Classification System
F. Theory of Computation
2. Analysis of Algorithms and Problem Complexity
2.1 Numerical Algorithms
2.2 Non-numerical Algorithms and Problems
2.2.1 Complexity of Proof Procedures
2.2.2 Computations on Discrete Structures
2.2.3 Geometrical Problems
2.2.4 Pattern Matching
2.2.5 Routing and Layout
2.2.6 Sequencing and Scheduling
2.2.7 Sorting and Searching

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
G. Mathematics of Computing
1.
2.
3.
4.

Numerical Analysis
Discrete Mathematics
Probability and Statistics
Mathematical Software

ACM Computing Classification System
G. Mathematics of Computing
2. Discrete Mathematics
2.1 Combinatorics

2.1.1 Combinatorial Algorithms
2.1.2 Counting Problems
2.1.3 Generating Functions
2.1.4 Permutations and Combinations
2.1.5 Recurrences and Difference Equations

2.2 Graph Theory
2.2.1 Graph Algorithms
2.2.2 Graph Labeling

2.2.5 Path and Circuit Problems
2.2.6 Trees

2.3 Applications

a world FULL of NP-hard problems
Problem: I want to travel among a set of
cities driving the fewest possible number
of KMs. IT’S DIFFICULT!!

Problem: I want to put a set of objects
into some bags, knowing that each bag
can not afford more than 10 KGs and
trying to use as few bags as possible.
IT’S DIFFICULT!!

How to Deal with NP-hard problems?
• Exact Algorithms
• Randomized Algorithms
• Approximation Algorithms
• Fixed-Parameter Tractable Algorithms
• …

Approximation Algorithms

Approximation Algorithms
• We want a solution “close” to the
optimal one.
• Given a minimization problem Π, an
algorithm is an α-approximation for Π if,
for every instance I of Π, it outputs a
solution SOL(I) such that
SOL(I)/OPT(I) ≤ α

Vertex Cover
• Problem: Given a graph G(V,E), find a
minimum vertex cover, that is, a set V’  V
such that every edge e  E has an
endvertex in V’.

NP-hard 
[Karp]

How to Guarantee an Approximation?
• We want an approximation algorithm
for Vertex Cover.
• The cost of the solution produced by the
algorithm should be compared with the
cost of an optimal solution.

• But computing the cost of an optimal
solution is NP-HARD!!
LOWER BOUNDS!

Lower Bound for Vertex Cover
• Given a graph G(V,E), a matching M is
a set of edges M  E such that no two
edges share an endvertex.
• A matching is maximal if no matching M’
exists such that M  M’.

• The size of a matching
is a lower bound on the
size of an optimal
solution to Vertex
Cover!

An Approximation Algorithm
for Vertex Cover

• Algorithm: Find a maximal matching M
and output the set S of matched vertices

An Approximation Algorithm
for Vertex Cover
• Theorem: The previous algorithm is a
2-approximation algorithm for Vertex Cover
• Proof:
• S is a vertex cover, otherwhise the
matching would not be maximal.
• OPT≥M, where M is the size of the output
maximal matching.
• SOL=2M, as the number of matched
vertices is twice the size of the matching.

Approximation Algorithms:much more…
• Approximation schemes: (1+ε)-approx.
• Inapproximability results.
• Complexity classes, e.g., APX.

Fixed-Parameter Tractable Algorithms

Easy or Hard?
Problem (optimization): Let G be a graph.
Which is the minimum number of vertices
whose deletion makes G planar?

NP-hard 
[Lewis-Yannakakis ]

Easy or Hard?
Problem (decision): Let G be a graph and k
be an integer. Is there a set of k vertices
whose deletion makes G planar?
Polynomial 
• Easy O(nk+1) time algorithm for solving the problem:
• Consider every set of k vertices. Remove such
vertices. Test the planarity of the resulting graph.

• There are O(nk) such sets. Testing the planarity of
an n-vertex graph takes O(n) time. Then,
T(n,k)= O(nk) O(n) = O(nk+1)

Easy or Hard?
Where is the trick?
In the decision version, k is a constant
parameter part of the input
An O(nk+1)-time algorithm, with k constant, is a
polynomial-time algorithm.

But it is very slow 

Fixed-Parameter Tractability
A problem is fixed-parameter tractable
if it can be solved in f(k) nO(1) time,
where k is a parameter of the problem,
f is an arbitrary function, and nO(1) is a
polynomial (not depending on k).

FPT algorithm for Vertex Cover
Theorem [Melhorn]: There is an O(2k n)time algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• There is a vertex cover with k=0 if and only if G
has no edge.
• Consider any edge e=(u,v). Either u or v belongs
to any vertex cover S.
• Consider both the case in which u S and the
case in which v S.

FPT algorithm for Vertex Cover
u

u

v

v

• u  S -> S is a vertex cover of G if and only if
S-{u} is a vertex cover of G-{u} -> solve the
instance (G-{u}, k-1)
• v  S -> S is a vertex cover of G if and only if
S-{v} is a vertex cover of G-{v} -> solve the
instance (G-{v}, k-1)

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• T(n,0) = O(n)
• T(n,k) = 2 T(n-1, k-1) +O(n) ≤ 2 T(n, k-1) +O(n) ≤
2 (2 T(n, k-2) +O(n)) +O(n) ≤
2 (2 (2 T(n, k-3) +O(n)) +O(n)) +O(n) ≤
2 (2 (2 (…(2 T(n, 0)+O(n)) + … +O(n))
+O(n)) +O(n) ≤
2k O(n) + (2k-1 + 2k-2 + 2k-3 + ... + 1) O(n) =
2k O(n) + (2k - 1) O(n) = O(2k n)

Reduction Rules
Reduction rule : a rule (that is, a polynomial time
algorithm) that transforms an instance (I,k) to
an "equivalent and simpler” instance (I', k’).

Equivalent: (I,k) is a YES instance if and only if
(I', k') is a YES instance.
Simpler: |I'|<|I| or k'occurrences of a particular substructure.

Another FPT algorithm for Vertex Cover
Theorem: There is an O(1.6181k n2)-time
algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• We apply the following two reduction rules:
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k).
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u,N(u)},k-1).

Another FPT algorithm for Vertex Cover
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k). Correctness: if S is a vertex
cover of G and u is in S, then S-{u} is also a
vertex cover of G, as u has no incident edge.
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u, N(u)},k-1). Correctness: if S is a
vertex cover of G and u is in S, then
S-{u}  N(u) is also a vertex cover of G, as u
has no other incident edge.

Another FPT algorithm for Vertex Cover
• If neither of the two rules can be applied,
then every vertex has degree at least 2.
• Pick a vertex u. Any vertex cover of G
contains either u or N(u). Thus, (G,k) is a YES
instance if and only if (G-{u},k-1) or
(G-N(u),k-|N(u)|) is.

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• Since |N(u)|\geq 2,
• T(n,k) ≤ T(n,k-1)+ T(n,k-2)+O(n^2).
• Fibonacci series: every number is the sum of
the previous two xk =xk-1 +xk-2 +c.

• The k-th number of the Fibonacci series
tends to the golden ratio to the power of k.
• T(n,k)=Φk O(n2)=((1+√5)/2)k O(n2) =
O(1.6181k n2).

Kernelization
• Sometimes the reduction rules work till the size
of the problem is reduced really a lot. That is,
after the reduction rules have been applied,
the problem has size g(k), for some function k.
In this case the problem has a g(k)-kernel.

• Kernel: given a problem and an instance (I,k), a
kernel is an algorithm that outputs in polynomial
time an instance (I',k') such that (a) (I',k') is a
YES instance if and only if (I,k) is; (b) |I'|and k'
Kernelization
• Theorem [Niedermaier]: Every fixed-parameter
tractable problem has a g(k)-kernel.
• Proof: Suppose that there exists a FPT
algorithm with running time f(k) nc, for some
function f and some constant c. Consider an
instance (I,k) with |I|=n.
• If n>f(k), we run the decision algorithm in time
f(k) nc < nc+1. If it returns YES (NO), the
kernelization algorithm outputs a constant size
YES (resp. NO) instance.
• If n≤f(k), the the kernelization algorithm
returns (I,k).

Kernelization
• The last theorem implies that every problem
that is FPT has a kernel.
• However, the goal is to obtain kernels that are
"small", that is, polynomial in k, or even constant.

FPT: much more…
• Some problems are not FPT (e.g., graph coloring).
• Complexity classes: W[1] -> Can a nondeterministic Turing machine accept an unary
string s in at most k steps?
• Independent Set is W[1]-hard.
• Reductions to W[1]-hard problems give new
W[1]-hard problems.
• Lower bounds for FPT tractability
• Upper and lower bounds for the size of the
kernels

FPT: much more…
• Theorem [Robertson and Seymour]: Every graph
problem with parameter k whose YES istances
are closed under taking minors can be solved in
O(f(k) n3)


Slide 31

Tecniche Algoritmiche per Grafi e Reti
Fabrizio Frati

Dipartimento di Informatica e Automazione
Università degli Studi Roma Tre

• 3 CREDITI
• I° periodo:
• Lunedì 9:45-11:15 aula N13

• II° periodo:
• Venerdì 8:00-9:45 aula N7

• Contatti:
• {angelini,gdb,frati,ratm} @dia.uniroma3.it
• Ricevimento: mercoledì dalle 17 alle 19

• Struttura del Corso
• ~ 8 seminari
• algoritmi, strutture dati, combinatorica,
graph drawing…

• progetti a gruppi di 2 - 4 persone
• problema di ricerca

• Materiale Didattico
• slides
• G. Di Battista, P. Eades, R. Tamassia, I. G.
Tollis, Graph Drawing: Algorithms for the
Visualization of Graphs, 1999. Prentice Hall.

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
C. Computer System Organization
1.
2.
3.
4.
5.

Processor Architectures
Computer-Communication Networks
Application-Based Systems
Performance of Systems
Computer System Implementations

ACM Computing Classification System
C. Computer System Organization
2. Computer-Communication Networks
2.1 Network Architectures
2.2 Network Protocols
2.3 Network Operations
2.4 Distributed Systems
2.5 LAN & WAN
2.6 Internetworking

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
E. Data
1.
2.
3.
4.
5.

Data Structures
Data Storage Representations
Data Encryption
Coding and Information Theory
Files

ACM Computing Classification System
E. Data
1. Data Structures
1.1 Arrays
1.2 Distributed Data Structures
1.3 Graphs and Networks
1.4 Lists, Stacks, and Queues
1.5 Records
1.6 Tables
1.7 Trees

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
F. Theory of Computation
1.
2.
3.
4.

Computation by Abstract Devices
Analysis of Algorithms and Problem Complexity
Logics and Meanings of Programs
Mathematical Logic and Formal Languages

ACM Computing Classification System
F. Theory of Computation
1. Computation by Abstract Devices
1.1 Models of Computation
1.2 Complexity Measures and Completeness
1.2.1 Complexity Hierarchies
1.2.2 Machine-Independent Complexity
1.2.3 Reducibility and Completeness
1.2.4 Relations among Complexity Classes

ACM Computing Classification System
F. Theory of Computation
2. Analysis of Algorithms and Problem Complexity
2.1 Numerical Algorithms
2.2 Non-numerical Algorithms and Problems
2.2.1 Complexity of Proof Procedures
2.2.2 Computations on Discrete Structures
2.2.3 Geometrical Problems
2.2.4 Pattern Matching
2.2.5 Routing and Layout
2.2.6 Sequencing and Scheduling
2.2.7 Sorting and Searching

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
G. Mathematics of Computing
1.
2.
3.
4.

Numerical Analysis
Discrete Mathematics
Probability and Statistics
Mathematical Software

ACM Computing Classification System
G. Mathematics of Computing
2. Discrete Mathematics
2.1 Combinatorics

2.1.1 Combinatorial Algorithms
2.1.2 Counting Problems
2.1.3 Generating Functions
2.1.4 Permutations and Combinations
2.1.5 Recurrences and Difference Equations

2.2 Graph Theory
2.2.1 Graph Algorithms
2.2.2 Graph Labeling

2.2.5 Path and Circuit Problems
2.2.6 Trees

2.3 Applications

a world FULL of NP-hard problems
Problem: I want to travel among a set of
cities driving the fewest possible number
of KMs. IT’S DIFFICULT!!

Problem: I want to put a set of objects
into some bags, knowing that each bag
can not afford more than 10 KGs and
trying to use as few bags as possible.
IT’S DIFFICULT!!

How to Deal with NP-hard problems?
• Exact Algorithms
• Randomized Algorithms
• Approximation Algorithms
• Fixed-Parameter Tractable Algorithms
• …

Approximation Algorithms

Approximation Algorithms
• We want a solution “close” to the
optimal one.
• Given a minimization problem Π, an
algorithm is an α-approximation for Π if,
for every instance I of Π, it outputs a
solution SOL(I) such that
SOL(I)/OPT(I) ≤ α

Vertex Cover
• Problem: Given a graph G(V,E), find a
minimum vertex cover, that is, a set V’  V
such that every edge e  E has an
endvertex in V’.

NP-hard 
[Karp]

How to Guarantee an Approximation?
• We want an approximation algorithm
for Vertex Cover.
• The cost of the solution produced by the
algorithm should be compared with the
cost of an optimal solution.

• But computing the cost of an optimal
solution is NP-HARD!!
LOWER BOUNDS!

Lower Bound for Vertex Cover
• Given a graph G(V,E), a matching M is
a set of edges M  E such that no two
edges share an endvertex.
• A matching is maximal if no matching M’
exists such that M  M’.

• The size of a matching
is a lower bound on the
size of an optimal
solution to Vertex
Cover!

An Approximation Algorithm
for Vertex Cover

• Algorithm: Find a maximal matching M
and output the set S of matched vertices

An Approximation Algorithm
for Vertex Cover
• Theorem: The previous algorithm is a
2-approximation algorithm for Vertex Cover
• Proof:
• S is a vertex cover, otherwhise the
matching would not be maximal.
• OPT≥M, where M is the size of the output
maximal matching.
• SOL=2M, as the number of matched
vertices is twice the size of the matching.

Approximation Algorithms:much more…
• Approximation schemes: (1+ε)-approx.
• Inapproximability results.
• Complexity classes, e.g., APX.

Fixed-Parameter Tractable Algorithms

Easy or Hard?
Problem (optimization): Let G be a graph.
Which is the minimum number of vertices
whose deletion makes G planar?

NP-hard 
[Lewis-Yannakakis ]

Easy or Hard?
Problem (decision): Let G be a graph and k
be an integer. Is there a set of k vertices
whose deletion makes G planar?
Polynomial 
• Easy O(nk+1) time algorithm for solving the problem:
• Consider every set of k vertices. Remove such
vertices. Test the planarity of the resulting graph.

• There are O(nk) such sets. Testing the planarity of
an n-vertex graph takes O(n) time. Then,
T(n,k)= O(nk) O(n) = O(nk+1)

Easy or Hard?
Where is the trick?
In the decision version, k is a constant
parameter part of the input
An O(nk+1)-time algorithm, with k constant, is a
polynomial-time algorithm.

But it is very slow 

Fixed-Parameter Tractability
A problem is fixed-parameter tractable
if it can be solved in f(k) nO(1) time,
where k is a parameter of the problem,
f is an arbitrary function, and nO(1) is a
polynomial (not depending on k).

FPT algorithm for Vertex Cover
Theorem [Melhorn]: There is an O(2k n)time algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• There is a vertex cover with k=0 if and only if G
has no edge.
• Consider any edge e=(u,v). Either u or v belongs
to any vertex cover S.
• Consider both the case in which u S and the
case in which v S.

FPT algorithm for Vertex Cover
u

u

v

v

• u  S -> S is a vertex cover of G if and only if
S-{u} is a vertex cover of G-{u} -> solve the
instance (G-{u}, k-1)
• v  S -> S is a vertex cover of G if and only if
S-{v} is a vertex cover of G-{v} -> solve the
instance (G-{v}, k-1)

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• T(n,0) = O(n)
• T(n,k) = 2 T(n-1, k-1) +O(n) ≤ 2 T(n, k-1) +O(n) ≤
2 (2 T(n, k-2) +O(n)) +O(n) ≤
2 (2 (2 T(n, k-3) +O(n)) +O(n)) +O(n) ≤
2 (2 (2 (…(2 T(n, 0)+O(n)) + … +O(n))
+O(n)) +O(n) ≤
2k O(n) + (2k-1 + 2k-2 + 2k-3 + ... + 1) O(n) =
2k O(n) + (2k - 1) O(n) = O(2k n)

Reduction Rules
Reduction rule : a rule (that is, a polynomial time
algorithm) that transforms an instance (I,k) to
an "equivalent and simpler” instance (I', k’).

Equivalent: (I,k) is a YES instance if and only if
(I', k') is a YES instance.
Simpler: |I'|<|I| or k'occurrences of a particular substructure.

Another FPT algorithm for Vertex Cover
Theorem: There is an O(1.6181k n2)-time
algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• We apply the following two reduction rules:
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k).
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u,N(u)},k-1).

Another FPT algorithm for Vertex Cover
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k). Correctness: if S is a vertex
cover of G and u is in S, then S-{u} is also a
vertex cover of G, as u has no incident edge.
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u, N(u)},k-1). Correctness: if S is a
vertex cover of G and u is in S, then
S-{u}  N(u) is also a vertex cover of G, as u
has no other incident edge.

Another FPT algorithm for Vertex Cover
• If neither of the two rules can be applied,
then every vertex has degree at least 2.
• Pick a vertex u. Any vertex cover of G
contains either u or N(u). Thus, (G,k) is a YES
instance if and only if (G-{u},k-1) or
(G-N(u),k-|N(u)|) is.

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• Since |N(u)|\geq 2,
• T(n,k) ≤ T(n,k-1)+ T(n,k-2)+O(n^2).
• Fibonacci series: every number is the sum of
the previous two xk =xk-1 +xk-2 +c.

• The k-th number of the Fibonacci series
tends to the golden ratio to the power of k.
• T(n,k)=Φk O(n2)=((1+√5)/2)k O(n2) =
O(1.6181k n2).

Kernelization
• Sometimes the reduction rules work till the size
of the problem is reduced really a lot. That is,
after the reduction rules have been applied,
the problem has size g(k), for some function k.
In this case the problem has a g(k)-kernel.

• Kernel: given a problem and an instance (I,k), a
kernel is an algorithm that outputs in polynomial
time an instance (I',k') such that (a) (I',k') is a
YES instance if and only if (I,k) is; (b) |I'|and k'
Kernelization
• Theorem [Niedermaier]: Every fixed-parameter
tractable problem has a g(k)-kernel.
• Proof: Suppose that there exists a FPT
algorithm with running time f(k) nc, for some
function f and some constant c. Consider an
instance (I,k) with |I|=n.
• If n>f(k), we run the decision algorithm in time
f(k) nc < nc+1. If it returns YES (NO), the
kernelization algorithm outputs a constant size
YES (resp. NO) instance.
• If n≤f(k), the the kernelization algorithm
returns (I,k).

Kernelization
• The last theorem implies that every problem
that is FPT has a kernel.
• However, the goal is to obtain kernels that are
"small", that is, polynomial in k, or even constant.

FPT: much more…
• Some problems are not FPT (e.g., graph coloring).
• Complexity classes: W[1] -> Can a nondeterministic Turing machine accept an unary
string s in at most k steps?
• Independent Set is W[1]-hard.
• Reductions to W[1]-hard problems give new
W[1]-hard problems.
• Lower bounds for FPT tractability
• Upper and lower bounds for the size of the
kernels

FPT: much more…
• Theorem [Robertson and Seymour]: Every graph
problem with parameter k whose YES istances
are closed under taking minors can be solved in
O(f(k) n3)


Slide 32

Tecniche Algoritmiche per Grafi e Reti
Fabrizio Frati

Dipartimento di Informatica e Automazione
Università degli Studi Roma Tre

• 3 CREDITI
• I° periodo:
• Lunedì 9:45-11:15 aula N13

• II° periodo:
• Venerdì 8:00-9:45 aula N7

• Contatti:
• {angelini,gdb,frati,ratm} @dia.uniroma3.it
• Ricevimento: mercoledì dalle 17 alle 19

• Struttura del Corso
• ~ 8 seminari
• algoritmi, strutture dati, combinatorica,
graph drawing…

• progetti a gruppi di 2 - 4 persone
• problema di ricerca

• Materiale Didattico
• slides
• G. Di Battista, P. Eades, R. Tamassia, I. G.
Tollis, Graph Drawing: Algorithms for the
Visualization of Graphs, 1999. Prentice Hall.

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
C. Computer System Organization
1.
2.
3.
4.
5.

Processor Architectures
Computer-Communication Networks
Application-Based Systems
Performance of Systems
Computer System Implementations

ACM Computing Classification System
C. Computer System Organization
2. Computer-Communication Networks
2.1 Network Architectures
2.2 Network Protocols
2.3 Network Operations
2.4 Distributed Systems
2.5 LAN & WAN
2.6 Internetworking

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
E. Data
1.
2.
3.
4.
5.

Data Structures
Data Storage Representations
Data Encryption
Coding and Information Theory
Files

ACM Computing Classification System
E. Data
1. Data Structures
1.1 Arrays
1.2 Distributed Data Structures
1.3 Graphs and Networks
1.4 Lists, Stacks, and Queues
1.5 Records
1.6 Tables
1.7 Trees

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
F. Theory of Computation
1.
2.
3.
4.

Computation by Abstract Devices
Analysis of Algorithms and Problem Complexity
Logics and Meanings of Programs
Mathematical Logic and Formal Languages

ACM Computing Classification System
F. Theory of Computation
1. Computation by Abstract Devices
1.1 Models of Computation
1.2 Complexity Measures and Completeness
1.2.1 Complexity Hierarchies
1.2.2 Machine-Independent Complexity
1.2.3 Reducibility and Completeness
1.2.4 Relations among Complexity Classes

ACM Computing Classification System
F. Theory of Computation
2. Analysis of Algorithms and Problem Complexity
2.1 Numerical Algorithms
2.2 Non-numerical Algorithms and Problems
2.2.1 Complexity of Proof Procedures
2.2.2 Computations on Discrete Structures
2.2.3 Geometrical Problems
2.2.4 Pattern Matching
2.2.5 Routing and Layout
2.2.6 Sequencing and Scheduling
2.2.7 Sorting and Searching

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
G. Mathematics of Computing
1.
2.
3.
4.

Numerical Analysis
Discrete Mathematics
Probability and Statistics
Mathematical Software

ACM Computing Classification System
G. Mathematics of Computing
2. Discrete Mathematics
2.1 Combinatorics

2.1.1 Combinatorial Algorithms
2.1.2 Counting Problems
2.1.3 Generating Functions
2.1.4 Permutations and Combinations
2.1.5 Recurrences and Difference Equations

2.2 Graph Theory
2.2.1 Graph Algorithms
2.2.2 Graph Labeling

2.2.5 Path and Circuit Problems
2.2.6 Trees

2.3 Applications

a world FULL of NP-hard problems
Problem: I want to travel among a set of
cities driving the fewest possible number
of KMs. IT’S DIFFICULT!!

Problem: I want to put a set of objects
into some bags, knowing that each bag
can not afford more than 10 KGs and
trying to use as few bags as possible.
IT’S DIFFICULT!!

How to Deal with NP-hard problems?
• Exact Algorithms
• Randomized Algorithms
• Approximation Algorithms
• Fixed-Parameter Tractable Algorithms
• …

Approximation Algorithms

Approximation Algorithms
• We want a solution “close” to the
optimal one.
• Given a minimization problem Π, an
algorithm is an α-approximation for Π if,
for every instance I of Π, it outputs a
solution SOL(I) such that
SOL(I)/OPT(I) ≤ α

Vertex Cover
• Problem: Given a graph G(V,E), find a
minimum vertex cover, that is, a set V’  V
such that every edge e  E has an
endvertex in V’.

NP-hard 
[Karp]

How to Guarantee an Approximation?
• We want an approximation algorithm
for Vertex Cover.
• The cost of the solution produced by the
algorithm should be compared with the
cost of an optimal solution.

• But computing the cost of an optimal
solution is NP-HARD!!
LOWER BOUNDS!

Lower Bound for Vertex Cover
• Given a graph G(V,E), a matching M is
a set of edges M  E such that no two
edges share an endvertex.
• A matching is maximal if no matching M’
exists such that M  M’.

• The size of a matching
is a lower bound on the
size of an optimal
solution to Vertex
Cover!

An Approximation Algorithm
for Vertex Cover

• Algorithm: Find a maximal matching M
and output the set S of matched vertices

An Approximation Algorithm
for Vertex Cover
• Theorem: The previous algorithm is a
2-approximation algorithm for Vertex Cover
• Proof:
• S is a vertex cover, otherwhise the
matching would not be maximal.
• OPT≥M, where M is the size of the output
maximal matching.
• SOL=2M, as the number of matched
vertices is twice the size of the matching.

Approximation Algorithms:much more…
• Approximation schemes: (1+ε)-approx.
• Inapproximability results.
• Complexity classes, e.g., APX.

Fixed-Parameter Tractable Algorithms

Easy or Hard?
Problem (optimization): Let G be a graph.
Which is the minimum number of vertices
whose deletion makes G planar?

NP-hard 
[Lewis-Yannakakis ]

Easy or Hard?
Problem (decision): Let G be a graph and k
be an integer. Is there a set of k vertices
whose deletion makes G planar?
Polynomial 
• Easy O(nk+1) time algorithm for solving the problem:
• Consider every set of k vertices. Remove such
vertices. Test the planarity of the resulting graph.

• There are O(nk) such sets. Testing the planarity of
an n-vertex graph takes O(n) time. Then,
T(n,k)= O(nk) O(n) = O(nk+1)

Easy or Hard?
Where is the trick?
In the decision version, k is a constant
parameter part of the input
An O(nk+1)-time algorithm, with k constant, is a
polynomial-time algorithm.

But it is very slow 

Fixed-Parameter Tractability
A problem is fixed-parameter tractable
if it can be solved in f(k) nO(1) time,
where k is a parameter of the problem,
f is an arbitrary function, and nO(1) is a
polynomial (not depending on k).

FPT algorithm for Vertex Cover
Theorem [Melhorn]: There is an O(2k n)time algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• There is a vertex cover with k=0 if and only if G
has no edge.
• Consider any edge e=(u,v). Either u or v belongs
to any vertex cover S.
• Consider both the case in which u S and the
case in which v S.

FPT algorithm for Vertex Cover
u

u

v

v

• u  S -> S is a vertex cover of G if and only if
S-{u} is a vertex cover of G-{u} -> solve the
instance (G-{u}, k-1)
• v  S -> S is a vertex cover of G if and only if
S-{v} is a vertex cover of G-{v} -> solve the
instance (G-{v}, k-1)

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• T(n,0) = O(n)
• T(n,k) = 2 T(n-1, k-1) +O(n) ≤ 2 T(n, k-1) +O(n) ≤
2 (2 T(n, k-2) +O(n)) +O(n) ≤
2 (2 (2 T(n, k-3) +O(n)) +O(n)) +O(n) ≤
2 (2 (2 (…(2 T(n, 0)+O(n)) + … +O(n))
+O(n)) +O(n) ≤
2k O(n) + (2k-1 + 2k-2 + 2k-3 + ... + 1) O(n) =
2k O(n) + (2k - 1) O(n) = O(2k n)

Reduction Rules
Reduction rule : a rule (that is, a polynomial time
algorithm) that transforms an instance (I,k) to
an "equivalent and simpler” instance (I', k’).

Equivalent: (I,k) is a YES instance if and only if
(I', k') is a YES instance.
Simpler: |I'|<|I| or k'occurrences of a particular substructure.

Another FPT algorithm for Vertex Cover
Theorem: There is an O(1.6181k n2)-time
algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• We apply the following two reduction rules:
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k).
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u,N(u)},k-1).

Another FPT algorithm for Vertex Cover
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k). Correctness: if S is a vertex
cover of G and u is in S, then S-{u} is also a
vertex cover of G, as u has no incident edge.
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u, N(u)},k-1). Correctness: if S is a
vertex cover of G and u is in S, then
S-{u}  N(u) is also a vertex cover of G, as u
has no other incident edge.

Another FPT algorithm for Vertex Cover
• If neither of the two rules can be applied,
then every vertex has degree at least 2.
• Pick a vertex u. Any vertex cover of G
contains either u or N(u). Thus, (G,k) is a YES
instance if and only if (G-{u},k-1) or
(G-N(u),k-|N(u)|) is.

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• Since |N(u)|\geq 2,
• T(n,k) ≤ T(n,k-1)+ T(n,k-2)+O(n^2).
• Fibonacci series: every number is the sum of
the previous two xk =xk-1 +xk-2 +c.

• The k-th number of the Fibonacci series
tends to the golden ratio to the power of k.
• T(n,k)=Φk O(n2)=((1+√5)/2)k O(n2) =
O(1.6181k n2).

Kernelization
• Sometimes the reduction rules work till the size
of the problem is reduced really a lot. That is,
after the reduction rules have been applied,
the problem has size g(k), for some function k.
In this case the problem has a g(k)-kernel.

• Kernel: given a problem and an instance (I,k), a
kernel is an algorithm that outputs in polynomial
time an instance (I',k') such that (a) (I',k') is a
YES instance if and only if (I,k) is; (b) |I'|and k'
Kernelization
• Theorem [Niedermaier]: Every fixed-parameter
tractable problem has a g(k)-kernel.
• Proof: Suppose that there exists a FPT
algorithm with running time f(k) nc, for some
function f and some constant c. Consider an
instance (I,k) with |I|=n.
• If n>f(k), we run the decision algorithm in time
f(k) nc < nc+1. If it returns YES (NO), the
kernelization algorithm outputs a constant size
YES (resp. NO) instance.
• If n≤f(k), the the kernelization algorithm
returns (I,k).

Kernelization
• The last theorem implies that every problem
that is FPT has a kernel.
• However, the goal is to obtain kernels that are
"small", that is, polynomial in k, or even constant.

FPT: much more…
• Some problems are not FPT (e.g., graph coloring).
• Complexity classes: W[1] -> Can a nondeterministic Turing machine accept an unary
string s in at most k steps?
• Independent Set is W[1]-hard.
• Reductions to W[1]-hard problems give new
W[1]-hard problems.
• Lower bounds for FPT tractability
• Upper and lower bounds for the size of the
kernels

FPT: much more…
• Theorem [Robertson and Seymour]: Every graph
problem with parameter k whose YES istances
are closed under taking minors can be solved in
O(f(k) n3)


Slide 33

Tecniche Algoritmiche per Grafi e Reti
Fabrizio Frati

Dipartimento di Informatica e Automazione
Università degli Studi Roma Tre

• 3 CREDITI
• I° periodo:
• Lunedì 9:45-11:15 aula N13

• II° periodo:
• Venerdì 8:00-9:45 aula N7

• Contatti:
• {angelini,gdb,frati,ratm} @dia.uniroma3.it
• Ricevimento: mercoledì dalle 17 alle 19

• Struttura del Corso
• ~ 8 seminari
• algoritmi, strutture dati, combinatorica,
graph drawing…

• progetti a gruppi di 2 - 4 persone
• problema di ricerca

• Materiale Didattico
• slides
• G. Di Battista, P. Eades, R. Tamassia, I. G.
Tollis, Graph Drawing: Algorithms for the
Visualization of Graphs, 1999. Prentice Hall.

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
C. Computer System Organization
1.
2.
3.
4.
5.

Processor Architectures
Computer-Communication Networks
Application-Based Systems
Performance of Systems
Computer System Implementations

ACM Computing Classification System
C. Computer System Organization
2. Computer-Communication Networks
2.1 Network Architectures
2.2 Network Protocols
2.3 Network Operations
2.4 Distributed Systems
2.5 LAN & WAN
2.6 Internetworking

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
E. Data
1.
2.
3.
4.
5.

Data Structures
Data Storage Representations
Data Encryption
Coding and Information Theory
Files

ACM Computing Classification System
E. Data
1. Data Structures
1.1 Arrays
1.2 Distributed Data Structures
1.3 Graphs and Networks
1.4 Lists, Stacks, and Queues
1.5 Records
1.6 Tables
1.7 Trees

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
F. Theory of Computation
1.
2.
3.
4.

Computation by Abstract Devices
Analysis of Algorithms and Problem Complexity
Logics and Meanings of Programs
Mathematical Logic and Formal Languages

ACM Computing Classification System
F. Theory of Computation
1. Computation by Abstract Devices
1.1 Models of Computation
1.2 Complexity Measures and Completeness
1.2.1 Complexity Hierarchies
1.2.2 Machine-Independent Complexity
1.2.3 Reducibility and Completeness
1.2.4 Relations among Complexity Classes

ACM Computing Classification System
F. Theory of Computation
2. Analysis of Algorithms and Problem Complexity
2.1 Numerical Algorithms
2.2 Non-numerical Algorithms and Problems
2.2.1 Complexity of Proof Procedures
2.2.2 Computations on Discrete Structures
2.2.3 Geometrical Problems
2.2.4 Pattern Matching
2.2.5 Routing and Layout
2.2.6 Sequencing and Scheduling
2.2.7 Sorting and Searching

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
G. Mathematics of Computing
1.
2.
3.
4.

Numerical Analysis
Discrete Mathematics
Probability and Statistics
Mathematical Software

ACM Computing Classification System
G. Mathematics of Computing
2. Discrete Mathematics
2.1 Combinatorics

2.1.1 Combinatorial Algorithms
2.1.2 Counting Problems
2.1.3 Generating Functions
2.1.4 Permutations and Combinations
2.1.5 Recurrences and Difference Equations

2.2 Graph Theory
2.2.1 Graph Algorithms
2.2.2 Graph Labeling

2.2.5 Path and Circuit Problems
2.2.6 Trees

2.3 Applications

a world FULL of NP-hard problems
Problem: I want to travel among a set of
cities driving the fewest possible number
of KMs. IT’S DIFFICULT!!

Problem: I want to put a set of objects
into some bags, knowing that each bag
can not afford more than 10 KGs and
trying to use as few bags as possible.
IT’S DIFFICULT!!

How to Deal with NP-hard problems?
• Exact Algorithms
• Randomized Algorithms
• Approximation Algorithms
• Fixed-Parameter Tractable Algorithms
• …

Approximation Algorithms

Approximation Algorithms
• We want a solution “close” to the
optimal one.
• Given a minimization problem Π, an
algorithm is an α-approximation for Π if,
for every instance I of Π, it outputs a
solution SOL(I) such that
SOL(I)/OPT(I) ≤ α

Vertex Cover
• Problem: Given a graph G(V,E), find a
minimum vertex cover, that is, a set V’  V
such that every edge e  E has an
endvertex in V’.

NP-hard 
[Karp]

How to Guarantee an Approximation?
• We want an approximation algorithm
for Vertex Cover.
• The cost of the solution produced by the
algorithm should be compared with the
cost of an optimal solution.

• But computing the cost of an optimal
solution is NP-HARD!!
LOWER BOUNDS!

Lower Bound for Vertex Cover
• Given a graph G(V,E), a matching M is
a set of edges M  E such that no two
edges share an endvertex.
• A matching is maximal if no matching M’
exists such that M  M’.

• The size of a matching
is a lower bound on the
size of an optimal
solution to Vertex
Cover!

An Approximation Algorithm
for Vertex Cover

• Algorithm: Find a maximal matching M
and output the set S of matched vertices

An Approximation Algorithm
for Vertex Cover
• Theorem: The previous algorithm is a
2-approximation algorithm for Vertex Cover
• Proof:
• S is a vertex cover, otherwhise the
matching would not be maximal.
• OPT≥M, where M is the size of the output
maximal matching.
• SOL=2M, as the number of matched
vertices is twice the size of the matching.

Approximation Algorithms:much more…
• Approximation schemes: (1+ε)-approx.
• Inapproximability results.
• Complexity classes, e.g., APX.

Fixed-Parameter Tractable Algorithms

Easy or Hard?
Problem (optimization): Let G be a graph.
Which is the minimum number of vertices
whose deletion makes G planar?

NP-hard 
[Lewis-Yannakakis ]

Easy or Hard?
Problem (decision): Let G be a graph and k
be an integer. Is there a set of k vertices
whose deletion makes G planar?
Polynomial 
• Easy O(nk+1) time algorithm for solving the problem:
• Consider every set of k vertices. Remove such
vertices. Test the planarity of the resulting graph.

• There are O(nk) such sets. Testing the planarity of
an n-vertex graph takes O(n) time. Then,
T(n,k)= O(nk) O(n) = O(nk+1)

Easy or Hard?
Where is the trick?
In the decision version, k is a constant
parameter part of the input
An O(nk+1)-time algorithm, with k constant, is a
polynomial-time algorithm.

But it is very slow 

Fixed-Parameter Tractability
A problem is fixed-parameter tractable
if it can be solved in f(k) nO(1) time,
where k is a parameter of the problem,
f is an arbitrary function, and nO(1) is a
polynomial (not depending on k).

FPT algorithm for Vertex Cover
Theorem [Melhorn]: There is an O(2k n)time algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• There is a vertex cover with k=0 if and only if G
has no edge.
• Consider any edge e=(u,v). Either u or v belongs
to any vertex cover S.
• Consider both the case in which u S and the
case in which v S.

FPT algorithm for Vertex Cover
u

u

v

v

• u  S -> S is a vertex cover of G if and only if
S-{u} is a vertex cover of G-{u} -> solve the
instance (G-{u}, k-1)
• v  S -> S is a vertex cover of G if and only if
S-{v} is a vertex cover of G-{v} -> solve the
instance (G-{v}, k-1)

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• T(n,0) = O(n)
• T(n,k) = 2 T(n-1, k-1) +O(n) ≤ 2 T(n, k-1) +O(n) ≤
2 (2 T(n, k-2) +O(n)) +O(n) ≤
2 (2 (2 T(n, k-3) +O(n)) +O(n)) +O(n) ≤
2 (2 (2 (…(2 T(n, 0)+O(n)) + … +O(n))
+O(n)) +O(n) ≤
2k O(n) + (2k-1 + 2k-2 + 2k-3 + ... + 1) O(n) =
2k O(n) + (2k - 1) O(n) = O(2k n)

Reduction Rules
Reduction rule : a rule (that is, a polynomial time
algorithm) that transforms an instance (I,k) to
an "equivalent and simpler” instance (I', k’).

Equivalent: (I,k) is a YES instance if and only if
(I', k') is a YES instance.
Simpler: |I'|<|I| or k'occurrences of a particular substructure.

Another FPT algorithm for Vertex Cover
Theorem: There is an O(1.6181k n2)-time
algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• We apply the following two reduction rules:
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k).
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u,N(u)},k-1).

Another FPT algorithm for Vertex Cover
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k). Correctness: if S is a vertex
cover of G and u is in S, then S-{u} is also a
vertex cover of G, as u has no incident edge.
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u, N(u)},k-1). Correctness: if S is a
vertex cover of G and u is in S, then
S-{u}  N(u) is also a vertex cover of G, as u
has no other incident edge.

Another FPT algorithm for Vertex Cover
• If neither of the two rules can be applied,
then every vertex has degree at least 2.
• Pick a vertex u. Any vertex cover of G
contains either u or N(u). Thus, (G,k) is a YES
instance if and only if (G-{u},k-1) or
(G-N(u),k-|N(u)|) is.

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• Since |N(u)|\geq 2,
• T(n,k) ≤ T(n,k-1)+ T(n,k-2)+O(n^2).
• Fibonacci series: every number is the sum of
the previous two xk =xk-1 +xk-2 +c.

• The k-th number of the Fibonacci series
tends to the golden ratio to the power of k.
• T(n,k)=Φk O(n2)=((1+√5)/2)k O(n2) =
O(1.6181k n2).

Kernelization
• Sometimes the reduction rules work till the size
of the problem is reduced really a lot. That is,
after the reduction rules have been applied,
the problem has size g(k), for some function k.
In this case the problem has a g(k)-kernel.

• Kernel: given a problem and an instance (I,k), a
kernel is an algorithm that outputs in polynomial
time an instance (I',k') such that (a) (I',k') is a
YES instance if and only if (I,k) is; (b) |I'|and k'
Kernelization
• Theorem [Niedermaier]: Every fixed-parameter
tractable problem has a g(k)-kernel.
• Proof: Suppose that there exists a FPT
algorithm with running time f(k) nc, for some
function f and some constant c. Consider an
instance (I,k) with |I|=n.
• If n>f(k), we run the decision algorithm in time
f(k) nc < nc+1. If it returns YES (NO), the
kernelization algorithm outputs a constant size
YES (resp. NO) instance.
• If n≤f(k), the the kernelization algorithm
returns (I,k).

Kernelization
• The last theorem implies that every problem
that is FPT has a kernel.
• However, the goal is to obtain kernels that are
"small", that is, polynomial in k, or even constant.

FPT: much more…
• Some problems are not FPT (e.g., graph coloring).
• Complexity classes: W[1] -> Can a nondeterministic Turing machine accept an unary
string s in at most k steps?
• Independent Set is W[1]-hard.
• Reductions to W[1]-hard problems give new
W[1]-hard problems.
• Lower bounds for FPT tractability
• Upper and lower bounds for the size of the
kernels

FPT: much more…
• Theorem [Robertson and Seymour]: Every graph
problem with parameter k whose YES istances
are closed under taking minors can be solved in
O(f(k) n3)


Slide 34

Tecniche Algoritmiche per Grafi e Reti
Fabrizio Frati

Dipartimento di Informatica e Automazione
Università degli Studi Roma Tre

• 3 CREDITI
• I° periodo:
• Lunedì 9:45-11:15 aula N13

• II° periodo:
• Venerdì 8:00-9:45 aula N7

• Contatti:
• {angelini,gdb,frati,ratm} @dia.uniroma3.it
• Ricevimento: mercoledì dalle 17 alle 19

• Struttura del Corso
• ~ 8 seminari
• algoritmi, strutture dati, combinatorica,
graph drawing…

• progetti a gruppi di 2 - 4 persone
• problema di ricerca

• Materiale Didattico
• slides
• G. Di Battista, P. Eades, R. Tamassia, I. G.
Tollis, Graph Drawing: Algorithms for the
Visualization of Graphs, 1999. Prentice Hall.

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
C. Computer System Organization
1.
2.
3.
4.
5.

Processor Architectures
Computer-Communication Networks
Application-Based Systems
Performance of Systems
Computer System Implementations

ACM Computing Classification System
C. Computer System Organization
2. Computer-Communication Networks
2.1 Network Architectures
2.2 Network Protocols
2.3 Network Operations
2.4 Distributed Systems
2.5 LAN & WAN
2.6 Internetworking

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
E. Data
1.
2.
3.
4.
5.

Data Structures
Data Storage Representations
Data Encryption
Coding and Information Theory
Files

ACM Computing Classification System
E. Data
1. Data Structures
1.1 Arrays
1.2 Distributed Data Structures
1.3 Graphs and Networks
1.4 Lists, Stacks, and Queues
1.5 Records
1.6 Tables
1.7 Trees

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
F. Theory of Computation
1.
2.
3.
4.

Computation by Abstract Devices
Analysis of Algorithms and Problem Complexity
Logics and Meanings of Programs
Mathematical Logic and Formal Languages

ACM Computing Classification System
F. Theory of Computation
1. Computation by Abstract Devices
1.1 Models of Computation
1.2 Complexity Measures and Completeness
1.2.1 Complexity Hierarchies
1.2.2 Machine-Independent Complexity
1.2.3 Reducibility and Completeness
1.2.4 Relations among Complexity Classes

ACM Computing Classification System
F. Theory of Computation
2. Analysis of Algorithms and Problem Complexity
2.1 Numerical Algorithms
2.2 Non-numerical Algorithms and Problems
2.2.1 Complexity of Proof Procedures
2.2.2 Computations on Discrete Structures
2.2.3 Geometrical Problems
2.2.4 Pattern Matching
2.2.5 Routing and Layout
2.2.6 Sequencing and Scheduling
2.2.7 Sorting and Searching

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
G. Mathematics of Computing
1.
2.
3.
4.

Numerical Analysis
Discrete Mathematics
Probability and Statistics
Mathematical Software

ACM Computing Classification System
G. Mathematics of Computing
2. Discrete Mathematics
2.1 Combinatorics

2.1.1 Combinatorial Algorithms
2.1.2 Counting Problems
2.1.3 Generating Functions
2.1.4 Permutations and Combinations
2.1.5 Recurrences and Difference Equations

2.2 Graph Theory
2.2.1 Graph Algorithms
2.2.2 Graph Labeling

2.2.5 Path and Circuit Problems
2.2.6 Trees

2.3 Applications

a world FULL of NP-hard problems
Problem: I want to travel among a set of
cities driving the fewest possible number
of KMs. IT’S DIFFICULT!!

Problem: I want to put a set of objects
into some bags, knowing that each bag
can not afford more than 10 KGs and
trying to use as few bags as possible.
IT’S DIFFICULT!!

How to Deal with NP-hard problems?
• Exact Algorithms
• Randomized Algorithms
• Approximation Algorithms
• Fixed-Parameter Tractable Algorithms
• …

Approximation Algorithms

Approximation Algorithms
• We want a solution “close” to the
optimal one.
• Given a minimization problem Π, an
algorithm is an α-approximation for Π if,
for every instance I of Π, it outputs a
solution SOL(I) such that
SOL(I)/OPT(I) ≤ α

Vertex Cover
• Problem: Given a graph G(V,E), find a
minimum vertex cover, that is, a set V’  V
such that every edge e  E has an
endvertex in V’.

NP-hard 
[Karp]

How to Guarantee an Approximation?
• We want an approximation algorithm
for Vertex Cover.
• The cost of the solution produced by the
algorithm should be compared with the
cost of an optimal solution.

• But computing the cost of an optimal
solution is NP-HARD!!
LOWER BOUNDS!

Lower Bound for Vertex Cover
• Given a graph G(V,E), a matching M is
a set of edges M  E such that no two
edges share an endvertex.
• A matching is maximal if no matching M’
exists such that M  M’.

• The size of a matching
is a lower bound on the
size of an optimal
solution to Vertex
Cover!

An Approximation Algorithm
for Vertex Cover

• Algorithm: Find a maximal matching M
and output the set S of matched vertices

An Approximation Algorithm
for Vertex Cover
• Theorem: The previous algorithm is a
2-approximation algorithm for Vertex Cover
• Proof:
• S is a vertex cover, otherwhise the
matching would not be maximal.
• OPT≥M, where M is the size of the output
maximal matching.
• SOL=2M, as the number of matched
vertices is twice the size of the matching.

Approximation Algorithms:much more…
• Approximation schemes: (1+ε)-approx.
• Inapproximability results.
• Complexity classes, e.g., APX.

Fixed-Parameter Tractable Algorithms

Easy or Hard?
Problem (optimization): Let G be a graph.
Which is the minimum number of vertices
whose deletion makes G planar?

NP-hard 
[Lewis-Yannakakis ]

Easy or Hard?
Problem (decision): Let G be a graph and k
be an integer. Is there a set of k vertices
whose deletion makes G planar?
Polynomial 
• Easy O(nk+1) time algorithm for solving the problem:
• Consider every set of k vertices. Remove such
vertices. Test the planarity of the resulting graph.

• There are O(nk) such sets. Testing the planarity of
an n-vertex graph takes O(n) time. Then,
T(n,k)= O(nk) O(n) = O(nk+1)

Easy or Hard?
Where is the trick?
In the decision version, k is a constant
parameter part of the input
An O(nk+1)-time algorithm, with k constant, is a
polynomial-time algorithm.

But it is very slow 

Fixed-Parameter Tractability
A problem is fixed-parameter tractable
if it can be solved in f(k) nO(1) time,
where k is a parameter of the problem,
f is an arbitrary function, and nO(1) is a
polynomial (not depending on k).

FPT algorithm for Vertex Cover
Theorem [Melhorn]: There is an O(2k n)time algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• There is a vertex cover with k=0 if and only if G
has no edge.
• Consider any edge e=(u,v). Either u or v belongs
to any vertex cover S.
• Consider both the case in which u S and the
case in which v S.

FPT algorithm for Vertex Cover
u

u

v

v

• u  S -> S is a vertex cover of G if and only if
S-{u} is a vertex cover of G-{u} -> solve the
instance (G-{u}, k-1)
• v  S -> S is a vertex cover of G if and only if
S-{v} is a vertex cover of G-{v} -> solve the
instance (G-{v}, k-1)

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• T(n,0) = O(n)
• T(n,k) = 2 T(n-1, k-1) +O(n) ≤ 2 T(n, k-1) +O(n) ≤
2 (2 T(n, k-2) +O(n)) +O(n) ≤
2 (2 (2 T(n, k-3) +O(n)) +O(n)) +O(n) ≤
2 (2 (2 (…(2 T(n, 0)+O(n)) + … +O(n))
+O(n)) +O(n) ≤
2k O(n) + (2k-1 + 2k-2 + 2k-3 + ... + 1) O(n) =
2k O(n) + (2k - 1) O(n) = O(2k n)

Reduction Rules
Reduction rule : a rule (that is, a polynomial time
algorithm) that transforms an instance (I,k) to
an "equivalent and simpler” instance (I', k’).

Equivalent: (I,k) is a YES instance if and only if
(I', k') is a YES instance.
Simpler: |I'|<|I| or k'occurrences of a particular substructure.

Another FPT algorithm for Vertex Cover
Theorem: There is an O(1.6181k n2)-time
algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• We apply the following two reduction rules:
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k).
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u,N(u)},k-1).

Another FPT algorithm for Vertex Cover
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k). Correctness: if S is a vertex
cover of G and u is in S, then S-{u} is also a
vertex cover of G, as u has no incident edge.
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u, N(u)},k-1). Correctness: if S is a
vertex cover of G and u is in S, then
S-{u}  N(u) is also a vertex cover of G, as u
has no other incident edge.

Another FPT algorithm for Vertex Cover
• If neither of the two rules can be applied,
then every vertex has degree at least 2.
• Pick a vertex u. Any vertex cover of G
contains either u or N(u). Thus, (G,k) is a YES
instance if and only if (G-{u},k-1) or
(G-N(u),k-|N(u)|) is.

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• Since |N(u)|\geq 2,
• T(n,k) ≤ T(n,k-1)+ T(n,k-2)+O(n^2).
• Fibonacci series: every number is the sum of
the previous two xk =xk-1 +xk-2 +c.

• The k-th number of the Fibonacci series
tends to the golden ratio to the power of k.
• T(n,k)=Φk O(n2)=((1+√5)/2)k O(n2) =
O(1.6181k n2).

Kernelization
• Sometimes the reduction rules work till the size
of the problem is reduced really a lot. That is,
after the reduction rules have been applied,
the problem has size g(k), for some function k.
In this case the problem has a g(k)-kernel.

• Kernel: given a problem and an instance (I,k), a
kernel is an algorithm that outputs in polynomial
time an instance (I',k') such that (a) (I',k') is a
YES instance if and only if (I,k) is; (b) |I'|and k'
Kernelization
• Theorem [Niedermaier]: Every fixed-parameter
tractable problem has a g(k)-kernel.
• Proof: Suppose that there exists a FPT
algorithm with running time f(k) nc, for some
function f and some constant c. Consider an
instance (I,k) with |I|=n.
• If n>f(k), we run the decision algorithm in time
f(k) nc < nc+1. If it returns YES (NO), the
kernelization algorithm outputs a constant size
YES (resp. NO) instance.
• If n≤f(k), the the kernelization algorithm
returns (I,k).

Kernelization
• The last theorem implies that every problem
that is FPT has a kernel.
• However, the goal is to obtain kernels that are
"small", that is, polynomial in k, or even constant.

FPT: much more…
• Some problems are not FPT (e.g., graph coloring).
• Complexity classes: W[1] -> Can a nondeterministic Turing machine accept an unary
string s in at most k steps?
• Independent Set is W[1]-hard.
• Reductions to W[1]-hard problems give new
W[1]-hard problems.
• Lower bounds for FPT tractability
• Upper and lower bounds for the size of the
kernels

FPT: much more…
• Theorem [Robertson and Seymour]: Every graph
problem with parameter k whose YES istances
are closed under taking minors can be solved in
O(f(k) n3)


Slide 35

Tecniche Algoritmiche per Grafi e Reti
Fabrizio Frati

Dipartimento di Informatica e Automazione
Università degli Studi Roma Tre

• 3 CREDITI
• I° periodo:
• Lunedì 9:45-11:15 aula N13

• II° periodo:
• Venerdì 8:00-9:45 aula N7

• Contatti:
• {angelini,gdb,frati,ratm} @dia.uniroma3.it
• Ricevimento: mercoledì dalle 17 alle 19

• Struttura del Corso
• ~ 8 seminari
• algoritmi, strutture dati, combinatorica,
graph drawing…

• progetti a gruppi di 2 - 4 persone
• problema di ricerca

• Materiale Didattico
• slides
• G. Di Battista, P. Eades, R. Tamassia, I. G.
Tollis, Graph Drawing: Algorithms for the
Visualization of Graphs, 1999. Prentice Hall.

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
C. Computer System Organization
1.
2.
3.
4.
5.

Processor Architectures
Computer-Communication Networks
Application-Based Systems
Performance of Systems
Computer System Implementations

ACM Computing Classification System
C. Computer System Organization
2. Computer-Communication Networks
2.1 Network Architectures
2.2 Network Protocols
2.3 Network Operations
2.4 Distributed Systems
2.5 LAN & WAN
2.6 Internetworking

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
E. Data
1.
2.
3.
4.
5.

Data Structures
Data Storage Representations
Data Encryption
Coding and Information Theory
Files

ACM Computing Classification System
E. Data
1. Data Structures
1.1 Arrays
1.2 Distributed Data Structures
1.3 Graphs and Networks
1.4 Lists, Stacks, and Queues
1.5 Records
1.6 Tables
1.7 Trees

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
F. Theory of Computation
1.
2.
3.
4.

Computation by Abstract Devices
Analysis of Algorithms and Problem Complexity
Logics and Meanings of Programs
Mathematical Logic and Formal Languages

ACM Computing Classification System
F. Theory of Computation
1. Computation by Abstract Devices
1.1 Models of Computation
1.2 Complexity Measures and Completeness
1.2.1 Complexity Hierarchies
1.2.2 Machine-Independent Complexity
1.2.3 Reducibility and Completeness
1.2.4 Relations among Complexity Classes

ACM Computing Classification System
F. Theory of Computation
2. Analysis of Algorithms and Problem Complexity
2.1 Numerical Algorithms
2.2 Non-numerical Algorithms and Problems
2.2.1 Complexity of Proof Procedures
2.2.2 Computations on Discrete Structures
2.2.3 Geometrical Problems
2.2.4 Pattern Matching
2.2.5 Routing and Layout
2.2.6 Sequencing and Scheduling
2.2.7 Sorting and Searching

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
G. Mathematics of Computing
1.
2.
3.
4.

Numerical Analysis
Discrete Mathematics
Probability and Statistics
Mathematical Software

ACM Computing Classification System
G. Mathematics of Computing
2. Discrete Mathematics
2.1 Combinatorics

2.1.1 Combinatorial Algorithms
2.1.2 Counting Problems
2.1.3 Generating Functions
2.1.4 Permutations and Combinations
2.1.5 Recurrences and Difference Equations

2.2 Graph Theory
2.2.1 Graph Algorithms
2.2.2 Graph Labeling

2.2.5 Path and Circuit Problems
2.2.6 Trees

2.3 Applications

a world FULL of NP-hard problems
Problem: I want to travel among a set of
cities driving the fewest possible number
of KMs. IT’S DIFFICULT!!

Problem: I want to put a set of objects
into some bags, knowing that each bag
can not afford more than 10 KGs and
trying to use as few bags as possible.
IT’S DIFFICULT!!

How to Deal with NP-hard problems?
• Exact Algorithms
• Randomized Algorithms
• Approximation Algorithms
• Fixed-Parameter Tractable Algorithms
• …

Approximation Algorithms

Approximation Algorithms
• We want a solution “close” to the
optimal one.
• Given a minimization problem Π, an
algorithm is an α-approximation for Π if,
for every instance I of Π, it outputs a
solution SOL(I) such that
SOL(I)/OPT(I) ≤ α

Vertex Cover
• Problem: Given a graph G(V,E), find a
minimum vertex cover, that is, a set V’  V
such that every edge e  E has an
endvertex in V’.

NP-hard 
[Karp]

How to Guarantee an Approximation?
• We want an approximation algorithm
for Vertex Cover.
• The cost of the solution produced by the
algorithm should be compared with the
cost of an optimal solution.

• But computing the cost of an optimal
solution is NP-HARD!!
LOWER BOUNDS!

Lower Bound for Vertex Cover
• Given a graph G(V,E), a matching M is
a set of edges M  E such that no two
edges share an endvertex.
• A matching is maximal if no matching M’
exists such that M  M’.

• The size of a matching
is a lower bound on the
size of an optimal
solution to Vertex
Cover!

An Approximation Algorithm
for Vertex Cover

• Algorithm: Find a maximal matching M
and output the set S of matched vertices

An Approximation Algorithm
for Vertex Cover
• Theorem: The previous algorithm is a
2-approximation algorithm for Vertex Cover
• Proof:
• S is a vertex cover, otherwhise the
matching would not be maximal.
• OPT≥M, where M is the size of the output
maximal matching.
• SOL=2M, as the number of matched
vertices is twice the size of the matching.

Approximation Algorithms:much more…
• Approximation schemes: (1+ε)-approx.
• Inapproximability results.
• Complexity classes, e.g., APX.

Fixed-Parameter Tractable Algorithms

Easy or Hard?
Problem (optimization): Let G be a graph.
Which is the minimum number of vertices
whose deletion makes G planar?

NP-hard 
[Lewis-Yannakakis ]

Easy or Hard?
Problem (decision): Let G be a graph and k
be an integer. Is there a set of k vertices
whose deletion makes G planar?
Polynomial 
• Easy O(nk+1) time algorithm for solving the problem:
• Consider every set of k vertices. Remove such
vertices. Test the planarity of the resulting graph.

• There are O(nk) such sets. Testing the planarity of
an n-vertex graph takes O(n) time. Then,
T(n,k)= O(nk) O(n) = O(nk+1)

Easy or Hard?
Where is the trick?
In the decision version, k is a constant
parameter part of the input
An O(nk+1)-time algorithm, with k constant, is a
polynomial-time algorithm.

But it is very slow 

Fixed-Parameter Tractability
A problem is fixed-parameter tractable
if it can be solved in f(k) nO(1) time,
where k is a parameter of the problem,
f is an arbitrary function, and nO(1) is a
polynomial (not depending on k).

FPT algorithm for Vertex Cover
Theorem [Melhorn]: There is an O(2k n)time algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• There is a vertex cover with k=0 if and only if G
has no edge.
• Consider any edge e=(u,v). Either u or v belongs
to any vertex cover S.
• Consider both the case in which u S and the
case in which v S.

FPT algorithm for Vertex Cover
u

u

v

v

• u  S -> S is a vertex cover of G if and only if
S-{u} is a vertex cover of G-{u} -> solve the
instance (G-{u}, k-1)
• v  S -> S is a vertex cover of G if and only if
S-{v} is a vertex cover of G-{v} -> solve the
instance (G-{v}, k-1)

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• T(n,0) = O(n)
• T(n,k) = 2 T(n-1, k-1) +O(n) ≤ 2 T(n, k-1) +O(n) ≤
2 (2 T(n, k-2) +O(n)) +O(n) ≤
2 (2 (2 T(n, k-3) +O(n)) +O(n)) +O(n) ≤
2 (2 (2 (…(2 T(n, 0)+O(n)) + … +O(n))
+O(n)) +O(n) ≤
2k O(n) + (2k-1 + 2k-2 + 2k-3 + ... + 1) O(n) =
2k O(n) + (2k - 1) O(n) = O(2k n)

Reduction Rules
Reduction rule : a rule (that is, a polynomial time
algorithm) that transforms an instance (I,k) to
an "equivalent and simpler” instance (I', k’).

Equivalent: (I,k) is a YES instance if and only if
(I', k') is a YES instance.
Simpler: |I'|<|I| or k'occurrences of a particular substructure.

Another FPT algorithm for Vertex Cover
Theorem: There is an O(1.6181k n2)-time
algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• We apply the following two reduction rules:
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k).
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u,N(u)},k-1).

Another FPT algorithm for Vertex Cover
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k). Correctness: if S is a vertex
cover of G and u is in S, then S-{u} is also a
vertex cover of G, as u has no incident edge.
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u, N(u)},k-1). Correctness: if S is a
vertex cover of G and u is in S, then
S-{u}  N(u) is also a vertex cover of G, as u
has no other incident edge.

Another FPT algorithm for Vertex Cover
• If neither of the two rules can be applied,
then every vertex has degree at least 2.
• Pick a vertex u. Any vertex cover of G
contains either u or N(u). Thus, (G,k) is a YES
instance if and only if (G-{u},k-1) or
(G-N(u),k-|N(u)|) is.

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• Since |N(u)|\geq 2,
• T(n,k) ≤ T(n,k-1)+ T(n,k-2)+O(n^2).
• Fibonacci series: every number is the sum of
the previous two xk =xk-1 +xk-2 +c.

• The k-th number of the Fibonacci series
tends to the golden ratio to the power of k.
• T(n,k)=Φk O(n2)=((1+√5)/2)k O(n2) =
O(1.6181k n2).

Kernelization
• Sometimes the reduction rules work till the size
of the problem is reduced really a lot. That is,
after the reduction rules have been applied,
the problem has size g(k), for some function k.
In this case the problem has a g(k)-kernel.

• Kernel: given a problem and an instance (I,k), a
kernel is an algorithm that outputs in polynomial
time an instance (I',k') such that (a) (I',k') is a
YES instance if and only if (I,k) is; (b) |I'|and k'
Kernelization
• Theorem [Niedermaier]: Every fixed-parameter
tractable problem has a g(k)-kernel.
• Proof: Suppose that there exists a FPT
algorithm with running time f(k) nc, for some
function f and some constant c. Consider an
instance (I,k) with |I|=n.
• If n>f(k), we run the decision algorithm in time
f(k) nc < nc+1. If it returns YES (NO), the
kernelization algorithm outputs a constant size
YES (resp. NO) instance.
• If n≤f(k), the the kernelization algorithm
returns (I,k).

Kernelization
• The last theorem implies that every problem
that is FPT has a kernel.
• However, the goal is to obtain kernels that are
"small", that is, polynomial in k, or even constant.

FPT: much more…
• Some problems are not FPT (e.g., graph coloring).
• Complexity classes: W[1] -> Can a nondeterministic Turing machine accept an unary
string s in at most k steps?
• Independent Set is W[1]-hard.
• Reductions to W[1]-hard problems give new
W[1]-hard problems.
• Lower bounds for FPT tractability
• Upper and lower bounds for the size of the
kernels

FPT: much more…
• Theorem [Robertson and Seymour]: Every graph
problem with parameter k whose YES istances
are closed under taking minors can be solved in
O(f(k) n3)


Slide 36

Tecniche Algoritmiche per Grafi e Reti
Fabrizio Frati

Dipartimento di Informatica e Automazione
Università degli Studi Roma Tre

• 3 CREDITI
• I° periodo:
• Lunedì 9:45-11:15 aula N13

• II° periodo:
• Venerdì 8:00-9:45 aula N7

• Contatti:
• {angelini,gdb,frati,ratm} @dia.uniroma3.it
• Ricevimento: mercoledì dalle 17 alle 19

• Struttura del Corso
• ~ 8 seminari
• algoritmi, strutture dati, combinatorica,
graph drawing…

• progetti a gruppi di 2 - 4 persone
• problema di ricerca

• Materiale Didattico
• slides
• G. Di Battista, P. Eades, R. Tamassia, I. G.
Tollis, Graph Drawing: Algorithms for the
Visualization of Graphs, 1999. Prentice Hall.

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
C. Computer System Organization
1.
2.
3.
4.
5.

Processor Architectures
Computer-Communication Networks
Application-Based Systems
Performance of Systems
Computer System Implementations

ACM Computing Classification System
C. Computer System Organization
2. Computer-Communication Networks
2.1 Network Architectures
2.2 Network Protocols
2.3 Network Operations
2.4 Distributed Systems
2.5 LAN & WAN
2.6 Internetworking

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
E. Data
1.
2.
3.
4.
5.

Data Structures
Data Storage Representations
Data Encryption
Coding and Information Theory
Files

ACM Computing Classification System
E. Data
1. Data Structures
1.1 Arrays
1.2 Distributed Data Structures
1.3 Graphs and Networks
1.4 Lists, Stacks, and Queues
1.5 Records
1.6 Tables
1.7 Trees

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
F. Theory of Computation
1.
2.
3.
4.

Computation by Abstract Devices
Analysis of Algorithms and Problem Complexity
Logics and Meanings of Programs
Mathematical Logic and Formal Languages

ACM Computing Classification System
F. Theory of Computation
1. Computation by Abstract Devices
1.1 Models of Computation
1.2 Complexity Measures and Completeness
1.2.1 Complexity Hierarchies
1.2.2 Machine-Independent Complexity
1.2.3 Reducibility and Completeness
1.2.4 Relations among Complexity Classes

ACM Computing Classification System
F. Theory of Computation
2. Analysis of Algorithms and Problem Complexity
2.1 Numerical Algorithms
2.2 Non-numerical Algorithms and Problems
2.2.1 Complexity of Proof Procedures
2.2.2 Computations on Discrete Structures
2.2.3 Geometrical Problems
2.2.4 Pattern Matching
2.2.5 Routing and Layout
2.2.6 Sequencing and Scheduling
2.2.7 Sorting and Searching

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
G. Mathematics of Computing
1.
2.
3.
4.

Numerical Analysis
Discrete Mathematics
Probability and Statistics
Mathematical Software

ACM Computing Classification System
G. Mathematics of Computing
2. Discrete Mathematics
2.1 Combinatorics

2.1.1 Combinatorial Algorithms
2.1.2 Counting Problems
2.1.3 Generating Functions
2.1.4 Permutations and Combinations
2.1.5 Recurrences and Difference Equations

2.2 Graph Theory
2.2.1 Graph Algorithms
2.2.2 Graph Labeling

2.2.5 Path and Circuit Problems
2.2.6 Trees

2.3 Applications

a world FULL of NP-hard problems
Problem: I want to travel among a set of
cities driving the fewest possible number
of KMs. IT’S DIFFICULT!!

Problem: I want to put a set of objects
into some bags, knowing that each bag
can not afford more than 10 KGs and
trying to use as few bags as possible.
IT’S DIFFICULT!!

How to Deal with NP-hard problems?
• Exact Algorithms
• Randomized Algorithms
• Approximation Algorithms
• Fixed-Parameter Tractable Algorithms
• …

Approximation Algorithms

Approximation Algorithms
• We want a solution “close” to the
optimal one.
• Given a minimization problem Π, an
algorithm is an α-approximation for Π if,
for every instance I of Π, it outputs a
solution SOL(I) such that
SOL(I)/OPT(I) ≤ α

Vertex Cover
• Problem: Given a graph G(V,E), find a
minimum vertex cover, that is, a set V’  V
such that every edge e  E has an
endvertex in V’.

NP-hard 
[Karp]

How to Guarantee an Approximation?
• We want an approximation algorithm
for Vertex Cover.
• The cost of the solution produced by the
algorithm should be compared with the
cost of an optimal solution.

• But computing the cost of an optimal
solution is NP-HARD!!
LOWER BOUNDS!

Lower Bound for Vertex Cover
• Given a graph G(V,E), a matching M is
a set of edges M  E such that no two
edges share an endvertex.
• A matching is maximal if no matching M’
exists such that M  M’.

• The size of a matching
is a lower bound on the
size of an optimal
solution to Vertex
Cover!

An Approximation Algorithm
for Vertex Cover

• Algorithm: Find a maximal matching M
and output the set S of matched vertices

An Approximation Algorithm
for Vertex Cover
• Theorem: The previous algorithm is a
2-approximation algorithm for Vertex Cover
• Proof:
• S is a vertex cover, otherwhise the
matching would not be maximal.
• OPT≥M, where M is the size of the output
maximal matching.
• SOL=2M, as the number of matched
vertices is twice the size of the matching.

Approximation Algorithms:much more…
• Approximation schemes: (1+ε)-approx.
• Inapproximability results.
• Complexity classes, e.g., APX.

Fixed-Parameter Tractable Algorithms

Easy or Hard?
Problem (optimization): Let G be a graph.
Which is the minimum number of vertices
whose deletion makes G planar?

NP-hard 
[Lewis-Yannakakis ]

Easy or Hard?
Problem (decision): Let G be a graph and k
be an integer. Is there a set of k vertices
whose deletion makes G planar?
Polynomial 
• Easy O(nk+1) time algorithm for solving the problem:
• Consider every set of k vertices. Remove such
vertices. Test the planarity of the resulting graph.

• There are O(nk) such sets. Testing the planarity of
an n-vertex graph takes O(n) time. Then,
T(n,k)= O(nk) O(n) = O(nk+1)

Easy or Hard?
Where is the trick?
In the decision version, k is a constant
parameter part of the input
An O(nk+1)-time algorithm, with k constant, is a
polynomial-time algorithm.

But it is very slow 

Fixed-Parameter Tractability
A problem is fixed-parameter tractable
if it can be solved in f(k) nO(1) time,
where k is a parameter of the problem,
f is an arbitrary function, and nO(1) is a
polynomial (not depending on k).

FPT algorithm for Vertex Cover
Theorem [Melhorn]: There is an O(2k n)time algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• There is a vertex cover with k=0 if and only if G
has no edge.
• Consider any edge e=(u,v). Either u or v belongs
to any vertex cover S.
• Consider both the case in which u S and the
case in which v S.

FPT algorithm for Vertex Cover
u

u

v

v

• u  S -> S is a vertex cover of G if and only if
S-{u} is a vertex cover of G-{u} -> solve the
instance (G-{u}, k-1)
• v  S -> S is a vertex cover of G if and only if
S-{v} is a vertex cover of G-{v} -> solve the
instance (G-{v}, k-1)

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• T(n,0) = O(n)
• T(n,k) = 2 T(n-1, k-1) +O(n) ≤ 2 T(n, k-1) +O(n) ≤
2 (2 T(n, k-2) +O(n)) +O(n) ≤
2 (2 (2 T(n, k-3) +O(n)) +O(n)) +O(n) ≤
2 (2 (2 (…(2 T(n, 0)+O(n)) + … +O(n))
+O(n)) +O(n) ≤
2k O(n) + (2k-1 + 2k-2 + 2k-3 + ... + 1) O(n) =
2k O(n) + (2k - 1) O(n) = O(2k n)

Reduction Rules
Reduction rule : a rule (that is, a polynomial time
algorithm) that transforms an instance (I,k) to
an "equivalent and simpler” instance (I', k’).

Equivalent: (I,k) is a YES instance if and only if
(I', k') is a YES instance.
Simpler: |I'|<|I| or k'occurrences of a particular substructure.

Another FPT algorithm for Vertex Cover
Theorem: There is an O(1.6181k n2)-time
algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• We apply the following two reduction rules:
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k).
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u,N(u)},k-1).

Another FPT algorithm for Vertex Cover
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k). Correctness: if S is a vertex
cover of G and u is in S, then S-{u} is also a
vertex cover of G, as u has no incident edge.
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u, N(u)},k-1). Correctness: if S is a
vertex cover of G and u is in S, then
S-{u}  N(u) is also a vertex cover of G, as u
has no other incident edge.

Another FPT algorithm for Vertex Cover
• If neither of the two rules can be applied,
then every vertex has degree at least 2.
• Pick a vertex u. Any vertex cover of G
contains either u or N(u). Thus, (G,k) is a YES
instance if and only if (G-{u},k-1) or
(G-N(u),k-|N(u)|) is.

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• Since |N(u)|\geq 2,
• T(n,k) ≤ T(n,k-1)+ T(n,k-2)+O(n^2).
• Fibonacci series: every number is the sum of
the previous two xk =xk-1 +xk-2 +c.

• The k-th number of the Fibonacci series
tends to the golden ratio to the power of k.
• T(n,k)=Φk O(n2)=((1+√5)/2)k O(n2) =
O(1.6181k n2).

Kernelization
• Sometimes the reduction rules work till the size
of the problem is reduced really a lot. That is,
after the reduction rules have been applied,
the problem has size g(k), for some function k.
In this case the problem has a g(k)-kernel.

• Kernel: given a problem and an instance (I,k), a
kernel is an algorithm that outputs in polynomial
time an instance (I',k') such that (a) (I',k') is a
YES instance if and only if (I,k) is; (b) |I'|and k'
Kernelization
• Theorem [Niedermaier]: Every fixed-parameter
tractable problem has a g(k)-kernel.
• Proof: Suppose that there exists a FPT
algorithm with running time f(k) nc, for some
function f and some constant c. Consider an
instance (I,k) with |I|=n.
• If n>f(k), we run the decision algorithm in time
f(k) nc < nc+1. If it returns YES (NO), the
kernelization algorithm outputs a constant size
YES (resp. NO) instance.
• If n≤f(k), the the kernelization algorithm
returns (I,k).

Kernelization
• The last theorem implies that every problem
that is FPT has a kernel.
• However, the goal is to obtain kernels that are
"small", that is, polynomial in k, or even constant.

FPT: much more…
• Some problems are not FPT (e.g., graph coloring).
• Complexity classes: W[1] -> Can a nondeterministic Turing machine accept an unary
string s in at most k steps?
• Independent Set is W[1]-hard.
• Reductions to W[1]-hard problems give new
W[1]-hard problems.
• Lower bounds for FPT tractability
• Upper and lower bounds for the size of the
kernels

FPT: much more…
• Theorem [Robertson and Seymour]: Every graph
problem with parameter k whose YES istances
are closed under taking minors can be solved in
O(f(k) n3)


Slide 37

Tecniche Algoritmiche per Grafi e Reti
Fabrizio Frati

Dipartimento di Informatica e Automazione
Università degli Studi Roma Tre

• 3 CREDITI
• I° periodo:
• Lunedì 9:45-11:15 aula N13

• II° periodo:
• Venerdì 8:00-9:45 aula N7

• Contatti:
• {angelini,gdb,frati,ratm} @dia.uniroma3.it
• Ricevimento: mercoledì dalle 17 alle 19

• Struttura del Corso
• ~ 8 seminari
• algoritmi, strutture dati, combinatorica,
graph drawing…

• progetti a gruppi di 2 - 4 persone
• problema di ricerca

• Materiale Didattico
• slides
• G. Di Battista, P. Eades, R. Tamassia, I. G.
Tollis, Graph Drawing: Algorithms for the
Visualization of Graphs, 1999. Prentice Hall.

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
C. Computer System Organization
1.
2.
3.
4.
5.

Processor Architectures
Computer-Communication Networks
Application-Based Systems
Performance of Systems
Computer System Implementations

ACM Computing Classification System
C. Computer System Organization
2. Computer-Communication Networks
2.1 Network Architectures
2.2 Network Protocols
2.3 Network Operations
2.4 Distributed Systems
2.5 LAN & WAN
2.6 Internetworking

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
E. Data
1.
2.
3.
4.
5.

Data Structures
Data Storage Representations
Data Encryption
Coding and Information Theory
Files

ACM Computing Classification System
E. Data
1. Data Structures
1.1 Arrays
1.2 Distributed Data Structures
1.3 Graphs and Networks
1.4 Lists, Stacks, and Queues
1.5 Records
1.6 Tables
1.7 Trees

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
F. Theory of Computation
1.
2.
3.
4.

Computation by Abstract Devices
Analysis of Algorithms and Problem Complexity
Logics and Meanings of Programs
Mathematical Logic and Formal Languages

ACM Computing Classification System
F. Theory of Computation
1. Computation by Abstract Devices
1.1 Models of Computation
1.2 Complexity Measures and Completeness
1.2.1 Complexity Hierarchies
1.2.2 Machine-Independent Complexity
1.2.3 Reducibility and Completeness
1.2.4 Relations among Complexity Classes

ACM Computing Classification System
F. Theory of Computation
2. Analysis of Algorithms and Problem Complexity
2.1 Numerical Algorithms
2.2 Non-numerical Algorithms and Problems
2.2.1 Complexity of Proof Procedures
2.2.2 Computations on Discrete Structures
2.2.3 Geometrical Problems
2.2.4 Pattern Matching
2.2.5 Routing and Layout
2.2.6 Sequencing and Scheduling
2.2.7 Sorting and Searching

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
G. Mathematics of Computing
1.
2.
3.
4.

Numerical Analysis
Discrete Mathematics
Probability and Statistics
Mathematical Software

ACM Computing Classification System
G. Mathematics of Computing
2. Discrete Mathematics
2.1 Combinatorics

2.1.1 Combinatorial Algorithms
2.1.2 Counting Problems
2.1.3 Generating Functions
2.1.4 Permutations and Combinations
2.1.5 Recurrences and Difference Equations

2.2 Graph Theory
2.2.1 Graph Algorithms
2.2.2 Graph Labeling

2.2.5 Path and Circuit Problems
2.2.6 Trees

2.3 Applications

a world FULL of NP-hard problems
Problem: I want to travel among a set of
cities driving the fewest possible number
of KMs. IT’S DIFFICULT!!

Problem: I want to put a set of objects
into some bags, knowing that each bag
can not afford more than 10 KGs and
trying to use as few bags as possible.
IT’S DIFFICULT!!

How to Deal with NP-hard problems?
• Exact Algorithms
• Randomized Algorithms
• Approximation Algorithms
• Fixed-Parameter Tractable Algorithms
• …

Approximation Algorithms

Approximation Algorithms
• We want a solution “close” to the
optimal one.
• Given a minimization problem Π, an
algorithm is an α-approximation for Π if,
for every instance I of Π, it outputs a
solution SOL(I) such that
SOL(I)/OPT(I) ≤ α

Vertex Cover
• Problem: Given a graph G(V,E), find a
minimum vertex cover, that is, a set V’  V
such that every edge e  E has an
endvertex in V’.

NP-hard 
[Karp]

How to Guarantee an Approximation?
• We want an approximation algorithm
for Vertex Cover.
• The cost of the solution produced by the
algorithm should be compared with the
cost of an optimal solution.

• But computing the cost of an optimal
solution is NP-HARD!!
LOWER BOUNDS!

Lower Bound for Vertex Cover
• Given a graph G(V,E), a matching M is
a set of edges M  E such that no two
edges share an endvertex.
• A matching is maximal if no matching M’
exists such that M  M’.

• The size of a matching
is a lower bound on the
size of an optimal
solution to Vertex
Cover!

An Approximation Algorithm
for Vertex Cover

• Algorithm: Find a maximal matching M
and output the set S of matched vertices

An Approximation Algorithm
for Vertex Cover
• Theorem: The previous algorithm is a
2-approximation algorithm for Vertex Cover
• Proof:
• S is a vertex cover, otherwhise the
matching would not be maximal.
• OPT≥M, where M is the size of the output
maximal matching.
• SOL=2M, as the number of matched
vertices is twice the size of the matching.

Approximation Algorithms:much more…
• Approximation schemes: (1+ε)-approx.
• Inapproximability results.
• Complexity classes, e.g., APX.

Fixed-Parameter Tractable Algorithms

Easy or Hard?
Problem (optimization): Let G be a graph.
Which is the minimum number of vertices
whose deletion makes G planar?

NP-hard 
[Lewis-Yannakakis ]

Easy or Hard?
Problem (decision): Let G be a graph and k
be an integer. Is there a set of k vertices
whose deletion makes G planar?
Polynomial 
• Easy O(nk+1) time algorithm for solving the problem:
• Consider every set of k vertices. Remove such
vertices. Test the planarity of the resulting graph.

• There are O(nk) such sets. Testing the planarity of
an n-vertex graph takes O(n) time. Then,
T(n,k)= O(nk) O(n) = O(nk+1)

Easy or Hard?
Where is the trick?
In the decision version, k is a constant
parameter part of the input
An O(nk+1)-time algorithm, with k constant, is a
polynomial-time algorithm.

But it is very slow 

Fixed-Parameter Tractability
A problem is fixed-parameter tractable
if it can be solved in f(k) nO(1) time,
where k is a parameter of the problem,
f is an arbitrary function, and nO(1) is a
polynomial (not depending on k).

FPT algorithm for Vertex Cover
Theorem [Melhorn]: There is an O(2k n)time algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• There is a vertex cover with k=0 if and only if G
has no edge.
• Consider any edge e=(u,v). Either u or v belongs
to any vertex cover S.
• Consider both the case in which u S and the
case in which v S.

FPT algorithm for Vertex Cover
u

u

v

v

• u  S -> S is a vertex cover of G if and only if
S-{u} is a vertex cover of G-{u} -> solve the
instance (G-{u}, k-1)
• v  S -> S is a vertex cover of G if and only if
S-{v} is a vertex cover of G-{v} -> solve the
instance (G-{v}, k-1)

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• T(n,0) = O(n)
• T(n,k) = 2 T(n-1, k-1) +O(n) ≤ 2 T(n, k-1) +O(n) ≤
2 (2 T(n, k-2) +O(n)) +O(n) ≤
2 (2 (2 T(n, k-3) +O(n)) +O(n)) +O(n) ≤
2 (2 (2 (…(2 T(n, 0)+O(n)) + … +O(n))
+O(n)) +O(n) ≤
2k O(n) + (2k-1 + 2k-2 + 2k-3 + ... + 1) O(n) =
2k O(n) + (2k - 1) O(n) = O(2k n)

Reduction Rules
Reduction rule : a rule (that is, a polynomial time
algorithm) that transforms an instance (I,k) to
an "equivalent and simpler” instance (I', k’).

Equivalent: (I,k) is a YES instance if and only if
(I', k') is a YES instance.
Simpler: |I'|<|I| or k'occurrences of a particular substructure.

Another FPT algorithm for Vertex Cover
Theorem: There is an O(1.6181k n2)-time
algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• We apply the following two reduction rules:
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k).
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u,N(u)},k-1).

Another FPT algorithm for Vertex Cover
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k). Correctness: if S is a vertex
cover of G and u is in S, then S-{u} is also a
vertex cover of G, as u has no incident edge.
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u, N(u)},k-1). Correctness: if S is a
vertex cover of G and u is in S, then
S-{u}  N(u) is also a vertex cover of G, as u
has no other incident edge.

Another FPT algorithm for Vertex Cover
• If neither of the two rules can be applied,
then every vertex has degree at least 2.
• Pick a vertex u. Any vertex cover of G
contains either u or N(u). Thus, (G,k) is a YES
instance if and only if (G-{u},k-1) or
(G-N(u),k-|N(u)|) is.

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• Since |N(u)|\geq 2,
• T(n,k) ≤ T(n,k-1)+ T(n,k-2)+O(n^2).
• Fibonacci series: every number is the sum of
the previous two xk =xk-1 +xk-2 +c.

• The k-th number of the Fibonacci series
tends to the golden ratio to the power of k.
• T(n,k)=Φk O(n2)=((1+√5)/2)k O(n2) =
O(1.6181k n2).

Kernelization
• Sometimes the reduction rules work till the size
of the problem is reduced really a lot. That is,
after the reduction rules have been applied,
the problem has size g(k), for some function k.
In this case the problem has a g(k)-kernel.

• Kernel: given a problem and an instance (I,k), a
kernel is an algorithm that outputs in polynomial
time an instance (I',k') such that (a) (I',k') is a
YES instance if and only if (I,k) is; (b) |I'|and k'
Kernelization
• Theorem [Niedermaier]: Every fixed-parameter
tractable problem has a g(k)-kernel.
• Proof: Suppose that there exists a FPT
algorithm with running time f(k) nc, for some
function f and some constant c. Consider an
instance (I,k) with |I|=n.
• If n>f(k), we run the decision algorithm in time
f(k) nc < nc+1. If it returns YES (NO), the
kernelization algorithm outputs a constant size
YES (resp. NO) instance.
• If n≤f(k), the the kernelization algorithm
returns (I,k).

Kernelization
• The last theorem implies that every problem
that is FPT has a kernel.
• However, the goal is to obtain kernels that are
"small", that is, polynomial in k, or even constant.

FPT: much more…
• Some problems are not FPT (e.g., graph coloring).
• Complexity classes: W[1] -> Can a nondeterministic Turing machine accept an unary
string s in at most k steps?
• Independent Set is W[1]-hard.
• Reductions to W[1]-hard problems give new
W[1]-hard problems.
• Lower bounds for FPT tractability
• Upper and lower bounds for the size of the
kernels

FPT: much more…
• Theorem [Robertson and Seymour]: Every graph
problem with parameter k whose YES istances
are closed under taking minors can be solved in
O(f(k) n3)


Slide 38

Tecniche Algoritmiche per Grafi e Reti
Fabrizio Frati

Dipartimento di Informatica e Automazione
Università degli Studi Roma Tre

• 3 CREDITI
• I° periodo:
• Lunedì 9:45-11:15 aula N13

• II° periodo:
• Venerdì 8:00-9:45 aula N7

• Contatti:
• {angelini,gdb,frati,ratm} @dia.uniroma3.it
• Ricevimento: mercoledì dalle 17 alle 19

• Struttura del Corso
• ~ 8 seminari
• algoritmi, strutture dati, combinatorica,
graph drawing…

• progetti a gruppi di 2 - 4 persone
• problema di ricerca

• Materiale Didattico
• slides
• G. Di Battista, P. Eades, R. Tamassia, I. G.
Tollis, Graph Drawing: Algorithms for the
Visualization of Graphs, 1999. Prentice Hall.

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
C. Computer System Organization
1.
2.
3.
4.
5.

Processor Architectures
Computer-Communication Networks
Application-Based Systems
Performance of Systems
Computer System Implementations

ACM Computing Classification System
C. Computer System Organization
2. Computer-Communication Networks
2.1 Network Architectures
2.2 Network Protocols
2.3 Network Operations
2.4 Distributed Systems
2.5 LAN & WAN
2.6 Internetworking

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
E. Data
1.
2.
3.
4.
5.

Data Structures
Data Storage Representations
Data Encryption
Coding and Information Theory
Files

ACM Computing Classification System
E. Data
1. Data Structures
1.1 Arrays
1.2 Distributed Data Structures
1.3 Graphs and Networks
1.4 Lists, Stacks, and Queues
1.5 Records
1.6 Tables
1.7 Trees

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
F. Theory of Computation
1.
2.
3.
4.

Computation by Abstract Devices
Analysis of Algorithms and Problem Complexity
Logics and Meanings of Programs
Mathematical Logic and Formal Languages

ACM Computing Classification System
F. Theory of Computation
1. Computation by Abstract Devices
1.1 Models of Computation
1.2 Complexity Measures and Completeness
1.2.1 Complexity Hierarchies
1.2.2 Machine-Independent Complexity
1.2.3 Reducibility and Completeness
1.2.4 Relations among Complexity Classes

ACM Computing Classification System
F. Theory of Computation
2. Analysis of Algorithms and Problem Complexity
2.1 Numerical Algorithms
2.2 Non-numerical Algorithms and Problems
2.2.1 Complexity of Proof Procedures
2.2.2 Computations on Discrete Structures
2.2.3 Geometrical Problems
2.2.4 Pattern Matching
2.2.5 Routing and Layout
2.2.6 Sequencing and Scheduling
2.2.7 Sorting and Searching

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
G. Mathematics of Computing
1.
2.
3.
4.

Numerical Analysis
Discrete Mathematics
Probability and Statistics
Mathematical Software

ACM Computing Classification System
G. Mathematics of Computing
2. Discrete Mathematics
2.1 Combinatorics

2.1.1 Combinatorial Algorithms
2.1.2 Counting Problems
2.1.3 Generating Functions
2.1.4 Permutations and Combinations
2.1.5 Recurrences and Difference Equations

2.2 Graph Theory
2.2.1 Graph Algorithms
2.2.2 Graph Labeling

2.2.5 Path and Circuit Problems
2.2.6 Trees

2.3 Applications

a world FULL of NP-hard problems
Problem: I want to travel among a set of
cities driving the fewest possible number
of KMs. IT’S DIFFICULT!!

Problem: I want to put a set of objects
into some bags, knowing that each bag
can not afford more than 10 KGs and
trying to use as few bags as possible.
IT’S DIFFICULT!!

How to Deal with NP-hard problems?
• Exact Algorithms
• Randomized Algorithms
• Approximation Algorithms
• Fixed-Parameter Tractable Algorithms
• …

Approximation Algorithms

Approximation Algorithms
• We want a solution “close” to the
optimal one.
• Given a minimization problem Π, an
algorithm is an α-approximation for Π if,
for every instance I of Π, it outputs a
solution SOL(I) such that
SOL(I)/OPT(I) ≤ α

Vertex Cover
• Problem: Given a graph G(V,E), find a
minimum vertex cover, that is, a set V’  V
such that every edge e  E has an
endvertex in V’.

NP-hard 
[Karp]

How to Guarantee an Approximation?
• We want an approximation algorithm
for Vertex Cover.
• The cost of the solution produced by the
algorithm should be compared with the
cost of an optimal solution.

• But computing the cost of an optimal
solution is NP-HARD!!
LOWER BOUNDS!

Lower Bound for Vertex Cover
• Given a graph G(V,E), a matching M is
a set of edges M  E such that no two
edges share an endvertex.
• A matching is maximal if no matching M’
exists such that M  M’.

• The size of a matching
is a lower bound on the
size of an optimal
solution to Vertex
Cover!

An Approximation Algorithm
for Vertex Cover

• Algorithm: Find a maximal matching M
and output the set S of matched vertices

An Approximation Algorithm
for Vertex Cover
• Theorem: The previous algorithm is a
2-approximation algorithm for Vertex Cover
• Proof:
• S is a vertex cover, otherwhise the
matching would not be maximal.
• OPT≥M, where M is the size of the output
maximal matching.
• SOL=2M, as the number of matched
vertices is twice the size of the matching.

Approximation Algorithms:much more…
• Approximation schemes: (1+ε)-approx.
• Inapproximability results.
• Complexity classes, e.g., APX.

Fixed-Parameter Tractable Algorithms

Easy or Hard?
Problem (optimization): Let G be a graph.
Which is the minimum number of vertices
whose deletion makes G planar?

NP-hard 
[Lewis-Yannakakis ]

Easy or Hard?
Problem (decision): Let G be a graph and k
be an integer. Is there a set of k vertices
whose deletion makes G planar?
Polynomial 
• Easy O(nk+1) time algorithm for solving the problem:
• Consider every set of k vertices. Remove such
vertices. Test the planarity of the resulting graph.

• There are O(nk) such sets. Testing the planarity of
an n-vertex graph takes O(n) time. Then,
T(n,k)= O(nk) O(n) = O(nk+1)

Easy or Hard?
Where is the trick?
In the decision version, k is a constant
parameter part of the input
An O(nk+1)-time algorithm, with k constant, is a
polynomial-time algorithm.

But it is very slow 

Fixed-Parameter Tractability
A problem is fixed-parameter tractable
if it can be solved in f(k) nO(1) time,
where k is a parameter of the problem,
f is an arbitrary function, and nO(1) is a
polynomial (not depending on k).

FPT algorithm for Vertex Cover
Theorem [Melhorn]: There is an O(2k n)time algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• There is a vertex cover with k=0 if and only if G
has no edge.
• Consider any edge e=(u,v). Either u or v belongs
to any vertex cover S.
• Consider both the case in which u S and the
case in which v S.

FPT algorithm for Vertex Cover
u

u

v

v

• u  S -> S is a vertex cover of G if and only if
S-{u} is a vertex cover of G-{u} -> solve the
instance (G-{u}, k-1)
• v  S -> S is a vertex cover of G if and only if
S-{v} is a vertex cover of G-{v} -> solve the
instance (G-{v}, k-1)

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• T(n,0) = O(n)
• T(n,k) = 2 T(n-1, k-1) +O(n) ≤ 2 T(n, k-1) +O(n) ≤
2 (2 T(n, k-2) +O(n)) +O(n) ≤
2 (2 (2 T(n, k-3) +O(n)) +O(n)) +O(n) ≤
2 (2 (2 (…(2 T(n, 0)+O(n)) + … +O(n))
+O(n)) +O(n) ≤
2k O(n) + (2k-1 + 2k-2 + 2k-3 + ... + 1) O(n) =
2k O(n) + (2k - 1) O(n) = O(2k n)

Reduction Rules
Reduction rule : a rule (that is, a polynomial time
algorithm) that transforms an instance (I,k) to
an "equivalent and simpler” instance (I', k’).

Equivalent: (I,k) is a YES instance if and only if
(I', k') is a YES instance.
Simpler: |I'|<|I| or k'occurrences of a particular substructure.

Another FPT algorithm for Vertex Cover
Theorem: There is an O(1.6181k n2)-time
algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• We apply the following two reduction rules:
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k).
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u,N(u)},k-1).

Another FPT algorithm for Vertex Cover
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k). Correctness: if S is a vertex
cover of G and u is in S, then S-{u} is also a
vertex cover of G, as u has no incident edge.
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u, N(u)},k-1). Correctness: if S is a
vertex cover of G and u is in S, then
S-{u}  N(u) is also a vertex cover of G, as u
has no other incident edge.

Another FPT algorithm for Vertex Cover
• If neither of the two rules can be applied,
then every vertex has degree at least 2.
• Pick a vertex u. Any vertex cover of G
contains either u or N(u). Thus, (G,k) is a YES
instance if and only if (G-{u},k-1) or
(G-N(u),k-|N(u)|) is.

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• Since |N(u)|\geq 2,
• T(n,k) ≤ T(n,k-1)+ T(n,k-2)+O(n^2).
• Fibonacci series: every number is the sum of
the previous two xk =xk-1 +xk-2 +c.

• The k-th number of the Fibonacci series
tends to the golden ratio to the power of k.
• T(n,k)=Φk O(n2)=((1+√5)/2)k O(n2) =
O(1.6181k n2).

Kernelization
• Sometimes the reduction rules work till the size
of the problem is reduced really a lot. That is,
after the reduction rules have been applied,
the problem has size g(k), for some function k.
In this case the problem has a g(k)-kernel.

• Kernel: given a problem and an instance (I,k), a
kernel is an algorithm that outputs in polynomial
time an instance (I',k') such that (a) (I',k') is a
YES instance if and only if (I,k) is; (b) |I'|and k'
Kernelization
• Theorem [Niedermaier]: Every fixed-parameter
tractable problem has a g(k)-kernel.
• Proof: Suppose that there exists a FPT
algorithm with running time f(k) nc, for some
function f and some constant c. Consider an
instance (I,k) with |I|=n.
• If n>f(k), we run the decision algorithm in time
f(k) nc < nc+1. If it returns YES (NO), the
kernelization algorithm outputs a constant size
YES (resp. NO) instance.
• If n≤f(k), the the kernelization algorithm
returns (I,k).

Kernelization
• The last theorem implies that every problem
that is FPT has a kernel.
• However, the goal is to obtain kernels that are
"small", that is, polynomial in k, or even constant.

FPT: much more…
• Some problems are not FPT (e.g., graph coloring).
• Complexity classes: W[1] -> Can a nondeterministic Turing machine accept an unary
string s in at most k steps?
• Independent Set is W[1]-hard.
• Reductions to W[1]-hard problems give new
W[1]-hard problems.
• Lower bounds for FPT tractability
• Upper and lower bounds for the size of the
kernels

FPT: much more…
• Theorem [Robertson and Seymour]: Every graph
problem with parameter k whose YES istances
are closed under taking minors can be solved in
O(f(k) n3)


Slide 39

Tecniche Algoritmiche per Grafi e Reti
Fabrizio Frati

Dipartimento di Informatica e Automazione
Università degli Studi Roma Tre

• 3 CREDITI
• I° periodo:
• Lunedì 9:45-11:15 aula N13

• II° periodo:
• Venerdì 8:00-9:45 aula N7

• Contatti:
• {angelini,gdb,frati,ratm} @dia.uniroma3.it
• Ricevimento: mercoledì dalle 17 alle 19

• Struttura del Corso
• ~ 8 seminari
• algoritmi, strutture dati, combinatorica,
graph drawing…

• progetti a gruppi di 2 - 4 persone
• problema di ricerca

• Materiale Didattico
• slides
• G. Di Battista, P. Eades, R. Tamassia, I. G.
Tollis, Graph Drawing: Algorithms for the
Visualization of Graphs, 1999. Prentice Hall.

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
C. Computer System Organization
1.
2.
3.
4.
5.

Processor Architectures
Computer-Communication Networks
Application-Based Systems
Performance of Systems
Computer System Implementations

ACM Computing Classification System
C. Computer System Organization
2. Computer-Communication Networks
2.1 Network Architectures
2.2 Network Protocols
2.3 Network Operations
2.4 Distributed Systems
2.5 LAN & WAN
2.6 Internetworking

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
E. Data
1.
2.
3.
4.
5.

Data Structures
Data Storage Representations
Data Encryption
Coding and Information Theory
Files

ACM Computing Classification System
E. Data
1. Data Structures
1.1 Arrays
1.2 Distributed Data Structures
1.3 Graphs and Networks
1.4 Lists, Stacks, and Queues
1.5 Records
1.6 Tables
1.7 Trees

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
F. Theory of Computation
1.
2.
3.
4.

Computation by Abstract Devices
Analysis of Algorithms and Problem Complexity
Logics and Meanings of Programs
Mathematical Logic and Formal Languages

ACM Computing Classification System
F. Theory of Computation
1. Computation by Abstract Devices
1.1 Models of Computation
1.2 Complexity Measures and Completeness
1.2.1 Complexity Hierarchies
1.2.2 Machine-Independent Complexity
1.2.3 Reducibility and Completeness
1.2.4 Relations among Complexity Classes

ACM Computing Classification System
F. Theory of Computation
2. Analysis of Algorithms and Problem Complexity
2.1 Numerical Algorithms
2.2 Non-numerical Algorithms and Problems
2.2.1 Complexity of Proof Procedures
2.2.2 Computations on Discrete Structures
2.2.3 Geometrical Problems
2.2.4 Pattern Matching
2.2.5 Routing and Layout
2.2.6 Sequencing and Scheduling
2.2.7 Sorting and Searching

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
G. Mathematics of Computing
1.
2.
3.
4.

Numerical Analysis
Discrete Mathematics
Probability and Statistics
Mathematical Software

ACM Computing Classification System
G. Mathematics of Computing
2. Discrete Mathematics
2.1 Combinatorics

2.1.1 Combinatorial Algorithms
2.1.2 Counting Problems
2.1.3 Generating Functions
2.1.4 Permutations and Combinations
2.1.5 Recurrences and Difference Equations

2.2 Graph Theory
2.2.1 Graph Algorithms
2.2.2 Graph Labeling

2.2.5 Path and Circuit Problems
2.2.6 Trees

2.3 Applications

a world FULL of NP-hard problems
Problem: I want to travel among a set of
cities driving the fewest possible number
of KMs. IT’S DIFFICULT!!

Problem: I want to put a set of objects
into some bags, knowing that each bag
can not afford more than 10 KGs and
trying to use as few bags as possible.
IT’S DIFFICULT!!

How to Deal with NP-hard problems?
• Exact Algorithms
• Randomized Algorithms
• Approximation Algorithms
• Fixed-Parameter Tractable Algorithms
• …

Approximation Algorithms

Approximation Algorithms
• We want a solution “close” to the
optimal one.
• Given a minimization problem Π, an
algorithm is an α-approximation for Π if,
for every instance I of Π, it outputs a
solution SOL(I) such that
SOL(I)/OPT(I) ≤ α

Vertex Cover
• Problem: Given a graph G(V,E), find a
minimum vertex cover, that is, a set V’  V
such that every edge e  E has an
endvertex in V’.

NP-hard 
[Karp]

How to Guarantee an Approximation?
• We want an approximation algorithm
for Vertex Cover.
• The cost of the solution produced by the
algorithm should be compared with the
cost of an optimal solution.

• But computing the cost of an optimal
solution is NP-HARD!!
LOWER BOUNDS!

Lower Bound for Vertex Cover
• Given a graph G(V,E), a matching M is
a set of edges M  E such that no two
edges share an endvertex.
• A matching is maximal if no matching M’
exists such that M  M’.

• The size of a matching
is a lower bound on the
size of an optimal
solution to Vertex
Cover!

An Approximation Algorithm
for Vertex Cover

• Algorithm: Find a maximal matching M
and output the set S of matched vertices

An Approximation Algorithm
for Vertex Cover
• Theorem: The previous algorithm is a
2-approximation algorithm for Vertex Cover
• Proof:
• S is a vertex cover, otherwhise the
matching would not be maximal.
• OPT≥M, where M is the size of the output
maximal matching.
• SOL=2M, as the number of matched
vertices is twice the size of the matching.

Approximation Algorithms:much more…
• Approximation schemes: (1+ε)-approx.
• Inapproximability results.
• Complexity classes, e.g., APX.

Fixed-Parameter Tractable Algorithms

Easy or Hard?
Problem (optimization): Let G be a graph.
Which is the minimum number of vertices
whose deletion makes G planar?

NP-hard 
[Lewis-Yannakakis ]

Easy or Hard?
Problem (decision): Let G be a graph and k
be an integer. Is there a set of k vertices
whose deletion makes G planar?
Polynomial 
• Easy O(nk+1) time algorithm for solving the problem:
• Consider every set of k vertices. Remove such
vertices. Test the planarity of the resulting graph.

• There are O(nk) such sets. Testing the planarity of
an n-vertex graph takes O(n) time. Then,
T(n,k)= O(nk) O(n) = O(nk+1)

Easy or Hard?
Where is the trick?
In the decision version, k is a constant
parameter part of the input
An O(nk+1)-time algorithm, with k constant, is a
polynomial-time algorithm.

But it is very slow 

Fixed-Parameter Tractability
A problem is fixed-parameter tractable
if it can be solved in f(k) nO(1) time,
where k is a parameter of the problem,
f is an arbitrary function, and nO(1) is a
polynomial (not depending on k).

FPT algorithm for Vertex Cover
Theorem [Melhorn]: There is an O(2k n)time algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• There is a vertex cover with k=0 if and only if G
has no edge.
• Consider any edge e=(u,v). Either u or v belongs
to any vertex cover S.
• Consider both the case in which u S and the
case in which v S.

FPT algorithm for Vertex Cover
u

u

v

v

• u  S -> S is a vertex cover of G if and only if
S-{u} is a vertex cover of G-{u} -> solve the
instance (G-{u}, k-1)
• v  S -> S is a vertex cover of G if and only if
S-{v} is a vertex cover of G-{v} -> solve the
instance (G-{v}, k-1)

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• T(n,0) = O(n)
• T(n,k) = 2 T(n-1, k-1) +O(n) ≤ 2 T(n, k-1) +O(n) ≤
2 (2 T(n, k-2) +O(n)) +O(n) ≤
2 (2 (2 T(n, k-3) +O(n)) +O(n)) +O(n) ≤
2 (2 (2 (…(2 T(n, 0)+O(n)) + … +O(n))
+O(n)) +O(n) ≤
2k O(n) + (2k-1 + 2k-2 + 2k-3 + ... + 1) O(n) =
2k O(n) + (2k - 1) O(n) = O(2k n)

Reduction Rules
Reduction rule : a rule (that is, a polynomial time
algorithm) that transforms an instance (I,k) to
an "equivalent and simpler” instance (I', k’).

Equivalent: (I,k) is a YES instance if and only if
(I', k') is a YES instance.
Simpler: |I'|<|I| or k'occurrences of a particular substructure.

Another FPT algorithm for Vertex Cover
Theorem: There is an O(1.6181k n2)-time
algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• We apply the following two reduction rules:
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k).
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u,N(u)},k-1).

Another FPT algorithm for Vertex Cover
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k). Correctness: if S is a vertex
cover of G and u is in S, then S-{u} is also a
vertex cover of G, as u has no incident edge.
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u, N(u)},k-1). Correctness: if S is a
vertex cover of G and u is in S, then
S-{u}  N(u) is also a vertex cover of G, as u
has no other incident edge.

Another FPT algorithm for Vertex Cover
• If neither of the two rules can be applied,
then every vertex has degree at least 2.
• Pick a vertex u. Any vertex cover of G
contains either u or N(u). Thus, (G,k) is a YES
instance if and only if (G-{u},k-1) or
(G-N(u),k-|N(u)|) is.

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• Since |N(u)|\geq 2,
• T(n,k) ≤ T(n,k-1)+ T(n,k-2)+O(n^2).
• Fibonacci series: every number is the sum of
the previous two xk =xk-1 +xk-2 +c.

• The k-th number of the Fibonacci series
tends to the golden ratio to the power of k.
• T(n,k)=Φk O(n2)=((1+√5)/2)k O(n2) =
O(1.6181k n2).

Kernelization
• Sometimes the reduction rules work till the size
of the problem is reduced really a lot. That is,
after the reduction rules have been applied,
the problem has size g(k), for some function k.
In this case the problem has a g(k)-kernel.

• Kernel: given a problem and an instance (I,k), a
kernel is an algorithm that outputs in polynomial
time an instance (I',k') such that (a) (I',k') is a
YES instance if and only if (I,k) is; (b) |I'|and k'
Kernelization
• Theorem [Niedermaier]: Every fixed-parameter
tractable problem has a g(k)-kernel.
• Proof: Suppose that there exists a FPT
algorithm with running time f(k) nc, for some
function f and some constant c. Consider an
instance (I,k) with |I|=n.
• If n>f(k), we run the decision algorithm in time
f(k) nc < nc+1. If it returns YES (NO), the
kernelization algorithm outputs a constant size
YES (resp. NO) instance.
• If n≤f(k), the the kernelization algorithm
returns (I,k).

Kernelization
• The last theorem implies that every problem
that is FPT has a kernel.
• However, the goal is to obtain kernels that are
"small", that is, polynomial in k, or even constant.

FPT: much more…
• Some problems are not FPT (e.g., graph coloring).
• Complexity classes: W[1] -> Can a nondeterministic Turing machine accept an unary
string s in at most k steps?
• Independent Set is W[1]-hard.
• Reductions to W[1]-hard problems give new
W[1]-hard problems.
• Lower bounds for FPT tractability
• Upper and lower bounds for the size of the
kernels

FPT: much more…
• Theorem [Robertson and Seymour]: Every graph
problem with parameter k whose YES istances
are closed under taking minors can be solved in
O(f(k) n3)


Slide 40

Tecniche Algoritmiche per Grafi e Reti
Fabrizio Frati

Dipartimento di Informatica e Automazione
Università degli Studi Roma Tre

• 3 CREDITI
• I° periodo:
• Lunedì 9:45-11:15 aula N13

• II° periodo:
• Venerdì 8:00-9:45 aula N7

• Contatti:
• {angelini,gdb,frati,ratm} @dia.uniroma3.it
• Ricevimento: mercoledì dalle 17 alle 19

• Struttura del Corso
• ~ 8 seminari
• algoritmi, strutture dati, combinatorica,
graph drawing…

• progetti a gruppi di 2 - 4 persone
• problema di ricerca

• Materiale Didattico
• slides
• G. Di Battista, P. Eades, R. Tamassia, I. G.
Tollis, Graph Drawing: Algorithms for the
Visualization of Graphs, 1999. Prentice Hall.

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
C. Computer System Organization
1.
2.
3.
4.
5.

Processor Architectures
Computer-Communication Networks
Application-Based Systems
Performance of Systems
Computer System Implementations

ACM Computing Classification System
C. Computer System Organization
2. Computer-Communication Networks
2.1 Network Architectures
2.2 Network Protocols
2.3 Network Operations
2.4 Distributed Systems
2.5 LAN & WAN
2.6 Internetworking

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
E. Data
1.
2.
3.
4.
5.

Data Structures
Data Storage Representations
Data Encryption
Coding and Information Theory
Files

ACM Computing Classification System
E. Data
1. Data Structures
1.1 Arrays
1.2 Distributed Data Structures
1.3 Graphs and Networks
1.4 Lists, Stacks, and Queues
1.5 Records
1.6 Tables
1.7 Trees

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
F. Theory of Computation
1.
2.
3.
4.

Computation by Abstract Devices
Analysis of Algorithms and Problem Complexity
Logics and Meanings of Programs
Mathematical Logic and Formal Languages

ACM Computing Classification System
F. Theory of Computation
1. Computation by Abstract Devices
1.1 Models of Computation
1.2 Complexity Measures and Completeness
1.2.1 Complexity Hierarchies
1.2.2 Machine-Independent Complexity
1.2.3 Reducibility and Completeness
1.2.4 Relations among Complexity Classes

ACM Computing Classification System
F. Theory of Computation
2. Analysis of Algorithms and Problem Complexity
2.1 Numerical Algorithms
2.2 Non-numerical Algorithms and Problems
2.2.1 Complexity of Proof Procedures
2.2.2 Computations on Discrete Structures
2.2.3 Geometrical Problems
2.2.4 Pattern Matching
2.2.5 Routing and Layout
2.2.6 Sequencing and Scheduling
2.2.7 Sorting and Searching

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
G. Mathematics of Computing
1.
2.
3.
4.

Numerical Analysis
Discrete Mathematics
Probability and Statistics
Mathematical Software

ACM Computing Classification System
G. Mathematics of Computing
2. Discrete Mathematics
2.1 Combinatorics

2.1.1 Combinatorial Algorithms
2.1.2 Counting Problems
2.1.3 Generating Functions
2.1.4 Permutations and Combinations
2.1.5 Recurrences and Difference Equations

2.2 Graph Theory
2.2.1 Graph Algorithms
2.2.2 Graph Labeling

2.2.5 Path and Circuit Problems
2.2.6 Trees

2.3 Applications

a world FULL of NP-hard problems
Problem: I want to travel among a set of
cities driving the fewest possible number
of KMs. IT’S DIFFICULT!!

Problem: I want to put a set of objects
into some bags, knowing that each bag
can not afford more than 10 KGs and
trying to use as few bags as possible.
IT’S DIFFICULT!!

How to Deal with NP-hard problems?
• Exact Algorithms
• Randomized Algorithms
• Approximation Algorithms
• Fixed-Parameter Tractable Algorithms
• …

Approximation Algorithms

Approximation Algorithms
• We want a solution “close” to the
optimal one.
• Given a minimization problem Π, an
algorithm is an α-approximation for Π if,
for every instance I of Π, it outputs a
solution SOL(I) such that
SOL(I)/OPT(I) ≤ α

Vertex Cover
• Problem: Given a graph G(V,E), find a
minimum vertex cover, that is, a set V’  V
such that every edge e  E has an
endvertex in V’.

NP-hard 
[Karp]

How to Guarantee an Approximation?
• We want an approximation algorithm
for Vertex Cover.
• The cost of the solution produced by the
algorithm should be compared with the
cost of an optimal solution.

• But computing the cost of an optimal
solution is NP-HARD!!
LOWER BOUNDS!

Lower Bound for Vertex Cover
• Given a graph G(V,E), a matching M is
a set of edges M  E such that no two
edges share an endvertex.
• A matching is maximal if no matching M’
exists such that M  M’.

• The size of a matching
is a lower bound on the
size of an optimal
solution to Vertex
Cover!

An Approximation Algorithm
for Vertex Cover

• Algorithm: Find a maximal matching M
and output the set S of matched vertices

An Approximation Algorithm
for Vertex Cover
• Theorem: The previous algorithm is a
2-approximation algorithm for Vertex Cover
• Proof:
• S is a vertex cover, otherwhise the
matching would not be maximal.
• OPT≥M, where M is the size of the output
maximal matching.
• SOL=2M, as the number of matched
vertices is twice the size of the matching.

Approximation Algorithms:much more…
• Approximation schemes: (1+ε)-approx.
• Inapproximability results.
• Complexity classes, e.g., APX.

Fixed-Parameter Tractable Algorithms

Easy or Hard?
Problem (optimization): Let G be a graph.
Which is the minimum number of vertices
whose deletion makes G planar?

NP-hard 
[Lewis-Yannakakis ]

Easy or Hard?
Problem (decision): Let G be a graph and k
be an integer. Is there a set of k vertices
whose deletion makes G planar?
Polynomial 
• Easy O(nk+1) time algorithm for solving the problem:
• Consider every set of k vertices. Remove such
vertices. Test the planarity of the resulting graph.

• There are O(nk) such sets. Testing the planarity of
an n-vertex graph takes O(n) time. Then,
T(n,k)= O(nk) O(n) = O(nk+1)

Easy or Hard?
Where is the trick?
In the decision version, k is a constant
parameter part of the input
An O(nk+1)-time algorithm, with k constant, is a
polynomial-time algorithm.

But it is very slow 

Fixed-Parameter Tractability
A problem is fixed-parameter tractable
if it can be solved in f(k) nO(1) time,
where k is a parameter of the problem,
f is an arbitrary function, and nO(1) is a
polynomial (not depending on k).

FPT algorithm for Vertex Cover
Theorem [Melhorn]: There is an O(2k n)time algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• There is a vertex cover with k=0 if and only if G
has no edge.
• Consider any edge e=(u,v). Either u or v belongs
to any vertex cover S.
• Consider both the case in which u S and the
case in which v S.

FPT algorithm for Vertex Cover
u

u

v

v

• u  S -> S is a vertex cover of G if and only if
S-{u} is a vertex cover of G-{u} -> solve the
instance (G-{u}, k-1)
• v  S -> S is a vertex cover of G if and only if
S-{v} is a vertex cover of G-{v} -> solve the
instance (G-{v}, k-1)

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• T(n,0) = O(n)
• T(n,k) = 2 T(n-1, k-1) +O(n) ≤ 2 T(n, k-1) +O(n) ≤
2 (2 T(n, k-2) +O(n)) +O(n) ≤
2 (2 (2 T(n, k-3) +O(n)) +O(n)) +O(n) ≤
2 (2 (2 (…(2 T(n, 0)+O(n)) + … +O(n))
+O(n)) +O(n) ≤
2k O(n) + (2k-1 + 2k-2 + 2k-3 + ... + 1) O(n) =
2k O(n) + (2k - 1) O(n) = O(2k n)

Reduction Rules
Reduction rule : a rule (that is, a polynomial time
algorithm) that transforms an instance (I,k) to
an "equivalent and simpler” instance (I', k’).

Equivalent: (I,k) is a YES instance if and only if
(I', k') is a YES instance.
Simpler: |I'|<|I| or k'occurrences of a particular substructure.

Another FPT algorithm for Vertex Cover
Theorem: There is an O(1.6181k n2)-time
algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• We apply the following two reduction rules:
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k).
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u,N(u)},k-1).

Another FPT algorithm for Vertex Cover
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k). Correctness: if S is a vertex
cover of G and u is in S, then S-{u} is also a
vertex cover of G, as u has no incident edge.
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u, N(u)},k-1). Correctness: if S is a
vertex cover of G and u is in S, then
S-{u}  N(u) is also a vertex cover of G, as u
has no other incident edge.

Another FPT algorithm for Vertex Cover
• If neither of the two rules can be applied,
then every vertex has degree at least 2.
• Pick a vertex u. Any vertex cover of G
contains either u or N(u). Thus, (G,k) is a YES
instance if and only if (G-{u},k-1) or
(G-N(u),k-|N(u)|) is.

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• Since |N(u)|\geq 2,
• T(n,k) ≤ T(n,k-1)+ T(n,k-2)+O(n^2).
• Fibonacci series: every number is the sum of
the previous two xk =xk-1 +xk-2 +c.

• The k-th number of the Fibonacci series
tends to the golden ratio to the power of k.
• T(n,k)=Φk O(n2)=((1+√5)/2)k O(n2) =
O(1.6181k n2).

Kernelization
• Sometimes the reduction rules work till the size
of the problem is reduced really a lot. That is,
after the reduction rules have been applied,
the problem has size g(k), for some function k.
In this case the problem has a g(k)-kernel.

• Kernel: given a problem and an instance (I,k), a
kernel is an algorithm that outputs in polynomial
time an instance (I',k') such that (a) (I',k') is a
YES instance if and only if (I,k) is; (b) |I'|and k'
Kernelization
• Theorem [Niedermaier]: Every fixed-parameter
tractable problem has a g(k)-kernel.
• Proof: Suppose that there exists a FPT
algorithm with running time f(k) nc, for some
function f and some constant c. Consider an
instance (I,k) with |I|=n.
• If n>f(k), we run the decision algorithm in time
f(k) nc < nc+1. If it returns YES (NO), the
kernelization algorithm outputs a constant size
YES (resp. NO) instance.
• If n≤f(k), the the kernelization algorithm
returns (I,k).

Kernelization
• The last theorem implies that every problem
that is FPT has a kernel.
• However, the goal is to obtain kernels that are
"small", that is, polynomial in k, or even constant.

FPT: much more…
• Some problems are not FPT (e.g., graph coloring).
• Complexity classes: W[1] -> Can a nondeterministic Turing machine accept an unary
string s in at most k steps?
• Independent Set is W[1]-hard.
• Reductions to W[1]-hard problems give new
W[1]-hard problems.
• Lower bounds for FPT tractability
• Upper and lower bounds for the size of the
kernels

FPT: much more…
• Theorem [Robertson and Seymour]: Every graph
problem with parameter k whose YES istances
are closed under taking minors can be solved in
O(f(k) n3)


Slide 41

Tecniche Algoritmiche per Grafi e Reti
Fabrizio Frati

Dipartimento di Informatica e Automazione
Università degli Studi Roma Tre

• 3 CREDITI
• I° periodo:
• Lunedì 9:45-11:15 aula N13

• II° periodo:
• Venerdì 8:00-9:45 aula N7

• Contatti:
• {angelini,gdb,frati,ratm} @dia.uniroma3.it
• Ricevimento: mercoledì dalle 17 alle 19

• Struttura del Corso
• ~ 8 seminari
• algoritmi, strutture dati, combinatorica,
graph drawing…

• progetti a gruppi di 2 - 4 persone
• problema di ricerca

• Materiale Didattico
• slides
• G. Di Battista, P. Eades, R. Tamassia, I. G.
Tollis, Graph Drawing: Algorithms for the
Visualization of Graphs, 1999. Prentice Hall.

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
C. Computer System Organization
1.
2.
3.
4.
5.

Processor Architectures
Computer-Communication Networks
Application-Based Systems
Performance of Systems
Computer System Implementations

ACM Computing Classification System
C. Computer System Organization
2. Computer-Communication Networks
2.1 Network Architectures
2.2 Network Protocols
2.3 Network Operations
2.4 Distributed Systems
2.5 LAN & WAN
2.6 Internetworking

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
E. Data
1.
2.
3.
4.
5.

Data Structures
Data Storage Representations
Data Encryption
Coding and Information Theory
Files

ACM Computing Classification System
E. Data
1. Data Structures
1.1 Arrays
1.2 Distributed Data Structures
1.3 Graphs and Networks
1.4 Lists, Stacks, and Queues
1.5 Records
1.6 Tables
1.7 Trees

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
F. Theory of Computation
1.
2.
3.
4.

Computation by Abstract Devices
Analysis of Algorithms and Problem Complexity
Logics and Meanings of Programs
Mathematical Logic and Formal Languages

ACM Computing Classification System
F. Theory of Computation
1. Computation by Abstract Devices
1.1 Models of Computation
1.2 Complexity Measures and Completeness
1.2.1 Complexity Hierarchies
1.2.2 Machine-Independent Complexity
1.2.3 Reducibility and Completeness
1.2.4 Relations among Complexity Classes

ACM Computing Classification System
F. Theory of Computation
2. Analysis of Algorithms and Problem Complexity
2.1 Numerical Algorithms
2.2 Non-numerical Algorithms and Problems
2.2.1 Complexity of Proof Procedures
2.2.2 Computations on Discrete Structures
2.2.3 Geometrical Problems
2.2.4 Pattern Matching
2.2.5 Routing and Layout
2.2.6 Sequencing and Scheduling
2.2.7 Sorting and Searching

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
G. Mathematics of Computing
1.
2.
3.
4.

Numerical Analysis
Discrete Mathematics
Probability and Statistics
Mathematical Software

ACM Computing Classification System
G. Mathematics of Computing
2. Discrete Mathematics
2.1 Combinatorics

2.1.1 Combinatorial Algorithms
2.1.2 Counting Problems
2.1.3 Generating Functions
2.1.4 Permutations and Combinations
2.1.5 Recurrences and Difference Equations

2.2 Graph Theory
2.2.1 Graph Algorithms
2.2.2 Graph Labeling

2.2.5 Path and Circuit Problems
2.2.6 Trees

2.3 Applications

a world FULL of NP-hard problems
Problem: I want to travel among a set of
cities driving the fewest possible number
of KMs. IT’S DIFFICULT!!

Problem: I want to put a set of objects
into some bags, knowing that each bag
can not afford more than 10 KGs and
trying to use as few bags as possible.
IT’S DIFFICULT!!

How to Deal with NP-hard problems?
• Exact Algorithms
• Randomized Algorithms
• Approximation Algorithms
• Fixed-Parameter Tractable Algorithms
• …

Approximation Algorithms

Approximation Algorithms
• We want a solution “close” to the
optimal one.
• Given a minimization problem Π, an
algorithm is an α-approximation for Π if,
for every instance I of Π, it outputs a
solution SOL(I) such that
SOL(I)/OPT(I) ≤ α

Vertex Cover
• Problem: Given a graph G(V,E), find a
minimum vertex cover, that is, a set V’  V
such that every edge e  E has an
endvertex in V’.

NP-hard 
[Karp]

How to Guarantee an Approximation?
• We want an approximation algorithm
for Vertex Cover.
• The cost of the solution produced by the
algorithm should be compared with the
cost of an optimal solution.

• But computing the cost of an optimal
solution is NP-HARD!!
LOWER BOUNDS!

Lower Bound for Vertex Cover
• Given a graph G(V,E), a matching M is
a set of edges M  E such that no two
edges share an endvertex.
• A matching is maximal if no matching M’
exists such that M  M’.

• The size of a matching
is a lower bound on the
size of an optimal
solution to Vertex
Cover!

An Approximation Algorithm
for Vertex Cover

• Algorithm: Find a maximal matching M
and output the set S of matched vertices

An Approximation Algorithm
for Vertex Cover
• Theorem: The previous algorithm is a
2-approximation algorithm for Vertex Cover
• Proof:
• S is a vertex cover, otherwhise the
matching would not be maximal.
• OPT≥M, where M is the size of the output
maximal matching.
• SOL=2M, as the number of matched
vertices is twice the size of the matching.

Approximation Algorithms:much more…
• Approximation schemes: (1+ε)-approx.
• Inapproximability results.
• Complexity classes, e.g., APX.

Fixed-Parameter Tractable Algorithms

Easy or Hard?
Problem (optimization): Let G be a graph.
Which is the minimum number of vertices
whose deletion makes G planar?

NP-hard 
[Lewis-Yannakakis ]

Easy or Hard?
Problem (decision): Let G be a graph and k
be an integer. Is there a set of k vertices
whose deletion makes G planar?
Polynomial 
• Easy O(nk+1) time algorithm for solving the problem:
• Consider every set of k vertices. Remove such
vertices. Test the planarity of the resulting graph.

• There are O(nk) such sets. Testing the planarity of
an n-vertex graph takes O(n) time. Then,
T(n,k)= O(nk) O(n) = O(nk+1)

Easy or Hard?
Where is the trick?
In the decision version, k is a constant
parameter part of the input
An O(nk+1)-time algorithm, with k constant, is a
polynomial-time algorithm.

But it is very slow 

Fixed-Parameter Tractability
A problem is fixed-parameter tractable
if it can be solved in f(k) nO(1) time,
where k is a parameter of the problem,
f is an arbitrary function, and nO(1) is a
polynomial (not depending on k).

FPT algorithm for Vertex Cover
Theorem [Melhorn]: There is an O(2k n)time algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• There is a vertex cover with k=0 if and only if G
has no edge.
• Consider any edge e=(u,v). Either u or v belongs
to any vertex cover S.
• Consider both the case in which u S and the
case in which v S.

FPT algorithm for Vertex Cover
u

u

v

v

• u  S -> S is a vertex cover of G if and only if
S-{u} is a vertex cover of G-{u} -> solve the
instance (G-{u}, k-1)
• v  S -> S is a vertex cover of G if and only if
S-{v} is a vertex cover of G-{v} -> solve the
instance (G-{v}, k-1)

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• T(n,0) = O(n)
• T(n,k) = 2 T(n-1, k-1) +O(n) ≤ 2 T(n, k-1) +O(n) ≤
2 (2 T(n, k-2) +O(n)) +O(n) ≤
2 (2 (2 T(n, k-3) +O(n)) +O(n)) +O(n) ≤
2 (2 (2 (…(2 T(n, 0)+O(n)) + … +O(n))
+O(n)) +O(n) ≤
2k O(n) + (2k-1 + 2k-2 + 2k-3 + ... + 1) O(n) =
2k O(n) + (2k - 1) O(n) = O(2k n)

Reduction Rules
Reduction rule : a rule (that is, a polynomial time
algorithm) that transforms an instance (I,k) to
an "equivalent and simpler” instance (I', k’).

Equivalent: (I,k) is a YES instance if and only if
(I', k') is a YES instance.
Simpler: |I'|<|I| or k'occurrences of a particular substructure.

Another FPT algorithm for Vertex Cover
Theorem: There is an O(1.6181k n2)-time
algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• We apply the following two reduction rules:
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k).
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u,N(u)},k-1).

Another FPT algorithm for Vertex Cover
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k). Correctness: if S is a vertex
cover of G and u is in S, then S-{u} is also a
vertex cover of G, as u has no incident edge.
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u, N(u)},k-1). Correctness: if S is a
vertex cover of G and u is in S, then
S-{u}  N(u) is also a vertex cover of G, as u
has no other incident edge.

Another FPT algorithm for Vertex Cover
• If neither of the two rules can be applied,
then every vertex has degree at least 2.
• Pick a vertex u. Any vertex cover of G
contains either u or N(u). Thus, (G,k) is a YES
instance if and only if (G-{u},k-1) or
(G-N(u),k-|N(u)|) is.

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• Since |N(u)|\geq 2,
• T(n,k) ≤ T(n,k-1)+ T(n,k-2)+O(n^2).
• Fibonacci series: every number is the sum of
the previous two xk =xk-1 +xk-2 +c.

• The k-th number of the Fibonacci series
tends to the golden ratio to the power of k.
• T(n,k)=Φk O(n2)=((1+√5)/2)k O(n2) =
O(1.6181k n2).

Kernelization
• Sometimes the reduction rules work till the size
of the problem is reduced really a lot. That is,
after the reduction rules have been applied,
the problem has size g(k), for some function k.
In this case the problem has a g(k)-kernel.

• Kernel: given a problem and an instance (I,k), a
kernel is an algorithm that outputs in polynomial
time an instance (I',k') such that (a) (I',k') is a
YES instance if and only if (I,k) is; (b) |I'|and k'
Kernelization
• Theorem [Niedermaier]: Every fixed-parameter
tractable problem has a g(k)-kernel.
• Proof: Suppose that there exists a FPT
algorithm with running time f(k) nc, for some
function f and some constant c. Consider an
instance (I,k) with |I|=n.
• If n>f(k), we run the decision algorithm in time
f(k) nc < nc+1. If it returns YES (NO), the
kernelization algorithm outputs a constant size
YES (resp. NO) instance.
• If n≤f(k), the the kernelization algorithm
returns (I,k).

Kernelization
• The last theorem implies that every problem
that is FPT has a kernel.
• However, the goal is to obtain kernels that are
"small", that is, polynomial in k, or even constant.

FPT: much more…
• Some problems are not FPT (e.g., graph coloring).
• Complexity classes: W[1] -> Can a nondeterministic Turing machine accept an unary
string s in at most k steps?
• Independent Set is W[1]-hard.
• Reductions to W[1]-hard problems give new
W[1]-hard problems.
• Lower bounds for FPT tractability
• Upper and lower bounds for the size of the
kernels

FPT: much more…
• Theorem [Robertson and Seymour]: Every graph
problem with parameter k whose YES istances
are closed under taking minors can be solved in
O(f(k) n3)


Slide 42

Tecniche Algoritmiche per Grafi e Reti
Fabrizio Frati

Dipartimento di Informatica e Automazione
Università degli Studi Roma Tre

• 3 CREDITI
• I° periodo:
• Lunedì 9:45-11:15 aula N13

• II° periodo:
• Venerdì 8:00-9:45 aula N7

• Contatti:
• {angelini,gdb,frati,ratm} @dia.uniroma3.it
• Ricevimento: mercoledì dalle 17 alle 19

• Struttura del Corso
• ~ 8 seminari
• algoritmi, strutture dati, combinatorica,
graph drawing…

• progetti a gruppi di 2 - 4 persone
• problema di ricerca

• Materiale Didattico
• slides
• G. Di Battista, P. Eades, R. Tamassia, I. G.
Tollis, Graph Drawing: Algorithms for the
Visualization of Graphs, 1999. Prentice Hall.

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
C. Computer System Organization
1.
2.
3.
4.
5.

Processor Architectures
Computer-Communication Networks
Application-Based Systems
Performance of Systems
Computer System Implementations

ACM Computing Classification System
C. Computer System Organization
2. Computer-Communication Networks
2.1 Network Architectures
2.2 Network Protocols
2.3 Network Operations
2.4 Distributed Systems
2.5 LAN & WAN
2.6 Internetworking

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
E. Data
1.
2.
3.
4.
5.

Data Structures
Data Storage Representations
Data Encryption
Coding and Information Theory
Files

ACM Computing Classification System
E. Data
1. Data Structures
1.1 Arrays
1.2 Distributed Data Structures
1.3 Graphs and Networks
1.4 Lists, Stacks, and Queues
1.5 Records
1.6 Tables
1.7 Trees

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
F. Theory of Computation
1.
2.
3.
4.

Computation by Abstract Devices
Analysis of Algorithms and Problem Complexity
Logics and Meanings of Programs
Mathematical Logic and Formal Languages

ACM Computing Classification System
F. Theory of Computation
1. Computation by Abstract Devices
1.1 Models of Computation
1.2 Complexity Measures and Completeness
1.2.1 Complexity Hierarchies
1.2.2 Machine-Independent Complexity
1.2.3 Reducibility and Completeness
1.2.4 Relations among Complexity Classes

ACM Computing Classification System
F. Theory of Computation
2. Analysis of Algorithms and Problem Complexity
2.1 Numerical Algorithms
2.2 Non-numerical Algorithms and Problems
2.2.1 Complexity of Proof Procedures
2.2.2 Computations on Discrete Structures
2.2.3 Geometrical Problems
2.2.4 Pattern Matching
2.2.5 Routing and Layout
2.2.6 Sequencing and Scheduling
2.2.7 Sorting and Searching

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
G. Mathematics of Computing
1.
2.
3.
4.

Numerical Analysis
Discrete Mathematics
Probability and Statistics
Mathematical Software

ACM Computing Classification System
G. Mathematics of Computing
2. Discrete Mathematics
2.1 Combinatorics

2.1.1 Combinatorial Algorithms
2.1.2 Counting Problems
2.1.3 Generating Functions
2.1.4 Permutations and Combinations
2.1.5 Recurrences and Difference Equations

2.2 Graph Theory
2.2.1 Graph Algorithms
2.2.2 Graph Labeling

2.2.5 Path and Circuit Problems
2.2.6 Trees

2.3 Applications

a world FULL of NP-hard problems
Problem: I want to travel among a set of
cities driving the fewest possible number
of KMs. IT’S DIFFICULT!!

Problem: I want to put a set of objects
into some bags, knowing that each bag
can not afford more than 10 KGs and
trying to use as few bags as possible.
IT’S DIFFICULT!!

How to Deal with NP-hard problems?
• Exact Algorithms
• Randomized Algorithms
• Approximation Algorithms
• Fixed-Parameter Tractable Algorithms
• …

Approximation Algorithms

Approximation Algorithms
• We want a solution “close” to the
optimal one.
• Given a minimization problem Π, an
algorithm is an α-approximation for Π if,
for every instance I of Π, it outputs a
solution SOL(I) such that
SOL(I)/OPT(I) ≤ α

Vertex Cover
• Problem: Given a graph G(V,E), find a
minimum vertex cover, that is, a set V’  V
such that every edge e  E has an
endvertex in V’.

NP-hard 
[Karp]

How to Guarantee an Approximation?
• We want an approximation algorithm
for Vertex Cover.
• The cost of the solution produced by the
algorithm should be compared with the
cost of an optimal solution.

• But computing the cost of an optimal
solution is NP-HARD!!
LOWER BOUNDS!

Lower Bound for Vertex Cover
• Given a graph G(V,E), a matching M is
a set of edges M  E such that no two
edges share an endvertex.
• A matching is maximal if no matching M’
exists such that M  M’.

• The size of a matching
is a lower bound on the
size of an optimal
solution to Vertex
Cover!

An Approximation Algorithm
for Vertex Cover

• Algorithm: Find a maximal matching M
and output the set S of matched vertices

An Approximation Algorithm
for Vertex Cover
• Theorem: The previous algorithm is a
2-approximation algorithm for Vertex Cover
• Proof:
• S is a vertex cover, otherwhise the
matching would not be maximal.
• OPT≥M, where M is the size of the output
maximal matching.
• SOL=2M, as the number of matched
vertices is twice the size of the matching.

Approximation Algorithms:much more…
• Approximation schemes: (1+ε)-approx.
• Inapproximability results.
• Complexity classes, e.g., APX.

Fixed-Parameter Tractable Algorithms

Easy or Hard?
Problem (optimization): Let G be a graph.
Which is the minimum number of vertices
whose deletion makes G planar?

NP-hard 
[Lewis-Yannakakis ]

Easy or Hard?
Problem (decision): Let G be a graph and k
be an integer. Is there a set of k vertices
whose deletion makes G planar?
Polynomial 
• Easy O(nk+1) time algorithm for solving the problem:
• Consider every set of k vertices. Remove such
vertices. Test the planarity of the resulting graph.

• There are O(nk) such sets. Testing the planarity of
an n-vertex graph takes O(n) time. Then,
T(n,k)= O(nk) O(n) = O(nk+1)

Easy or Hard?
Where is the trick?
In the decision version, k is a constant
parameter part of the input
An O(nk+1)-time algorithm, with k constant, is a
polynomial-time algorithm.

But it is very slow 

Fixed-Parameter Tractability
A problem is fixed-parameter tractable
if it can be solved in f(k) nO(1) time,
where k is a parameter of the problem,
f is an arbitrary function, and nO(1) is a
polynomial (not depending on k).

FPT algorithm for Vertex Cover
Theorem [Melhorn]: There is an O(2k n)time algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• There is a vertex cover with k=0 if and only if G
has no edge.
• Consider any edge e=(u,v). Either u or v belongs
to any vertex cover S.
• Consider both the case in which u S and the
case in which v S.

FPT algorithm for Vertex Cover
u

u

v

v

• u  S -> S is a vertex cover of G if and only if
S-{u} is a vertex cover of G-{u} -> solve the
instance (G-{u}, k-1)
• v  S -> S is a vertex cover of G if and only if
S-{v} is a vertex cover of G-{v} -> solve the
instance (G-{v}, k-1)

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• T(n,0) = O(n)
• T(n,k) = 2 T(n-1, k-1) +O(n) ≤ 2 T(n, k-1) +O(n) ≤
2 (2 T(n, k-2) +O(n)) +O(n) ≤
2 (2 (2 T(n, k-3) +O(n)) +O(n)) +O(n) ≤
2 (2 (2 (…(2 T(n, 0)+O(n)) + … +O(n))
+O(n)) +O(n) ≤
2k O(n) + (2k-1 + 2k-2 + 2k-3 + ... + 1) O(n) =
2k O(n) + (2k - 1) O(n) = O(2k n)

Reduction Rules
Reduction rule : a rule (that is, a polynomial time
algorithm) that transforms an instance (I,k) to
an "equivalent and simpler” instance (I', k’).

Equivalent: (I,k) is a YES instance if and only if
(I', k') is a YES instance.
Simpler: |I'|<|I| or k'occurrences of a particular substructure.

Another FPT algorithm for Vertex Cover
Theorem: There is an O(1.6181k n2)-time
algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• We apply the following two reduction rules:
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k).
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u,N(u)},k-1).

Another FPT algorithm for Vertex Cover
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k). Correctness: if S is a vertex
cover of G and u is in S, then S-{u} is also a
vertex cover of G, as u has no incident edge.
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u, N(u)},k-1). Correctness: if S is a
vertex cover of G and u is in S, then
S-{u}  N(u) is also a vertex cover of G, as u
has no other incident edge.

Another FPT algorithm for Vertex Cover
• If neither of the two rules can be applied,
then every vertex has degree at least 2.
• Pick a vertex u. Any vertex cover of G
contains either u or N(u). Thus, (G,k) is a YES
instance if and only if (G-{u},k-1) or
(G-N(u),k-|N(u)|) is.

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• Since |N(u)|\geq 2,
• T(n,k) ≤ T(n,k-1)+ T(n,k-2)+O(n^2).
• Fibonacci series: every number is the sum of
the previous two xk =xk-1 +xk-2 +c.

• The k-th number of the Fibonacci series
tends to the golden ratio to the power of k.
• T(n,k)=Φk O(n2)=((1+√5)/2)k O(n2) =
O(1.6181k n2).

Kernelization
• Sometimes the reduction rules work till the size
of the problem is reduced really a lot. That is,
after the reduction rules have been applied,
the problem has size g(k), for some function k.
In this case the problem has a g(k)-kernel.

• Kernel: given a problem and an instance (I,k), a
kernel is an algorithm that outputs in polynomial
time an instance (I',k') such that (a) (I',k') is a
YES instance if and only if (I,k) is; (b) |I'|and k'
Kernelization
• Theorem [Niedermaier]: Every fixed-parameter
tractable problem has a g(k)-kernel.
• Proof: Suppose that there exists a FPT
algorithm with running time f(k) nc, for some
function f and some constant c. Consider an
instance (I,k) with |I|=n.
• If n>f(k), we run the decision algorithm in time
f(k) nc < nc+1. If it returns YES (NO), the
kernelization algorithm outputs a constant size
YES (resp. NO) instance.
• If n≤f(k), the the kernelization algorithm
returns (I,k).

Kernelization
• The last theorem implies that every problem
that is FPT has a kernel.
• However, the goal is to obtain kernels that are
"small", that is, polynomial in k, or even constant.

FPT: much more…
• Some problems are not FPT (e.g., graph coloring).
• Complexity classes: W[1] -> Can a nondeterministic Turing machine accept an unary
string s in at most k steps?
• Independent Set is W[1]-hard.
• Reductions to W[1]-hard problems give new
W[1]-hard problems.
• Lower bounds for FPT tractability
• Upper and lower bounds for the size of the
kernels

FPT: much more…
• Theorem [Robertson and Seymour]: Every graph
problem with parameter k whose YES istances
are closed under taking minors can be solved in
O(f(k) n3)


Slide 43

Tecniche Algoritmiche per Grafi e Reti
Fabrizio Frati

Dipartimento di Informatica e Automazione
Università degli Studi Roma Tre

• 3 CREDITI
• I° periodo:
• Lunedì 9:45-11:15 aula N13

• II° periodo:
• Venerdì 8:00-9:45 aula N7

• Contatti:
• {angelini,gdb,frati,ratm} @dia.uniroma3.it
• Ricevimento: mercoledì dalle 17 alle 19

• Struttura del Corso
• ~ 8 seminari
• algoritmi, strutture dati, combinatorica,
graph drawing…

• progetti a gruppi di 2 - 4 persone
• problema di ricerca

• Materiale Didattico
• slides
• G. Di Battista, P. Eades, R. Tamassia, I. G.
Tollis, Graph Drawing: Algorithms for the
Visualization of Graphs, 1999. Prentice Hall.

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
C. Computer System Organization
1.
2.
3.
4.
5.

Processor Architectures
Computer-Communication Networks
Application-Based Systems
Performance of Systems
Computer System Implementations

ACM Computing Classification System
C. Computer System Organization
2. Computer-Communication Networks
2.1 Network Architectures
2.2 Network Protocols
2.3 Network Operations
2.4 Distributed Systems
2.5 LAN & WAN
2.6 Internetworking

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
E. Data
1.
2.
3.
4.
5.

Data Structures
Data Storage Representations
Data Encryption
Coding and Information Theory
Files

ACM Computing Classification System
E. Data
1. Data Structures
1.1 Arrays
1.2 Distributed Data Structures
1.3 Graphs and Networks
1.4 Lists, Stacks, and Queues
1.5 Records
1.6 Tables
1.7 Trees

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
F. Theory of Computation
1.
2.
3.
4.

Computation by Abstract Devices
Analysis of Algorithms and Problem Complexity
Logics and Meanings of Programs
Mathematical Logic and Formal Languages

ACM Computing Classification System
F. Theory of Computation
1. Computation by Abstract Devices
1.1 Models of Computation
1.2 Complexity Measures and Completeness
1.2.1 Complexity Hierarchies
1.2.2 Machine-Independent Complexity
1.2.3 Reducibility and Completeness
1.2.4 Relations among Complexity Classes

ACM Computing Classification System
F. Theory of Computation
2. Analysis of Algorithms and Problem Complexity
2.1 Numerical Algorithms
2.2 Non-numerical Algorithms and Problems
2.2.1 Complexity of Proof Procedures
2.2.2 Computations on Discrete Structures
2.2.3 Geometrical Problems
2.2.4 Pattern Matching
2.2.5 Routing and Layout
2.2.6 Sequencing and Scheduling
2.2.7 Sorting and Searching

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
G. Mathematics of Computing
1.
2.
3.
4.

Numerical Analysis
Discrete Mathematics
Probability and Statistics
Mathematical Software

ACM Computing Classification System
G. Mathematics of Computing
2. Discrete Mathematics
2.1 Combinatorics

2.1.1 Combinatorial Algorithms
2.1.2 Counting Problems
2.1.3 Generating Functions
2.1.4 Permutations and Combinations
2.1.5 Recurrences and Difference Equations

2.2 Graph Theory
2.2.1 Graph Algorithms
2.2.2 Graph Labeling

2.2.5 Path and Circuit Problems
2.2.6 Trees

2.3 Applications

a world FULL of NP-hard problems
Problem: I want to travel among a set of
cities driving the fewest possible number
of KMs. IT’S DIFFICULT!!

Problem: I want to put a set of objects
into some bags, knowing that each bag
can not afford more than 10 KGs and
trying to use as few bags as possible.
IT’S DIFFICULT!!

How to Deal with NP-hard problems?
• Exact Algorithms
• Randomized Algorithms
• Approximation Algorithms
• Fixed-Parameter Tractable Algorithms
• …

Approximation Algorithms

Approximation Algorithms
• We want a solution “close” to the
optimal one.
• Given a minimization problem Π, an
algorithm is an α-approximation for Π if,
for every instance I of Π, it outputs a
solution SOL(I) such that
SOL(I)/OPT(I) ≤ α

Vertex Cover
• Problem: Given a graph G(V,E), find a
minimum vertex cover, that is, a set V’  V
such that every edge e  E has an
endvertex in V’.

NP-hard 
[Karp]

How to Guarantee an Approximation?
• We want an approximation algorithm
for Vertex Cover.
• The cost of the solution produced by the
algorithm should be compared with the
cost of an optimal solution.

• But computing the cost of an optimal
solution is NP-HARD!!
LOWER BOUNDS!

Lower Bound for Vertex Cover
• Given a graph G(V,E), a matching M is
a set of edges M  E such that no two
edges share an endvertex.
• A matching is maximal if no matching M’
exists such that M  M’.

• The size of a matching
is a lower bound on the
size of an optimal
solution to Vertex
Cover!

An Approximation Algorithm
for Vertex Cover

• Algorithm: Find a maximal matching M
and output the set S of matched vertices

An Approximation Algorithm
for Vertex Cover
• Theorem: The previous algorithm is a
2-approximation algorithm for Vertex Cover
• Proof:
• S is a vertex cover, otherwhise the
matching would not be maximal.
• OPT≥M, where M is the size of the output
maximal matching.
• SOL=2M, as the number of matched
vertices is twice the size of the matching.

Approximation Algorithms:much more…
• Approximation schemes: (1+ε)-approx.
• Inapproximability results.
• Complexity classes, e.g., APX.

Fixed-Parameter Tractable Algorithms

Easy or Hard?
Problem (optimization): Let G be a graph.
Which is the minimum number of vertices
whose deletion makes G planar?

NP-hard 
[Lewis-Yannakakis ]

Easy or Hard?
Problem (decision): Let G be a graph and k
be an integer. Is there a set of k vertices
whose deletion makes G planar?
Polynomial 
• Easy O(nk+1) time algorithm for solving the problem:
• Consider every set of k vertices. Remove such
vertices. Test the planarity of the resulting graph.

• There are O(nk) such sets. Testing the planarity of
an n-vertex graph takes O(n) time. Then,
T(n,k)= O(nk) O(n) = O(nk+1)

Easy or Hard?
Where is the trick?
In the decision version, k is a constant
parameter part of the input
An O(nk+1)-time algorithm, with k constant, is a
polynomial-time algorithm.

But it is very slow 

Fixed-Parameter Tractability
A problem is fixed-parameter tractable
if it can be solved in f(k) nO(1) time,
where k is a parameter of the problem,
f is an arbitrary function, and nO(1) is a
polynomial (not depending on k).

FPT algorithm for Vertex Cover
Theorem [Melhorn]: There is an O(2k n)time algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• There is a vertex cover with k=0 if and only if G
has no edge.
• Consider any edge e=(u,v). Either u or v belongs
to any vertex cover S.
• Consider both the case in which u S and the
case in which v S.

FPT algorithm for Vertex Cover
u

u

v

v

• u  S -> S is a vertex cover of G if and only if
S-{u} is a vertex cover of G-{u} -> solve the
instance (G-{u}, k-1)
• v  S -> S is a vertex cover of G if and only if
S-{v} is a vertex cover of G-{v} -> solve the
instance (G-{v}, k-1)

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• T(n,0) = O(n)
• T(n,k) = 2 T(n-1, k-1) +O(n) ≤ 2 T(n, k-1) +O(n) ≤
2 (2 T(n, k-2) +O(n)) +O(n) ≤
2 (2 (2 T(n, k-3) +O(n)) +O(n)) +O(n) ≤
2 (2 (2 (…(2 T(n, 0)+O(n)) + … +O(n))
+O(n)) +O(n) ≤
2k O(n) + (2k-1 + 2k-2 + 2k-3 + ... + 1) O(n) =
2k O(n) + (2k - 1) O(n) = O(2k n)

Reduction Rules
Reduction rule : a rule (that is, a polynomial time
algorithm) that transforms an instance (I,k) to
an "equivalent and simpler” instance (I', k’).

Equivalent: (I,k) is a YES instance if and only if
(I', k') is a YES instance.
Simpler: |I'|<|I| or k'occurrences of a particular substructure.

Another FPT algorithm for Vertex Cover
Theorem: There is an O(1.6181k n2)-time
algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• We apply the following two reduction rules:
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k).
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u,N(u)},k-1).

Another FPT algorithm for Vertex Cover
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k). Correctness: if S is a vertex
cover of G and u is in S, then S-{u} is also a
vertex cover of G, as u has no incident edge.
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u, N(u)},k-1). Correctness: if S is a
vertex cover of G and u is in S, then
S-{u}  N(u) is also a vertex cover of G, as u
has no other incident edge.

Another FPT algorithm for Vertex Cover
• If neither of the two rules can be applied,
then every vertex has degree at least 2.
• Pick a vertex u. Any vertex cover of G
contains either u or N(u). Thus, (G,k) is a YES
instance if and only if (G-{u},k-1) or
(G-N(u),k-|N(u)|) is.

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• Since |N(u)|\geq 2,
• T(n,k) ≤ T(n,k-1)+ T(n,k-2)+O(n^2).
• Fibonacci series: every number is the sum of
the previous two xk =xk-1 +xk-2 +c.

• The k-th number of the Fibonacci series
tends to the golden ratio to the power of k.
• T(n,k)=Φk O(n2)=((1+√5)/2)k O(n2) =
O(1.6181k n2).

Kernelization
• Sometimes the reduction rules work till the size
of the problem is reduced really a lot. That is,
after the reduction rules have been applied,
the problem has size g(k), for some function k.
In this case the problem has a g(k)-kernel.

• Kernel: given a problem and an instance (I,k), a
kernel is an algorithm that outputs in polynomial
time an instance (I',k') such that (a) (I',k') is a
YES instance if and only if (I,k) is; (b) |I'|and k'
Kernelization
• Theorem [Niedermaier]: Every fixed-parameter
tractable problem has a g(k)-kernel.
• Proof: Suppose that there exists a FPT
algorithm with running time f(k) nc, for some
function f and some constant c. Consider an
instance (I,k) with |I|=n.
• If n>f(k), we run the decision algorithm in time
f(k) nc < nc+1. If it returns YES (NO), the
kernelization algorithm outputs a constant size
YES (resp. NO) instance.
• If n≤f(k), the the kernelization algorithm
returns (I,k).

Kernelization
• The last theorem implies that every problem
that is FPT has a kernel.
• However, the goal is to obtain kernels that are
"small", that is, polynomial in k, or even constant.

FPT: much more…
• Some problems are not FPT (e.g., graph coloring).
• Complexity classes: W[1] -> Can a nondeterministic Turing machine accept an unary
string s in at most k steps?
• Independent Set is W[1]-hard.
• Reductions to W[1]-hard problems give new
W[1]-hard problems.
• Lower bounds for FPT tractability
• Upper and lower bounds for the size of the
kernels

FPT: much more…
• Theorem [Robertson and Seymour]: Every graph
problem with parameter k whose YES istances
are closed under taking minors can be solved in
O(f(k) n3)


Slide 44

Tecniche Algoritmiche per Grafi e Reti
Fabrizio Frati

Dipartimento di Informatica e Automazione
Università degli Studi Roma Tre

• 3 CREDITI
• I° periodo:
• Lunedì 9:45-11:15 aula N13

• II° periodo:
• Venerdì 8:00-9:45 aula N7

• Contatti:
• {angelini,gdb,frati,ratm} @dia.uniroma3.it
• Ricevimento: mercoledì dalle 17 alle 19

• Struttura del Corso
• ~ 8 seminari
• algoritmi, strutture dati, combinatorica,
graph drawing…

• progetti a gruppi di 2 - 4 persone
• problema di ricerca

• Materiale Didattico
• slides
• G. Di Battista, P. Eades, R. Tamassia, I. G.
Tollis, Graph Drawing: Algorithms for the
Visualization of Graphs, 1999. Prentice Hall.

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
C. Computer System Organization
1.
2.
3.
4.
5.

Processor Architectures
Computer-Communication Networks
Application-Based Systems
Performance of Systems
Computer System Implementations

ACM Computing Classification System
C. Computer System Organization
2. Computer-Communication Networks
2.1 Network Architectures
2.2 Network Protocols
2.3 Network Operations
2.4 Distributed Systems
2.5 LAN & WAN
2.6 Internetworking

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
E. Data
1.
2.
3.
4.
5.

Data Structures
Data Storage Representations
Data Encryption
Coding and Information Theory
Files

ACM Computing Classification System
E. Data
1. Data Structures
1.1 Arrays
1.2 Distributed Data Structures
1.3 Graphs and Networks
1.4 Lists, Stacks, and Queues
1.5 Records
1.6 Tables
1.7 Trees

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
F. Theory of Computation
1.
2.
3.
4.

Computation by Abstract Devices
Analysis of Algorithms and Problem Complexity
Logics and Meanings of Programs
Mathematical Logic and Formal Languages

ACM Computing Classification System
F. Theory of Computation
1. Computation by Abstract Devices
1.1 Models of Computation
1.2 Complexity Measures and Completeness
1.2.1 Complexity Hierarchies
1.2.2 Machine-Independent Complexity
1.2.3 Reducibility and Completeness
1.2.4 Relations among Complexity Classes

ACM Computing Classification System
F. Theory of Computation
2. Analysis of Algorithms and Problem Complexity
2.1 Numerical Algorithms
2.2 Non-numerical Algorithms and Problems
2.2.1 Complexity of Proof Procedures
2.2.2 Computations on Discrete Structures
2.2.3 Geometrical Problems
2.2.4 Pattern Matching
2.2.5 Routing and Layout
2.2.6 Sequencing and Scheduling
2.2.7 Sorting and Searching

ACM Computing Classification System
A.
B.
C.
D.
E.
F.
G.
H.
I.
J.

General Literature
Hardware
Computer System Organization
Software
Data
Theory of Computation
Mathematics of Computing
Information Systems
Computing Methodologies
Computer Applications

ACM Computing Classification System
G. Mathematics of Computing
1.
2.
3.
4.

Numerical Analysis
Discrete Mathematics
Probability and Statistics
Mathematical Software

ACM Computing Classification System
G. Mathematics of Computing
2. Discrete Mathematics
2.1 Combinatorics

2.1.1 Combinatorial Algorithms
2.1.2 Counting Problems
2.1.3 Generating Functions
2.1.4 Permutations and Combinations
2.1.5 Recurrences and Difference Equations

2.2 Graph Theory
2.2.1 Graph Algorithms
2.2.2 Graph Labeling

2.2.5 Path and Circuit Problems
2.2.6 Trees

2.3 Applications

a world FULL of NP-hard problems
Problem: I want to travel among a set of
cities driving the fewest possible number
of KMs. IT’S DIFFICULT!!

Problem: I want to put a set of objects
into some bags, knowing that each bag
can not afford more than 10 KGs and
trying to use as few bags as possible.
IT’S DIFFICULT!!

How to Deal with NP-hard problems?
• Exact Algorithms
• Randomized Algorithms
• Approximation Algorithms
• Fixed-Parameter Tractable Algorithms
• …

Approximation Algorithms

Approximation Algorithms
• We want a solution “close” to the
optimal one.
• Given a minimization problem Π, an
algorithm is an α-approximation for Π if,
for every instance I of Π, it outputs a
solution SOL(I) such that
SOL(I)/OPT(I) ≤ α

Vertex Cover
• Problem: Given a graph G(V,E), find a
minimum vertex cover, that is, a set V’  V
such that every edge e  E has an
endvertex in V’.

NP-hard 
[Karp]

How to Guarantee an Approximation?
• We want an approximation algorithm
for Vertex Cover.
• The cost of the solution produced by the
algorithm should be compared with the
cost of an optimal solution.

• But computing the cost of an optimal
solution is NP-HARD!!
LOWER BOUNDS!

Lower Bound for Vertex Cover
• Given a graph G(V,E), a matching M is
a set of edges M  E such that no two
edges share an endvertex.
• A matching is maximal if no matching M’
exists such that M  M’.

• The size of a matching
is a lower bound on the
size of an optimal
solution to Vertex
Cover!

An Approximation Algorithm
for Vertex Cover

• Algorithm: Find a maximal matching M
and output the set S of matched vertices

An Approximation Algorithm
for Vertex Cover
• Theorem: The previous algorithm is a
2-approximation algorithm for Vertex Cover
• Proof:
• S is a vertex cover, otherwhise the
matching would not be maximal.
• OPT≥M, where M is the size of the output
maximal matching.
• SOL=2M, as the number of matched
vertices is twice the size of the matching.

Approximation Algorithms:much more…
• Approximation schemes: (1+ε)-approx.
• Inapproximability results.
• Complexity classes, e.g., APX.

Fixed-Parameter Tractable Algorithms

Easy or Hard?
Problem (optimization): Let G be a graph.
Which is the minimum number of vertices
whose deletion makes G planar?

NP-hard 
[Lewis-Yannakakis ]

Easy or Hard?
Problem (decision): Let G be a graph and k
be an integer. Is there a set of k vertices
whose deletion makes G planar?
Polynomial 
• Easy O(nk+1) time algorithm for solving the problem:
• Consider every set of k vertices. Remove such
vertices. Test the planarity of the resulting graph.

• There are O(nk) such sets. Testing the planarity of
an n-vertex graph takes O(n) time. Then,
T(n,k)= O(nk) O(n) = O(nk+1)

Easy or Hard?
Where is the trick?
In the decision version, k is a constant
parameter part of the input
An O(nk+1)-time algorithm, with k constant, is a
polynomial-time algorithm.

But it is very slow 

Fixed-Parameter Tractability
A problem is fixed-parameter tractable
if it can be solved in f(k) nO(1) time,
where k is a parameter of the problem,
f is an arbitrary function, and nO(1) is a
polynomial (not depending on k).

FPT algorithm for Vertex Cover
Theorem [Melhorn]: There is an O(2k n)time algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• There is a vertex cover with k=0 if and only if G
has no edge.
• Consider any edge e=(u,v). Either u or v belongs
to any vertex cover S.
• Consider both the case in which u S and the
case in which v S.

FPT algorithm for Vertex Cover
u

u

v

v

• u  S -> S is a vertex cover of G if and only if
S-{u} is a vertex cover of G-{u} -> solve the
instance (G-{u}, k-1)
• v  S -> S is a vertex cover of G if and only if
S-{v} is a vertex cover of G-{v} -> solve the
instance (G-{v}, k-1)

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• T(n,0) = O(n)
• T(n,k) = 2 T(n-1, k-1) +O(n) ≤ 2 T(n, k-1) +O(n) ≤
2 (2 T(n, k-2) +O(n)) +O(n) ≤
2 (2 (2 T(n, k-3) +O(n)) +O(n)) +O(n) ≤
2 (2 (2 (…(2 T(n, 0)+O(n)) + … +O(n))
+O(n)) +O(n) ≤
2k O(n) + (2k-1 + 2k-2 + 2k-3 + ... + 1) O(n) =
2k O(n) + (2k - 1) O(n) = O(2k n)

Reduction Rules
Reduction rule : a rule (that is, a polynomial time
algorithm) that transforms an instance (I,k) to
an "equivalent and simpler” instance (I', k’).

Equivalent: (I,k) is a YES instance if and only if
(I', k') is a YES instance.
Simpler: |I'|<|I| or k'occurrences of a particular substructure.

Another FPT algorithm for Vertex Cover
Theorem: There is an O(1.6181k n2)-time
algorithm for Vertex Cover.
Proof: Consider an instance (G,k).
• We apply the following two reduction rules:
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k).
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u,N(u)},k-1).

Another FPT algorithm for Vertex Cover
• If G has a vertex u of degree 0, then let
(G',k')=(G-{u},k). Correctness: if S is a vertex
cover of G and u is in S, then S-{u} is also a
vertex cover of G, as u has no incident edge.
• If G has a vertex u of degree 1, then let N(u)
denote the set of neighbors of u (here
|N(u)|=1). Add N(u) to S and let
(G',k')=(G-{u, N(u)},k-1). Correctness: if S is a
vertex cover of G and u is in S, then
S-{u}  N(u) is also a vertex cover of G, as u
has no other incident edge.

Another FPT algorithm for Vertex Cover
• If neither of the two rules can be applied,
then every vertex has degree at least 2.
• Pick a vertex u. Any vertex cover of G
contains either u or N(u). Thus, (G,k) is a YES
instance if and only if (G-{u},k-1) or
(G-N(u),k-|N(u)|) is.

FPT algorithm for Vertex Cover
• Time complexity T(n,k):

• Since |N(u)|\geq 2,
• T(n,k) ≤ T(n,k-1)+ T(n,k-2)+O(n^2).
• Fibonacci series: every number is the sum of
the previous two xk =xk-1 +xk-2 +c.

• The k-th number of the Fibonacci series
tends to the golden ratio to the power of k.
• T(n,k)=Φk O(n2)=((1+√5)/2)k O(n2) =
O(1.6181k n2).

Kernelization
• Sometimes the reduction rules work till the size
of the problem is reduced really a lot. That is,
after the reduction rules have been applied,
the problem has size g(k), for some function k.
In this case the problem has a g(k)-kernel.

• Kernel: given a problem and an instance (I,k), a
kernel is an algorithm that outputs in polynomial
time an instance (I',k') such that (a) (I',k') is a
YES instance if and only if (I,k) is; (b) |I'|and k'
Kernelization
• Theorem [Niedermaier]: Every fixed-parameter
tractable problem has a g(k)-kernel.
• Proof: Suppose that there exists a FPT
algorithm with running time f(k) nc, for some
function f and some constant c. Consider an
instance (I,k) with |I|=n.
• If n>f(k), we run the decision algorithm in time
f(k) nc < nc+1. If it returns YES (NO), the
kernelization algorithm outputs a constant size
YES (resp. NO) instance.
• If n≤f(k), the the kernelization algorithm
returns (I,k).

Kernelization
• The last theorem implies that every problem
that is FPT has a kernel.
• However, the goal is to obtain kernels that are
"small", that is, polynomial in k, or even constant.

FPT: much more…
• Some problems are not FPT (e.g., graph coloring).
• Complexity classes: W[1] -> Can a nondeterministic Turing machine accept an unary
string s in at most k steps?
• Independent Set is W[1]-hard.
• Reductions to W[1]-hard problems give new
W[1]-hard problems.
• Lower bounds for FPT tractability
• Upper and lower bounds for the size of the
kernels

FPT: much more…
• Theorem [Robertson and Seymour]: Every graph
problem with parameter k whose YES istances
are closed under taking minors can be solved in
O(f(k) n3)