Since graph nodes represent indexes of numbers in pset [ ] , we find indexes of num1 and num2 .
int in1 , in2 ; for ( int j = 0 ; j < pset . size ( ) ; j ++ ) if ( pset [ j ] == num1 ) in1 = j ; for ( int j = 0 ; j < pset . size ( ) ; j ++ ) if ( pset [ j ] == num2 ) in2 = j ; return g . bfs ( in1 , in2 ) ; }