in1 and in2 are two vertices of graph which are actually indexes in pset [ ]
def bfs ( self , in1 , in2 ) : NEW_LINE INDENT visited = [ 0 ] * self . V NEW_LINE que = queue . Queue ( ) NEW_LINE visited [ in1 ] = 1 NEW_LINE que . put ( in1 ) NEW_LINE while ( not que . empty ( ) ) : NEW_LINE INDENT p = que . queue [ 0 ] NEW_LINE que . get ( ) NEW_LINE i = 0 NEW_LINE while i < len ( self . l [ p ] ) : NEW_LINE INDENT if ( not visited [ self . l [ p ] [ i ] ] ) : NEW_LINE INDENT visited [ self . l [ p ] [ i ] ] = visited [ p ] + 1 NEW_LINE que . put ( self . l [ p ] [ i ] ) NEW_LINE DEDENT if ( self . l [ p ] [ i ] == in2 ) : NEW_LINE INDENT return visited [ self . l [ p ] [ i ] ] - 1 NEW_LINE DEDENT i += 1 NEW_LINE DEDENT DEDENT DEDENT