Graph path finding algorithms #48
-
Hi there, I have the following questions on path finding algorithms context-
question -
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
For 1, you just have to invert your relationships, and then the destination becomes the starting node. Then you can use the usual algorithms. 2 is more complicated. Basically, the algorithm can give you the path, and you need to use your host language to chop the path into path segments, and query the database again to find out the types. Then you can add this information back to the path you extracted. So two trips to the database are required. If you are worried about data inconsistency due to some other processes mutating the database while you run your queries, you can use multi-statement transaction. |
Beta Was this translation helpful? Give feedback.
For 1, you just have to invert your relationships, and then the destination becomes the starting node. Then you can use the usual algorithms.
2 is more complicated. Basically, the algorithm can give you the path, and you need to use your host language to chop the path into path segments, and query the database again to find out the types. Then you can add this information back to the path you extracted. So two trips to the database are required. If you are worried about data inconsistency due to some other processes mutating the database while you run your queries, you can use multi-statement transaction.