Since graph nodes represent indexes of numbers in pset [ ] , we find indexes of num1 and num2 .
in1 , in2 = None , None NEW_LINE for j in range ( len ( pset ) ) : NEW_LINE INDENT if ( pset [ j ] == num1 ) : NEW_LINE INDENT in1 = j NEW_LINE DEDENT DEDENT for j in range ( len ( pset ) ) : NEW_LINE INDENT if ( pset [ j ] == num2 ) : NEW_LINE INDENT in2 = j NEW_LINE DEDENT DEDENT return g . bfs ( in1 , in2 ) NEW_LINE