Hi Luca, I ran the code that you posted, and got the following output: 0 --> 4 1 --> 1 3 4 2 --> 0 1 3 --> 1 2 4 --> 1 2 3 0 --> 4 1 --> 1 3 4 2 --> 0 1 3 --> 1 2 4 --> 1 2 3 distances: 0 2 2 2 1 parent[0] = 0 parent[1] = 4 parent[2] = 4 parent[3] = 4 parent[4] = 0 The above output looks correct to me. It prints the graph G, then a copy of G, then the distances, which look right given the parent structure, which says that the BFS tree for this graph was 0 -> 4 4 -> 1 2 3 Did you expect different output? Or did the program you post not exhibit the problem you are having? Cheers, Jeremy ---------------------------------------------------------------------- Jeremy Siek http://php.indiana.edu/~jsiek/ Ph.D. Student, Indiana Univ. B'ton email: jsiek@osl.iu.edu C++ Booster (http://www.boost.org) office phone: (812) 855-3608 ----------------------------------------------------------------------