Approximation Algorithms
Approximation Algorithms
• Example:
– Optimisation problem - Given graph G with
integer weights on its edges. What is the weight
of a minimum spanning tree (MST) in G?
• Not in P (NP):
– Vertex Cover
– Traveling salesman
My T. Thai
7
[email protected]
Vertex-Cover is in NP
• Computational Complexity:
• The number of possible routes grows exponentially with the number
of cities, making finding the absolute shortest route impractical for
even moderately sized problems.
• Practicality:
• In real-world scenarios, finding a route that is within a certain
percentage of the optimal solution can be much faster and more
useful than attempting to find the absolute shortest route.
Approximation Algorithms
• An algorithm that returns near-optimal solutions in
polynomial time
My T. Thai
14
[email protected]
Approximation Schemes
• Let c(S) be the value of a solution S delivered by an
algorithm A to an optimisation problem P and OPT
will be the optimal solution for P
• We say that A is a -approximation algorithm for a
minimisation problem P if
– c(S) ·OPT
• And A is is a -approximation algorithm for a
maximisation problem P if
– c(S) ·OPT
My T. Thai
17
[email protected]
PTAS (Polynomial Time Approximation
Scheme):
• Approximation Guarantee:
• A PTAS guarantees a solution that is within a factor
of 1 + ε of the optimal solution. For example, if ε =
0.1, the solution will be within 110% of the optimal
solution.
• Polynomial Time:
• The runtime of a PTAS is polynomial in the input size
(n) for any fixed ε. This means the time complexity
can be expressed as something like O(n^k) for some
constant k, where n is the input size.
PTAS (Polynomial Time Approximation
Scheme):
• Parameterization:
• A PTAS takes an additional parameter ε, which
controls the accuracy of the approximation. A
smaller ε results in a more accurate solution,
but the runtime may increase.
Fully Polynomial-Time Approximation
Scheme (FPTAS)
• FPTAS is an algorithm that finds approximate
solutions to optimization problems, especially
those that are NP-hard. It guarantees a
solution within a factor of (1 + ε) of the
optimal solution, where ε is a small positive
value. The key characteristic of an FPTAS is
that its running time is polynomial in both the
size of the input and 1/ε.
FPTAS
• Approximation Guarantee:
• FPTAS algorithms provide solutions that are
close to the optimal solution, with the
closeness controlled by the parameter ε.
• Polynomial Running Time:
• The time complexity of an FPTAS is bounded by
a polynomial function of the input size (n) and
1/ε, making it efficient for large problems.
• Dynamic Programming:
• Many FPTAS algorithms are based on dynamic programming, which
allows them to find optimal solutions in a structured manner, even if
the time complexity is not always polynomial.
• NP-hard problems:
• FPTAS algorithms are particularly useful for NP-hard problems, where
finding exact solutions is computationally expensive.
• Time complexity:
• The time complexity of an FPTAS is generally expressed as O(poly(n,
1/ε)), where poly(n, 1/ε) represents a polynomial function of the input
size (n) and the inverse of the desired precision (1/ε).
Relationship of PTAS to FPTAS:
• An Example
My T. Thai
25
[email protected]
Vertex Cover Problem
• Definition:
– Given an undirected graph G=(V,E), find a vertex
cover with minimum size (has the least number of
vertices)
– This is sometimes called cardinality vertex cover
My T. Thai
26
[email protected]
How to solve it
• Matching:
– A set M of edges in a graph G is called a matching
of G if no two edges in set M have an endpoint in
common
• Example:
My T. Thai
27
[email protected]
How to solve it (cont)
• Maximum Matching:
– A matching of G with the greatest number of edges
• Maximal Matching:
– A matching which is not contained in any larger matching
• Note: Any maximum matching is certainly maximal,
but not the reverse.
My T. Thai
28
[email protected]
Main Observation
• No vertex can cover two edges of a matching
• The size of every vertex cover is at least the size of every
matching: |M| ≤ |C|
• |M| = |C| indicates the optimality
My T. Thai
30
[email protected]
My T. Thai
31
[email protected]
32
My T. Thai
33
[email protected]
Traveling-salesman Problem
My T. Thai
36
[email protected]
My T. Thai
37
[email protected]
38
• Intuitively, Approx-TSP first makes a full walk
of MST T, which visits each edge exactly two
times.
• To create a Hamiltonian cycle from the full
walk, it bypasses some vertices (which
corresponds to making a shortcut)
My T. Thai
39
[email protected]
TSP starting point
• What would be a good baseline?
• Something we can calculate that would at
least connect things up for us.
• A Minimum Spanning Tree!
A 3
4
5 5
B 6 D
4 3 3
4
C E
2
From MST to Tour
A 3
• How do we get from start to every vertex 4
and back? 5 5
B 6 D
• Make the starting point the root, do a
4 3 3
traversal (DFS) of the graph! 4
C E
• Why not BFS? Because the “next vertex” 2
isn’t always right next to you! (not a If is
problem in this example, but very bad if Go f
To D
you have a very tall tree)
Back
• The biggest problem is vertices of odd degree. The last time we enter that
vertex, the only way out is an already used edge.
• And that’s definitely not taking us somewhere new!
4 3 3
4
C E
2
A
What would help? 4
5 5
3
Did It Help?
B D
• So…now every vertex has even degree…but
there’s not a nice order anymore.
• We’ll have to find one. C E
• Christofides' algorithm
– Find a minimum spanning tree T
– Let O be the set of nodes with odd degree in T
– Find a minimum-cost perfect matching M on O
– Add the set of edges of M to T
– Find an Eulerian tour.
– Shortcut the Eulerian tour.
Graph Coloring Problem
• Approximation algorithms for graph
coloring aim to find a coloring of a graph with
a number of colors close to the chromatic
number, which is the minimum number of
colors needed to color the graph. These
algorithms are useful because finding the
exact chromatic number is NP-hard.
• Yes, the graph coloring algorithm is NP-
complete for k greater than 3, meaning it's a
problem where finding a solution is
computationally difficult, and verifying a
solution is easy.
• Specifically, determining if a graph can be
colored with k colors is NP-complete k greater
than 3, while the problem is easily solvable for
k=2
Greedy Algorithm:
– Concept:
– Assign colors to vertices one by one, ensuring that
no adjacent vertices have the same color.
– Process:
• Start with an arbitrary ordering of vertices.
• For each vertex, try to assign the smallest possible color
that isn't used by any of its neighbors.
– Performance:
• While simple and fast, the greedy algorithm doesn't
guarantee a coloring close to the optimal chromatic
number.
Maximal Independent Set
• Independent Set: A set of vertices in a graph
where no two vertices are connected by an
edge.
• Maximal Independent Set: An independent
set that cannot be made larger by adding any
additional vertices.
• Maximum Independent Set: An independent
set of the largest possible size in the graph.
Chromatic Number
• Consider a k-chromatic graph G of n vertices
properly colored with k different colors. Since
the largest number of vertices in G with the
same color cannot exceed the independence
number β(G) >= n/k.
• β(G) – largest set size
• Find minimal number of the maximal
independent sets which collectively include all
vertices of G.
Independent Sets for this graph