Bad memory usage in DSA/algorithms/CPlusPlus/Graphs/dijkstra.cpp
Denisthatorf opened this issue · comments
The Dijkstra algorithm uses vector<vector<pair<int,int>>> graph(V+1,vector<pair<int,int>>()) as a matrix. This is very, very bad for memory, because the vector in the vector in memory is not stored linearly, and can be scattered in memory very much. As an alternative, I propose to use a regular array (data = new T [rows * columns]) allocated on the heap and get its elements like this : *(_data + row * _rows + column).
Thanks for opening your first issue here! Be sure to follow the issue template!
Hi @Denisthatorf,
Could you help me to this bug?
Yes, sure