A route planner
The problem
Build a program that plans routes on a map: fewest moves through a maze, cheapest travel cost on a weighted road network, and the cheapest cabling that connects every town.
Requirements
- Use BFS for the fewest moves through a grid maze
- Use Dijkstra for the cheapest cost between towns and report -1 when no route exists
- Use Kruskal and union-find for the cheapest set of cables that connects every town
- Count the groups of connected towns with DFS or union-find
Technologies
- C++17
- queue and priority_queue
- vector of vectors
- Union-find and sorting
Step by step
- Read the maze and run BFS from the start to the exit.
- Read the road network and run Dijkstra from one town.
- Sort the possible cables and add them with union-find to get the cheapest connection.
- Report the connected groups, then test unreachable towns and single-town inputs.
Expected result
A single C++ program with four small commands that prints correct routes, costs and groups on the sample maps and on large random ones.
How it is evaluated
- Routes are correct on the samples and on hand-made edge cases
- Unreachable targets are reported rather than ignored
- Each part has the complexity the lesson gives
- Bounds are checked before any grid or array read
Ways to improve it
- Print the actual route, not only its length
- Add a second cost for each road and find the cheapest route under both
- Compare Dijkstra with Floyd–Warshall on small maps