According to the docs Dgraph’s GraphQL± provides us with a functionality to calculate k-shortest-paths between two nodes and even use the calculation as a variable:
(1) But this variable only contains the information about the first found shortest path, doesn’t it?
(2) I am interested in finding the sum of weights of k-shortest-paths to use it further in my queries:
But i cannot find a way to access weights or even path section from my query. Is there a way to sum weights up in another variable to use it in further queries?
Hi @kostjaigin, Thanks for your questions.
Which variable are you talking of? In your query,
calc will only store the shortest path. But
_path_ will store the other paths and respective weights.
From the docs:
For k-shortest paths (when
numpaths > 1), the result of the shortest path query variable will only return a single path. All k paths are returned in
Do you want to add weights of different paths returned inside
_path_ ? I don’t think that is possible via only a gql± query. You need to parse the JSON struct with
_path_ key and use those weights again in a different query which you want to make