Skip to content

Build path with pgr_dijkstra without shortcuts #2101

Answered by cvvergara
HardRock4Life asked this question in Q&A
Discussion options

You must be logged in to vote

Your pgr_dijkstra is for a directed graph.

This is your query:

pgr_dijkstra(
        'SELECT id, 
				source, 
				target, 
				st_length(geom) as cost, --- There is no reverse_cost so there is no edge from target to source
				geom FROM public."Edges"
		',
        -- source
        nearest_id_v3(clicks."start"),
        -- target
        nearest_id_v3(clicks.stop) -- There is no directed flag set to false (aka undirected)
        ) AS dijk

The graph that is been built by the inner query and the flag visually speaking looks like the image bellow where I added arrows.
As you can not go using the wrong way, it will never give you the expected answer

Because of this instruction: st_length(…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by cvvergara
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #2100 on August 27, 2021 15:16.