def shortest_path_length(creation_sequence, i):
 first = creation_sequence[0]
 if isinstance(first, str):
  if isinstance(creation_sequence, list):
   cs = creation_sequence[:]
  else:
   cs = list(creation_sequence)
 elif isinstance(first, tuple):
  cs = [v[1] for v in creation_sequence]
  i = [v[0] for v in creation_sequence].index(i)
 elif isinstance(first, int):
  cs = uncompact(creation_sequence)
 else:
  raise TypeError('Not a valid creation sequence type')
 N = len(cs)
 spl = ([2] * N)
 spl[i] = 0
 for j in range((i + 1), N):
  if (cs[j] == 'd'):
   spl[j] = 1
 if (cs[i] == 'd'):
  for j in range(i):
   spl[j] = 1
 for j in range((N - 1), 0, (-1)):
  if (cs[j] == 'd'):
   break
  spl[j] = (-1)
 return spl

def shortest_path_length ( creation_sequence , i ) : first = creation_sequence [ 0 ] if isinstance ( first , str ) : if isinstance ( creation_sequence , list ) : cs = creation_sequence [ : ] else : cs = list ( creation_sequence ) elif isinstance ( first , tuple ) : cs = [ v [ 1 ] for v in creation_sequence ] i = [ v [ 0 ] for v in creation_sequence ] . index ( i ) elif isinstance ( first , int ) : cs = uncompact ( creation_sequence ) else : raise TypeError ( 'Not a valid creation sequence type' ) N = len ( cs ) spl = ( [ 2 ] * N ) spl [ i ] = 0 for j in range ( ( i + 1 ) , N ) : if ( cs [ j ] == 'd' ) : spl [ j ] = 1 if ( cs [ i ] == 'd' ) : for j in range ( i ) : spl [ j ] = 1 for j in range ( ( N - 1 ) , 0 , ( - 1 ) ) : if ( cs [ j ] == 'd' ) : break spl [ j ] = ( - 1 ) return spl
return the shortest path length from indicated node to every other node for the threshold graph with the given creation sequence .