A graph theoretical approach to the shunting problem.