3

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?
Igor
  • 33,276
  • 14
  • 79
  • 112
john
  • 31
  • 3
  • Do you want to use pgRouting to calculate shortest paths or are you trying to understand how the code works? – underdark Feb 08 '12 at 19:38
  • I'm trying to understand how the code works and I would like to know how I can compile the .c file in order to take a bigger picture from the code –  Feb 09 '12 at 12:22
  • I really need to know how it works so could someone please help me.. –  Feb 12 '12 at 19:16
  • This question is pretty much off-topic here. It's much more about general programing knowledge. I can migrate it for you. – underdark Feb 12 '12 at 19:44

1 Answers1

1

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.

cope360
  • 6,195
  • 2
  • 20
  • 33
  • 1
    Direct link updated and here's top-level link to the project: https://github.com/pgRouting/pgrouting – cope360 Nov 07 '13 at 15:04