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
The function getPath() in src/algorithms/shortestPath/getPath.ts adds up the weights. However, the requirement for weight computation can be driven by usecase.
For example
in a relationship usecase, the further we out in the graph, the lower the significace of the weight is.
In a usecase we are defining the graph, the resulting weight is a multiple of the weights rather than sum of weights.
We can improve the function in 2 ways:
Take an input that says if the weights must be added, multipled ...
Pass in a function that takes in 2 values (weight of the edge, computed weight so far undefined if this is the first edge ) and returns a new computed weight.