liveBook · Manning

Shortest path

As explained in Modern C

A shortest path is a path between two graph nodes whose total distance is minimal among the available paths.

A shortest path connects two graph nodes with the least total distance among available routes. Represent direct distances in a distance matrix D. section 6.1.5

Represent the problem as follows:

  • Store the distance from point i to point j in D[i][j]. section 6.1.5
  • Represent the absence of a direct arc with a very large value such as SIZE_MAX. section 6.1.5
  • Given nodes x and y, find the shortest path between them using the distance information. section 6.1.5

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 Modern C. The section links point to the parts of the book it draws on.