I define an unordered_map
like this:
std::unordered_map edges;
Is there a efficient way to choose a rando
This is how you can get random element from a map:
std::unordered_map edges;
iterator item = edges.begin();
int random_index = rand() % edges.size();
std::advance(item, random_index);
Or take a look at this answer, which provides the following solution:
std::unordered_map edges;
iterator item = edges.begin();
std::advance( item, random_0_to_n(edges.size()) );