datavis-tech / graph-data-structure

A graph data structure with topological sort and shortest path algorithms.
MIT License
249 stars 46 forks source link

shortestPath does not return the total weight over all edges in the path #25

Closed skeletorkun closed 4 years ago

skeletorkun commented 4 years ago

https://www.npmjs.com/package/graph-data-structure#shortest-path

example :

        let shortestPath = graph.shortestPath(departure, arrival);
        console.log("shortest path " + JSON.stringify(shortestPath));

Expected behavior:

The returned array also contains a weight property, which is the total weight over all edges in the path

Actual behavior: shortest path ["Hoth","Endor"]

skeletorkun commented 4 years ago

Nevermind. it does actually.

let shortestPath = graph.shortestPath(departure, arrival);
console.log("shortest path total weight " + shortestPath.weight);
curran commented 4 years ago

Thanks for reporting your experience!