CSRT-NTUA / AlgoPlus

AlgoPlus is a C++17 library for complex data structures and algorithms
https://csrt-ntua.github.io/AlgoPlus
Apache License 2.0
141 stars 20 forks source link

Corrected and optimized DFS function and optimized BFS #36

Closed Shu-AFK closed 5 months ago

Shu-AFK commented 5 months ago
spirosmaggioros commented 5 months ago

you are correct about the bfs, i was probably tired and missed it when i was writting it. I don't agree with the unordered_set instead of unordered_map. It's the same thing and there's no need to change it right now, cause i have unordered_maps everywhere in they graph header, and it'll consume a lot of time to just change those things.So let me just fix the bfs myself and we'll see about the unordered_map later. I don't really think it's faster, it is just a matter of implementation.Both are equally fast.

Shu-AFK commented 5 months ago

The change is minor but switching to unordered_sets reduces memory usage, due to the bools not getting used anyways but it doesn't really make a big difference if the graph is not massive

spirosmaggioros commented 5 months ago

there is not enough documentation to check about the memory, but it makes sense that hashmaps have one more operator [] for their values. Let me worry about that, i'll change them to unordered_sets when i have the chance in this commit, i'll close it for now and re-open it when i'll make the change.Thanks for the comments.