You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Given the result of a single-source algorithm like Dijkstra or Bellman–Ford, provide a function which can extract the path from a given source to a given destination. Ideally, we should define a new object type for a shortest path tree that has the method to do so on it:
The above should print two things: The weight of the path from A to B (which is literally shortestPathTree["B"].distance) as well as the path, which should be an array of nodes, in the correct order.
Alternatively, if we want to maintain the current data type returned by dijkstra for backwards compatibility, we could introduce a new function for path extraction:
The rationale for the above is that it is often the case that the application has to extract the shortest path between a source and a destination. While it is not a lot of work to traverse the predecessor pointers, it ends up being repetitive and we would rather avoid duplication by incorporating it in the library.
@pkakelas perhaps you can solve this by migrating our "getOptimalPath" code into a graphlib PR.
The text was updated successfully, but these errors were encountered:
Given the result of a single-source algorithm like Dijkstra or Bellman–Ford, provide a function which can extract the path from a given source to a given destination. Ideally, we should define a new object type for a shortest path tree that has the method to do so on it:
The above should print two things: The weight of the path from A to B (which is literally
shortestPathTree["B"].distance
) as well as the path, which should be an array of nodes, in the correct order.Alternatively, if we want to maintain the current data type returned by
dijkstra
for backwards compatibility, we could introduce a new function for path extraction:The rationale for the above is that it is often the case that the application has to extract the shortest path between a source and a destination. While it is not a lot of work to traverse the
predecessor
pointers, it ends up being repetitive and we would rather avoid duplication by incorporating it in the library.@pkakelas perhaps you can solve this by migrating our "getOptimalPath" code into a graphlib PR.
The text was updated successfully, but these errors were encountered: