Skip to content

How to use the least number of colors to color different routes of a bus route such that no two intersecting routes will have the same color?

An answer to this question on the Operations Research Stack Exchange.

Question

I would like to know of a method in which if provided say 10 routes with details regarding which route intersects with which another route, we can use the least number of colors to color the routes, without the intersecting routes having the same color.

For example, say Route 1 intersects with Route 2,3,6,7,9.

Route 2 intersects with Route 1,3,5,7 and so on...

One can use the same color again.

How should one go about assigning colors to each route and also minimize the number of colors used?

Answer

Recognize that each route can be viewed as being a node on a graph. Edges connect nodes if the routes the nodes represent intersect. This is the canonical graph coloring problem for which there are a number of exact and approximate algorithms. Specifically, you're trying to find a constructive algorithm for determining the chromatic number.

For 10 routes and low recalculation volume, I'd suggest building a simple brute-force algorithm as the quickest way of getting an answer.