I have tried to implement the BFS algorithm with an adjasency table which is implemented with an array of vectors. I start storing input from 1 and not from 0.
EDIT: I have updated the code: http://ideone.com/GZwPP and now it compiles and runs but when I try to search for a node which is not in the graph I get this error:
terminate called after throwing an instance of 'std::out_of_range'
what(): vector::_M_range_check
Aborted
out_of_range
exception? Do you have the call stack? Did you try to debug that? – Eitan T