improve get_neighbors performance - #302
Conversation
|
Marking this PR as stale. It will not be automatically closed. Even though the maintainers of Graaf may not always have time to take a look in a timely fashion, your contributions are much appreciated. |
|
Marking this PR as stale. It will not be automatically closed. Even though the maintainers of Graaf may not always have time to take a look in a timely fashion, your contributions are much appreciated. |
bobluppes
left a comment
There was a problem hiding this comment.
Thanks for this — great catch, and a very reasonable optimization! Verified locally: builds cleanly against current main, all 752 existing tests pass (including the dedicated GetNeighbors coverage for both directed and undirected graphs), and clang-format clean. The reference-lifetime tradeoff (the returned reference is tied to the graph's internal state until that vertex is removed) matches the existing pattern already used by get_vertex()/get_edge() in this class, so this is consistent with the rest of the API. Merging, thanks again for contributing!
I use graaf a lot and change get_neighbors my executable run time drop from 700s to 60s. Hope you could accept it. Thanks!