def betweenness_sequence(creation_sequence, normalized=True):
 cs = creation_sequence
 seq = []
 lastchar = 'd'
 dr = float(cs.count('d'))
 irun = 0
 drun = 0
 dlast = 0.0
 for (i, c) in enumerate(cs):
  if (c == 'd'):
   b = ((dlast + (((irun - 1) * irun) / dr)) + (((2 * irun) * ((i - drun) - irun)) / dr))
   drun += 1
  else:
   if (lastchar == 'd'):
    dlast = b
    dr -= drun
    drun = 0
    irun = 0
   b = 0
   irun += 1
  seq.append(float(b))
  lastchar = c
 if normalized:
  order = len(cs)
  scale = (1.0 / ((order - 1) * (order - 2)))
  seq = [(s * scale) for s in seq]
 return seq

def betweenness_sequence ( creation_sequence , normalized = True ) : cs = creation_sequence seq = [ ] lastchar = 'd' dr = float ( cs . count ( 'd' ) ) irun = 0 drun = 0 dlast = 0.0 for ( i , c ) in enumerate ( cs ) : if ( c == 'd' ) : b = ( ( dlast + ( ( ( irun - 1 ) * irun ) / dr ) ) + ( ( ( 2 * irun ) * ( ( i - drun ) - irun ) ) / dr ) ) drun += 1 else : if ( lastchar == 'd' ) : dlast = b dr -= drun drun = 0 irun = 0 b = 0 irun += 1 seq . append ( float ( b ) ) lastchar = c if normalized : order = len ( cs ) scale = ( 1.0 / ( ( order - 1 ) * ( order - 2 ) ) ) seq = [ ( s * scale ) for s in seq ] return seq
return betweenness for the threshold graph with the given creation sequence .