Here is the problem (Rooks) asks that
Given a chessboard NxN, on which the rooks are placed. You have to color those rooks in a minimal number of colors in that way – no horizontal and vertical line contains two rooks of the same color.
What type of solution can you offer ?
Thanks
Form a bipartite graph with rows as one set and the columns as other.
The rooks would correspond to the edges of the bipartite graph: row r and column c are joined by and edge if there is a rook at position (r,c).
Now you are looking for an edge colouring of this bipartite graph.
It can be shown that (I believe first by Konig) that the minimum number of colours required is same as the max degree and polynomial time algorithms are known (inspite of the general problem being NP-Complete). Thus in your case, the minimum number of colours required will be the maximum numbers of rooks in a row or column.
In fact, the edge colouring corresponds to the vertex colouring of the line graph of a bipartite graph, which is known to be a perfect graph and thus the minimum number of colours is the max degree. Polynomial time algorithms to colour perfect graphs are also known, but that would be overkill for this problem.
An algorithm (and references to earlier algorithms) for edge colouring bipartite graphs appears here: http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.144.3399&rep=rep1&type=pdf