7

I don't believe there exists an algorithm for finding the maximum independent vertex set in a bipartite graph other than the brute force method of finding the maximum among all possible independent sets.

I am wondering about the pseudocode to find all possible vertex sets.

Say given a bipartite graph with 4 blue vertices and 4 red. Currently I would

Start with an arbitrary blue,
  find all red that don't match this blue
  put all these red in Independent Set
  find all blue that dont match these red
  put these blue in Independent Set
  Repeat for next vertex in blue

Repeat all over again for all blue then all vertices in red.

I understand that this way doesn't give me all possible Independent Set combinations at all, since after the first step I am choosing all of the next colour vertices that dont match rather than stepping through every possiblity.

For example given a graph with the matching

B  R
1  1
1  3 
2  1
2  3
3  1
3  3
4  2
4  4

Start with blue 1
  Choose red 2 and 4 since they dont match
  Add 2, 4 to independent Set
  Choose 2 and 3 from blue since they dont with 2 or 4 from red
  Add 2 and 3 from blue to independent set as well.
Independent Set = 1,2,3 from blue 2,4 from red
Repeat for blue 2, blue 3, ... red n (storing the cardinality for each set)

Is there a way I can improve this algorithm to better search for all possibilities. I know that a |Maximum Set for a bipartite graph| = |Red| + |Blue| - |Maximum Matching|.

The problem arises with the possibility that by choosing all possible red in the first go for a given blue, if those red connect to all other possible blue then my set only ever has all 1 blue and rest red.

Eric
  • 95,302
  • 53
  • 242
  • 374
user1084113
  • 932
  • 3
  • 15
  • 31
  • How big is the graph? Number of nodes and numbers of edges? It might be possible to feed the complement of the graph in a standard maximum clique algorithm. – Aaron McDaid Dec 21 '11 at 17:23

2 Answers2

10

I don't believe there exists an algorithm for finding the maximum independent vertex set in a bipartite graph other than the brute force method of finding the maximum among all possible independent sets.

There is: finding the maximum independent set is equivalent to finding the minimum vertex cover (by taking complement of the result), and Konig's theorem states that minimum vertex cover in bipartite graphs is equivalent to maximum matching, and that that can be found in polynomial time. I don't know about finding all matchings, but it seems there can be exponentially many.

sdcvvc
  • 25,343
  • 4
  • 66
  • 102
  • I can't see the connection between vertex covers and independent sets. The complement of a vertex cover is not an independent set, I think. – Aaron McDaid Dec 21 '11 at 17:26
  • Vertex cover: for all edges (u,v), either u in C or v in C. Independent set: for all edges (u,v), either u is not in I or v is not in I. The conditions are equivalent if you take I to be complement of C. – sdcvvc Dec 21 '11 at 17:28
  • The article on [Konig's theorem](http://en.wikipedia.org/wiki/K%C3%B6nig%27s_theorem_%28graph_theory%29) shows a contradictory example. On the top right you can see an edges between two of the reds node. This demonstrates a (minimum) vertex cover which is not independent. – Aaron McDaid Dec 21 '11 at 17:29
  • Vertex cover: for all edges (u,v): either u in C, or v in C, *or both u and v are in C*. – Aaron McDaid Dec 21 '11 at 17:30
  • (Thanks for mentioning vertex covers. I'm never heard of them before. So even if I am right, it's still good to hear new ideas!) – Aaron McDaid Dec 21 '11 at 17:31
  • "or" means by default inclusive or (|| operator), and you've got the same thing with independent set (either u is not in I, or v is not in I, or both u and v are not in I). Perhaps you should try to understand what is going on. There is nothing contradictory in vertex cover not being an independent set, it's complement of vertex cover which is independent. – sdcvvc Dec 21 '11 at 17:35
  • Doh! I see now. I was thinking "the vertex cover in the complement graph" (i.e. flipping the edges). You're right. (And now I can't upvote your answer unless you edit it!) – Aaron McDaid Dec 21 '11 at 17:40
  • What do u mean by the complement of the result. – user1084113 Dec 21 '11 at 20:12
  • If your graph has vertices {A,B,C,D} and the vertex cover turns out to be {A,B} then the independent set is {C,D}. – sdcvvc Dec 21 '11 at 20:16
  • Sorry but could u clarify with this example, I can not see it working here. Given the bipartite graph blue (1-5) red (A-E) 1B,1C; 2A,2B,2C,2D; 3A,3B,3C,3D; 4B,4C; AND 5C,5E. How do I find the vertex cover? What is the complement? – user1084113 Dec 21 '11 at 20:24
  • 1
    1. Find maximum matching (e.g. Hopcroft-Karp) 2. use the algorithm given in Wikipedia on Konig theorem to get vertex cover 3. output vertices that are NOT in the cover to get independent set – sdcvvc Dec 21 '11 at 20:41
  • Is there anyway to find the maximum vertex set without doing a maximum matching. – user1084113 Dec 21 '11 at 22:00
  • It's *minimum* vertex cover and *maximum* matching. I don't know, but it seems no, since the problems are equivalent by the theorem. Anyway maximum matching is not that hard. – sdcvvc Dec 21 '11 at 22:03
  • Srry I meant maximum independent vertex set not minimum vertex cover. Also why would u say its not hard, is there somewhere i can find pseudocode for it the only way I see is using another brute force search method. – user1084113 Dec 21 '11 at 22:47
  • search for maximum matching in bipartite graphs – sdcvvc Dec 21 '11 at 23:09
  • To summarize (from Wikipedia). A *maximum* independent set is the complement of a *minimum* vertex cover, which is (closely connected to) a *maximum* matching. Correct? (Edited: I forgot to say 'complement') – Aaron McDaid Dec 22 '11 at 03:41
1

As Aaron McDaid mentions in his now deleted answer, the problem of find a maximum independent set is equivalent to finding a maximum clique. The equivalence is that finding a maximum independent set in a graph G is the same as finding a maximum clique in the complement of G. The problem is known to be NP-complete.

The brute force solution you mention takes O(n^2 2^n), but you can do better than this. Robson has a paper entitled ""Algorithms for maximum independent sets" from 1986 that gives an algorithm that takes O(2^{c*n}) for a constant 0<c<1 (I believe c is around 1/4, but I could be mistaken). None of this is specific to a bipartite graph.

One thing to note if you have a bipartite graph is that either side forms an independent set. In the complete bipartite graph K_{b,r} which is partitioned B x R with |B|=b and |R|=r where there is an edge from every vertex in B to every vertex in R and none within B nor none within R, a maximum independent set is B if b>=r, otherwise it's R.

Taking B or R won't work in general. sdcvvc noted the example with vertices {1,2,3,A,B,C} and edges {A,1}, {A,2}, {A,3}, {B,3}, {C,3}. In this case, the maximal independent set is {1,2,B,C}, which is larger than either partition {A,B,C} or {1,2,3}.

It may improve Robson's algorithm to start with the larger of B or R and proceed from there, though I'm not sure how much of a difference this will make.

Alternatively, you can use the Hopcroft–Karp algorithm on the bipartite complement of a graph to find a maximum matching, and then take the vertices used in the matching as the independent set. This gives a polynomial time algorithm to solve the problem.

PengOne
  • 48,188
  • 17
  • 130
  • 149
  • I don't think the last paragraph is correct without Konig's theorem. For example, if the graph is complete bipartite, then its bipartite complement is empty and Hopcroft-Karp algorithm will not find any matching, while the optimum is to take all blue (or red) vertices. – sdcvvc Dec 21 '11 at 21:54
  • PengOne, I deleted my answer because once I understood @sdcvvc's answer, I decided that people should that answer instead instead of mine. As far as I can see it's correct. – Aaron McDaid Dec 22 '11 at 03:48
  • Is there software implementation for Robson algorithm? – simon Dec 18 '15 at 11:50