In Singapore, this year's (2016) NOI (National Olympiad in Informatics) included the following problem "ROCKCLIMBING" (I was unable to solve it during the contest.) :
Abridged Problem Statement
Given a DAG with N <= 500 vertices, find the maximum number of vertices in a subset of the original vertices such that there is no path from 1 vertex in the set to another vertex in the same set, directly or indirectly.
Solution
The solution was to use transitive closure algorithm, and then to form a bipartite graph by duplicating each vertex i to form i' such that if vertex j can be reached from vertex i directly or indirectly in the original graph, then there is a directed edge from i to j' in the new graph.
However, during the solution presentation, the presenters did not explain how or why N - MCBM (MCBM being the Maximum Cardinality Bipartite Matching) of the new bipartite graph is also the maximum size of the set of vertices that cannot reach each other directly or indirectly in the original DAG.
I looked up other problems related to DAGs and bipartite graphs, such as the Minimum Path Cover problem on DAGs, but I could not find anything that explains this.
Does anyone know a way in which to prove this equality?
The problem statement can be found here: ROCKCLIMBING
Thank you in advance.
There are two things going on here:
A set is independent if and only if its complement is a vertex cover (see wikipedia). This means that the size of a max independent set is equal to the size of a minimum vertex cover.
Konig's theorem proves that
In any bipartite graph, the number of edges in a maximum matching equals the number of vertices in a minimum vertex cover.
Therefore to find the size of the max independent set we first compute the size MCBM of the max matching, and then compute its complement which equals N-MCBM.
An alternative viewpoint is as follows:
If we use A<B to mean we can climb from A to B, we have defined a partially ordered set
There is a result called Dilworth's theorem that says the maximum number of incomparable elements is equal to the minimum number of chains
The proof shows how to construct the minimum number of chains by constructing a maximum matching in your bipartite graph.
Related
I have a complete graph with n vertex. The MinimumVertexCover of the complete graph is n-1.Can I take less then n-1 as a MinimumVertexCover? If the answer is No please Explain it with the proof?
The answer is No.
I think the easiest way to prove it is by Gallai’s result. Recall that an independent set of vertices is one in which two vertices share an edge. Now Gallai’s theorem says that:
α(G)+β(G)=n
where,
α(G)=
size of largest independent set,
β(G)=size of minimum vertex cover, and
n=
number of vertices in G.
Now clearly α(Kn)=1
since a set of two vertices in Kn is not independent. It follows therefore that β(G)=n−1, as required.
Given a DAG (possibly not strongly connected e.i consisting of several connected components), the goal is to find the minimum number of starting vertices required to visit to fully explore the graph.
One method I thought of was to generate all permutations of the given vertices and run a topological sort in that order. The one with the minimum backtracks would be the answer.
Is there an efficient algorithm to perform the above task?
This a famous problem called minimum path cover, it's a pity that wiki says nothing about it, you can search it in google.
As methioned, the minimum path cover problem is NP-hard in normal graph. But in DAG, it can be solved with Matching.
Method:
Dividing each vertex u into two different vertex u1 and u2. For every edge (u->v) in orginal graph, adding edge (u1->v2) in new graph. Then do any matching algorithm you like. The result is n - maximum matching, n is total number of vertex in orginal graph.
I just started reading graph theory and was reading about graph coloring. This problem popped in my mind:
We have to color our undirected graph(not completely) with only 1 color so that number of colored nodes are maximized. We need to find this maximum number. I was able to formulate an approach for non cyclic graphs :
My approach : First we divide graph into isolated components and do this for each component. We make a dfs tree and make 2 dp arrays while traversing it so that root comes last :
dp[0][u]=sum(dp[1][visited children])
dp[1][u]=sum(dp[0][visited children])
ans=max(dp[1][root],dp[0][root])
dp[0][i] , dp[1][i] are initialized to 0,1 respectively.
Here 0 signifies uncolored and 1 signifies colored.
But this does not work for cyclic graphs as I have assumed that no visited children are connected.
Can someone guide me in the right direction on how to solve this problem for cyclic graphs(not by brute force)? Is it possible to modify my approach or do we need to come up with a different approach? Would a greedy approach like coloring a nodes with least edges work?
This problem is NP-Hard as well, and is known as maximum independent set problem.
A set S<=V is said to be Independent Set in a graph if for each two vertices u,v in S, there is no edge (u,v).
The maximum size of S (which is the number you are seeking) is called the independence number of the graph, and unfortunately finding it is NP-Hard.
So, unless P=NP, your algorithm fails for general purposes graphs.
Proving it is fairly simple, given a graph G=(V,E), create the complementary graph G'=(V,E') where (u,v) is in E' if and only if (u,v) is NOT in E.
Now, given a graph G, there is a clique of size k if and only if there is an independent set of size k in G', using the same vertices (since if (u,v) are two vertices the independent set, there is no edge (u,v) in E', and by definition there is an edge in E. Repeat for all vertices in the independent set, and you got a clique in G).
Since clique problem is NP-Hard, this makes this one such as well.
I was trying to solve the maximum independent set problem on bipartite graphs using the greedy method. So came across this post which does exactly what i was trying to do. But am concentrating only on the bipartite graphs. The counter case in the answer is not a bipartite graph. Are there any bipartite graphs that this one wont work?
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
Why is greedy algorithm not finding maximum independent set of a graph?
The same approach as in the original question answer applies here as well, with a slightly modified graph:
Start by removing #5, What's left is a paw graph (nodes (1,3,4,7)). Remove its leaves in any order. You discover a four-node independent set: (1,3,5,7)
Start by removing #6. What's left is a 4-cycle. Removing any node forces either of these sets:
(1,3,6)
(2,4,6)
both are three-element maximal (as in, cannot be expanded) independent sets, and thus not maximum (as in, the largest possible).
I am trying to find the maximal set for an undirected graph and here is the algorithm that i am using to do so:
1) Select the node with minimum number of edges
2) Eliminate all it's neighbors
3) From the rest of the nodes, select the node with minimum number of edges
4) Repeat the steps until the whole graph is covered
Can someone tell me if this is right? If not, then why is this method wrong to calculate the maximal independent set in a graph?
What you have described will pick a maximal independent set. We can see this as follows:
This produces an independent set. By contradiction, suppose that it didn't. Then there would have to be two nodes connected by edges that were added into the set you produced. Take whichever one of them was picked first (call it u, let the other be v) Then when it was added to the set, you would have removed all of its neighboring nodes from the set, including node v. Then v wouldn't have been added to the set, giving a contradiction.
This produces a maximal independent set. By contradiction, suppose that it didn't. This means that there is some node v that can be added to the independent set produced by your algorithm, but was not added. Since this node wasn't added, it must have been removed from the graph by the algorithm. This means that it must have been adjacent to some node added to the set already. But this is impossible, because it would mean that the node v cannot be added to the produced independent set without making the result not an independent set. We have a contradiction.
Hope this helps!
There is not one definite maximal independent set in any graph; take for example the cycle over 3 nodes, each of the nodes forms a maximal independent set. Your algorithm will give you one of the maximal independent sets of the graph, without guaranteeing that it has maximum cardinality.On the other hand, finding the maximum independent set in a graph is NP-complete (since that problem is complementary to that of finding a maximum clique), so there probably isn't an efficient algorithm.
After your clarify situation in comments, your solutions is right.
Even better, according to Corollary 3 from this paper http://courses.engr.illinois.edu/cs598csc/sp2011/Lectures/lecture_7.pdf
your get good aproximation for subset order.
Greedy gives a 1 / (d + 1) -approximation for (unweighted) MIS in graphs of degree at most d