Relax all edges | V | - 1 times .
for i in range ( 1 , V ) : NEW_LINE INDENT for j in range ( E ) : NEW_LINE INDENT u = graph . edge [ j ] . src ; NEW_LINE v = graph . edge [ j ] . dest ; NEW_LINE weight = graph . edge [ j ] . weight ; NEW_LINE if ( dist [ u ] != 1000000 and dist [ u ] + weight < dist [ v ] ) : NEW_LINE INDENT dist [ v ] = dist [ u ] + weight ; NEW_LINE parent [ v ] = u ; NEW_LINE DEDENT DEDENT DEDENT