liveBook · Manning

Shortest path

As explained in Advanced Algorithms and Data Structures

A shortest path is a path between graph vertices having minimum total edge distance or cost.

A shortest path connects two graph vertices with the least total distance or cost. In delivery routing, it identifies an efficient route from a warehouse to a customer while modeling intersections as vertices and streets as edges. section 14.0 section 14.3.1

A practical treatment develops the problem incrementally:

  • Start with a regular city grid, where counting blocks approximates route length. section 14.3.1
  • Represent intersections as vertices and one-way streets as directed edges; model two-way streets with paired edges. section 14.3.1
  • Use breadth-first search when each traversed edge has equal cost, then reconstruct the route from the recorded distances and predecessors. section 14.3.6
  • Recognize that weighted or differently optimized routes may require algorithms such as Dijkstra’s or A* rather than simple block counting. section 14.0 section 14.3.1

Delivery across a city grid

On a regular street grid, the shortest route between two intersections corresponds to minimum Manhattan distance: the sum of the absolute coordinate differences. Removing one connecting street can force BFS to select a completely different route. section 14.3.6

Figure 14.15 The shortest path to destination, and shortest distances to all the vertices, computed using BFS on the graph in figure 14.10. The shortest path is shown with dashed arrows, while distances are shown next to each vertex.

Use the diagram to inspect BFS-computed distances for every vertex and trace the selected path to the destination. section 14.3.6

How Advanced Algorithms and Data Structures covers it

How deep it goes
Develops graph modeling, grid simplification, BFS distances, and path reconstruction, while deferring detailed weighted-route algorithms.
Examples
Uses delivery maps, regular city grids, directed street graphs, BFS distance labels, and an edge-removal exercise.
What it assumes
Assumes basic familiarity with trees, then establishes graph properties and representations before solving routing problems.
What you can do after
Apply BFS to compute shortest distances and reconstruct a route in an equal-cost grid graph.
How it connects
Connects shortest paths with graphs, breadth-first search, Manhattan distance, Dijkstra’s algorithm, A*, and the traveling salesman problem.

Also explained in

Compare how 6 books explain shortest path →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Advanced Algorithms and Data Structures. The section links point to the parts of the book it draws on.