in1 and in2 are two vertices of graph which are actually indexes in pset [ ]
int graph :: bfs ( int in1 , int in2 ) { int visited [ V ] ; memset ( visited , 0 , sizeof ( visited ) ) ; queue < int > que ; visited [ in1 ] = 1 ; que . push ( in1 ) ; list < int > :: iterator i ; while ( ! que . empty ( ) ) { int p = que . front ( ) ; que . pop ( ) ; for ( i = l [ p ] . begin ( ) ; i != l [ p ] . end ( ) ; i ++ ) { if ( ! visited [ * i ] ) { visited [ * i ] = visited [ p ] + 1 ; que . push ( * i ) ; } if ( * i == in2 ) { return visited [ * i ] - 1 ; } } } }