def is_multigraphical(sequence):
 deg_sequence = list(sequence)
 if (not nx.utils.is_list_of_ints(deg_sequence)):
  return False
 (dsum, dmax) = (0, 0)
 for d in deg_sequence:
  if (d < 0):
   return False
  (dsum, dmax) = ((dsum + d), max(dmax, d))
 if ((dsum % 2) or (dsum < (2 * dmax))):
  return False
 return True

def is_multigraphical ( sequence ) : deg_sequence = list ( sequence ) if ( not nx . utils . is_list_of_ints ( deg_sequence ) ) : return False ( dsum , dmax ) = ( 0 , 0 ) for d in deg_sequence : if ( d < 0 ) : return False ( dsum , dmax ) = ( ( dsum + d ) , max ( dmax , d ) ) if ( ( dsum % 2 ) or ( dsum < ( 2 * dmax ) ) ) : return False return True
returns true if some multigraph can realize the sequence .