bitwalker / libgraph

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

Support injectable vertex_id implementations #43

Closed zblanco closed 2 years ago

zblanco commented 2 years ago

While using libgraph I found myself building hash maps of some_other_id => vertex to get map lookup performance in contexts where the id was a hash of a value in a struct/vertex rather than the whole vertex contents as Graph.Utils.vertex_id/1 implements. In my case this was to maintain uniqueness of conditionals in a rule engine / match algorithm context where additional meta data in a vertex may vary but uniqueness of the actual conditional expression within was necessary.

Rather than maintain the extra memory space of my own hash maps this PR lets these hash lookups be maintained as a single source of truth within Libgraph.

This PR does the following to address this use case

Please tell me if you have any questions or concerns - I'm not yet 100% sure this is a sane approach so feedback of any kind would be appreciated.

bitwalker commented 2 years ago

Thanks! I've made some modifications and fixed up a few other chores on your branch, but preserved your changes and authorship.