This can be solved in polynomial time for any graph, as it can be converted to a MinCut problem. Just connect all red vertices into a single vertex $s$, and all blue vertices into another single vertex $t$, obtaining a multigraph (or if you prefer, a graph with edge weights). The Minimum cut in this new graph between $s$ and $t$ gives the partition that gives the coloring maximizing the number of the monochromatic edges.
domotorp
- 19.1k
- 3
- 59
- 128