We wish to find the maximum independent set in a bipartite graph. My intuition led me to the following algorithm. (Assume that the bipartite graph is connected and has at least 3 vertices, if not run the algorithm on each component)
- Given $G=(L,R,E)$
- Let $S$ be the set of vertices with degree $1$. Note that since graph is connected and has at least $3$ vertices, $v,u\in S\implies (v,u)\not \in E$. (If $S$ is empty, go to step $5$)
- Add the vertices in $S$ to the independent set. $\forall s\in S$, remove $s$ and neighborhood of $s$ from $G$
- If the graph is connected, repeat steps $2-4$. If it is disconnected, repeat the steps $2-4$ for each component.
- if $|L| > |R|$, add $L$ to the independent set, else add $R$
Obviously, the output is some independent set, not necessarily the maximum. However, I could neither prove nor come up with an counter example. Any help will be appreciated.
https://cs.stackexchange.com/a/3033 has a answer which does not rely on intuition