Main Idea: Graph Coloring and DAG Construction
How do we eliminate cycles and guarantee $$$r_1 \ne r_N$$$?
We can translate this problem into Graph Coloring.
1. Guaranteeing a DAG
Assign a positive integer color $$$C[u]$$$ to each resource vertex $$$u$$$.
For every directed edge $$$u \to v$$$, enforce:
Along any directed path
the colors must satisfy:
Therefore, a directed path can never return to a previously visited vertex. Hence the directed graph is a DAG.
This eliminates deadlocks caused by cyclic wait chains.
2. Minimizing the Chain Length
By the Gallai-Roy-Vitaver theorem, for an undirected graph $$$G$$$:
where $$$\chi(G)$$$ is the chromatic number of $$$G$$$.
Therefore, if the graph can be colored using $$$k$$$ colors, we can orient every edge from the vertex with the smaller color to the vertex with the larger color.
The resulting DAG has longest directed path of at most $$$k-1$$$ edges.
Thus, the problem reduces to finding the chromatic number of a graph with at most $$$15$$$ vertices.
problem: https://vjudge.net/problem/UVA-1439
Share better approaches!!




