Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does shortest path work in pgrouting?

I'm trying to find how the implementation of shortest_path() in pgRouting works.

This is the function definition:

CREATE OR REPLACE FUNCTION shortest_path(sql text, source_id integer,target_id integer, directed boolean, has_reverse_cost boolean)  
RETURNS SETOF path_result AS '$libdir/librouting', 'shortest_path'  
  LANGUAGE c IMMUTABLE STRICT  
  COST 1  
  ROWS 1000;  
ALTER FUNCTION shortest_path(text, integer, integer, boolean, boolean) OWNER TO postgres;

My questions are:

  1. How does it calls the .c file and how it passes the parameters to it (I believe it's dijkstra.c file, correct?)
  2. How can I take that .c file and compile it with the debug info it has in order to see how it works so I can understand it better?
like image 335
john Avatar asked Feb 28 '26 11:02

john


1 Answers

Here is the source for dijkstra.c. You can read this code to see what the function is doing. The SQL you posted just shows the binding to the native C function.

like image 58
cope360 Avatar answered Mar 07 '26 10:03

cope360