Find the safest and shortest path to mudik in java