datavis-tech / graph-data-structure

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

weight of the node #14

Closed merjana closed 7 years ago

merjana commented 7 years ago

how to add the weight of the node ?

curran commented 7 years ago

What do you mean?

merjana commented 7 years ago

for example if we need to find the shortest path between two nodes implementing Dijkstra's algorithm, we should know the distance of each edge, is there any function to add for example graph.addEdge("a", "b",2); which 2 is the distance between a and b

curran commented 7 years ago

Oh I see what you mean; the weight of an edge (not the weight of a node).

That functionality is not present at the moment, but I don't think it would be very difficult to add.

In terms of implementation, I think it would make sense to add an object called weights that has keys as some encoding of edges (e.g. "a|b" for an edge that goes from A to B) and values as the weights.

Are you working on adding Dijkstra's algorithm? If you have any work in progress to show, I'd be happy to take a look.

curran commented 7 years ago

Released in 1.0, you should be able to use it now.

merjana commented 7 years ago

thank you @curran ,i appreciate that