Wilson13 / delivery-trains

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Trains

Solution

This is an undirected weighted graph problem.

My basic idea is to use Dijkstra's algorithm to find the shortest paths.

  1. Find shortest path for each package's start to destination.

  2. Find a train with enough capacity at the start/current station for each package.

    1. If there isn't one, find the closest train with enough capacity.
    2. Move trains to the start stations.
  3. For each train now at the start stations, pick up parcel and follow shortest path towards destination and drop parcel off at the last station.

Note

This is not an optimal solution.

References

Output Screenshot

Output

About


Languages

Language:TypeScript 94.6%Language:JavaScript 5.4%