0

Is it possible to search for the shortest path using Dijkstra from Node A to Node B by only passing nodes having a property x with a certain value? Is this also possible by taking a relationship property into account?

If yes, could you explain me how?

Thanks for letting me know something in any case.

Kind regards, Johan,

  • I am curious as to why we have a sudden surge of dijkstra related questions here, I can't explain it. Note that this is just my curiosity that wants to be satisfied OP, your question is a fine one. – arynaq Nov 15 '13 at 21:16
  • @arynaq That's probably because a number of universities have started new semesters and Dijkstra is typical for the beginning of a semester. Anyway how about just adding an if statement when you add the node to your queue and check if it satisfies the condition? – Thijser Nov 15 '13 at 21:34

1 Answers1

1

Nodes that have a given property and the edges that connect them form a subgraph of the original. It's trivial to adapt Dijkstra's algorithm to work on a subgraph: just ignore the vertices and edges that don't belong.

Joni
  • 108,737
  • 14
  • 143
  • 193
  • @downvoter: what am I missing? Is there some subtlety that makes this answer wrong? – Joni Nov 16 '13 at 10:21