Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is greedy algorithm not finding maximum independent set of a graph?

Given a graph G, why is following greedy algorithm not guaranteed to find maximum independent set of G:

Greedy(G):
S = {}
While G is not empty:
    Let v be a node with minimum degree in G
    S = union(S, {v})
    remove v and its neighbors from G
return S

I am wondering can someone show me a simple example of a graph where this algorithm fails?

like image 797
Slaven Glumac Avatar asked Dec 17 '12 20:12

Slaven Glumac


People also ask

How do you find the maximum independent set of a graph?

The Maximum Independent Set (MIS) problem in graph theory is the task of finding the largest independent set in a graph, where an independent set is a set of vertices such that no two vertices are adjacent. There is currently no known efficient algorithm to find maximum independent sets.

Why does greedy algorithm fail?

Limitations of Greedy Algorithms. Sometimes greedy algorithms fail to find the globally optimal solution because they do not consider all the data. The choice made by a greedy algorithm may depend on choices it has made so far, but it is not aware of future choices it could make.

Why is maximum independent set NP hard?

The maximum independent set problem is NP-hard. However, it can be solved more efficiently than the O(n2 2n) time that would be given by a naive brute force algorithm that examines every vertex subset and checks whether it is an independent set. As of 2017 it can be solved in time O(1.1996n) using polynomial space.

How do you know if a greedy algorithm is optimal?

One of the simplest methods for showing that a greedy algorithm is correct is to use a “greedy stays ahead” argument. This style of proof works by showing that, according to some measure, the greedy algorithm always is at least as far ahead as the optimal solution during each iteration of the algorithm.


1 Answers

I'm not sure this is the simplest example, but here is one that fails: http://imgur.com/QK3DC

For the first step, you can choose B, C, D, or F since they all have degree 2. Suppose we remove B and its neighbors. That leaves F and D with degree 1 and E with degree 2. During the next two steps, we remove F and D and end up with a set size of 3, which is the maximum.

Instead suppose on the first step we removed C and its neighbors. This leaves us with F, A and E, each with a degree size of 2. We take either one of these next, and the graph is empty and our solution only contains 2 nodes, which as we have seen, isn't the maximum.

like image 129
gms7777 Avatar answered Nov 11 '22 19:11

gms7777