Блог пользователя kingofnumbers

Автор kingofnumbers, 9 лет назад, По-английски

I want help to explain the behavior of this code

this code reads an undirected graph then store list of the edges in list vector, then in the adj vector I store adjacency list of the graph where I actually store pointers to the edges from list vector

but as you can see there's some random big numbers appear in the output but I don't know how, maybe I am making some undefined behavior some where? , any help would be appreciated.

  • Проголосовать: нравится
  • +5
  • Проголосовать: не нравится

»
9 лет назад, # |
  Проголосовать: нравится +20 Проголосовать: не нравится

After some push_back operations (for example, when size is a power of 2) the whole vector moves to another place in memory and you keep addresses to wrong old locations of the elements.