Skip to content

The weight calculation on the shortest path is not generic enough ... #106

@ravann

Description

@ravann

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

  1. in a relationship usecase, the further we out in the graph, the lower the significace of the weight is.
  2. 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:

  1. Take an input that says if the weights must be added, multipled ...
  2. 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.

Link: https://github.com/datavis-tech/graph-data-structure/blob/master/src/algorithms/shortestPath/getPath.ts

@JesusTheHun what do you think?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions