bitwalker / libgraph

A graph data structure library for Elixir projects
MIT License
524 stars 75 forks source link

Edge weight integer #14

Closed Roconda closed 6 years ago

Roconda commented 6 years ago

Hi,

I want to do path finding between multiple vertexes. I'm adding edges but my current weight values are decimal. The library returns the following message:

(ArgumentError) invalid value for :weight, must be an integer

I understand that integers are faster and don't have rounding errors. What is the reason that weights must be an integer?

ps: thanks for the lib :-)

nlevnaut commented 6 years ago

I'm not sure why this is, but you could use an integer representation of your decimal to get around it. If your decimal weight is 1.05 you could use 105 as the weight, or 1050 if you want another decimal place of precision, etc.

georgewhewell commented 6 years ago

I made the following modifications and it seems to work: https://github.com/georgewhewell/libgraph/commit/548f3142511af36d2214df847bbc4c6624e59a7c

ymmv

Roconda commented 6 years ago

Thanks a lot @georgewhewell 😄

Might be worth creating a pull request.

bitwalker commented 6 years ago

Addressed in #19