### mac_n_cheese_pog's blog

By mac_n_cheese_pog, history, 3 years ago,

i read cp algorithm and understand bfs theory.when it comes to implementation i cant. see this code https://pastebin.com/5RtDSMMW this is literally copying yet its still wrong idk whats wrong.pls help

| Write comment?
 » 3 years ago, # |   -18 pls help.im tired of asking someone in discord since theyll just ignore me.i really want to learn bfs and i cant.
•  » » 3 years ago, # ^ |   0
•  » » » 3 years ago, # ^ |   -25 that book is the worst.it left me confused at the implementation like what am i suppose to write in int main? whenever i tried to see the implementation example it just wont print anything.
•  » » » » 3 years ago, # ^ | ← Rev. 2 →   +1 If you can't implement bfs by your own in main function despite having the bfs structure ready, then you have lack of understanding of bfs, that's not the fault of the book
•  » » » » » 3 years ago, # ^ |   -23 what i dont understand is actually the variations.some use vector for storing adj list for bfs and some use vector pair.i was confused since in the article i read it uses vector vector and what i elarn from my teacher is vector pair.this also applies to that book.the standards are different
•  » » » » » » 3 years ago, # ^ |   0 I don't know how the vector of pairs implementation works, but vector of vectors is used because for a vector with index $i$, all the values in that vector are neighbours of $i$. For example if 1,2,3 are stored in vector adj[0], then nodes 1,2,3 are neighbours of node 0. This way after processing node 0, you can push it's neighbours (1,2,3) in the queue for processing.