This project combines a technical description and an instructional set to explain and apply route optimization in modern navigation systems.
It first explains how road networks are modeled as weighted graphs and how Dijkstra’s Algorithm computes the shortest path. It then provides a step-by-step, usability-centered guide that allows a user to manually perform the same process.
The goal is to move from understanding → execution.
- Nodes → intersections or endpoints
- Edges → roads connecting nodes
- Weights → travel cost (time, distance, traffic)
The algorithm finds the shortest path from a starting node to all other nodes by:
- Initializing distances (start = 0, others = ∞)
- Selecting the smallest unvisited node
- Updating neighboring nodes (relaxation)
- Repeating until the destination is finalized
- Converts a road layout into a weighted graph
- Preserves spatial relationships and connectivity
- Tracks shortest known distances
- Continuously updates routes as better paths are found
- Produces the lowest-cost path between locations
- Equivalent to navigation system routing behavior
- Traffic conditions
- Road closures / one-way systems
- Continuous recalculation
How to Find the Shortest Path Using Dijkstra’s Algorithm
Manually compute the shortest path between two nodes using a weighted graph.
- Weighted graph
- Distance table (Node | Distance | Previous | Status)
- Method for marking visited nodes
- All edge weights must be non-negative
- Graph and table must be visible simultaneously
- Set starting node distance = 0
- Set all other nodes = ∞
- Leave previous nodes blank
- Mark all nodes as unvisited
Check: Only the start node has a known distance
- Choose the unvisited node with the smallest current distance
For each neighbor:
- Compute:
new distance = current node distance + edge weight - If the new distance is smaller, update:
- Distance
- Previous node
- Mark the current node as finalized
- Do not revisit it
- Return to Step 2
- Continue until the destination node has the smallest distance
- Stop when the destination node is selected as the smallest unvisited node
- Follow previous nodes backward from destination to start
Output:
- Shortest path
- Total travel cost
Shortest path:
A → B → D → E
Total cost:
11
| Issue | Cause | Fix |
|---|---|---|
| Picking wrong node | Choosing smallest edge instead of smallest total distance | Always compare current distances |
| Distances stay ∞ | Initialization error | Ensure start node = 0 |
| Incorrect final path | Previous nodes not updated correctly | Re-check update step |
| Algorithm gives wrong result | Negative edge weights | Use a different algorithm (e.g., Bellman-Ford) |
This project includes:
- Step-by-step algorithm visualization
- Live distance updates
- Practice graph for user application
- HTML — structure and diagrams
- CSS — layout and usability design
- JavaScript — algorithm simulation and interaction
index.html→ Technical descriptioninstructions.html→ Instructional setmain.css→ Styling and layout*.js→ Interactive behavior
This project demonstrates both:
- Conceptual understanding of shortest path algorithms
- Procedural execution through a structured instructional guide
It mirrors how real navigation systems compute and apply optimal routes.