[GIS] How does pgRouting shortest_path work

pgrouting

I am running the shortest_path function but it will not return rows of lines to follow from source id to target id. Is there a specific way to digitise my dataset? Does pgrouting understand intersections between lines? I digitised my lines one by one connecting snapping them together.

To be a bit more clear, in my db i have a gid for every line, plus a source and target id for that line (plus the other columns). Shouldn't the shortest path function take me from a random source id to a random target id?

I hope my problem is clear but let me know if further explanation is needed 🙂

Thanks in advance.
A

Best Answer

Dijkstra's algorithm shortest path:

"the algorithm finds the path with lowest cost (i.e. the shortest path) between that vertex and every other vertex. It can also be used for finding costs of shortest paths from a single vertex to a single destination vertex by stopping the algorithm once the shortest path to the destination vertex has been determined. For example, if the vertices of the graph represent cities and edge path costs represent driving distances between pairs of cities connected by a direct road, Dijkstra's algorithm can be used to find the shortest route between one city and all other cities"

http://www.pgrouting.org/docs/1.x/dijkstra.html

enter image description here

Based on the Dijkstra's algorithm:

http://en.wikipedia.org/wiki/Dijkstra%27s_algorithm

Related Question