def is_valid_joint_degree(joint_degrees):
 degree_count = {}
 for k in joint_degrees:
  if (k > 0):
   k_size = (sum(joint_degrees[k].values()) / k)
   if (not k_size.is_integer()):
    return False
   degree_count[k] = k_size
 for k in joint_degrees:
  for l in joint_degrees[k]:
   if (not float(joint_degrees[k][l]).is_integer()):
    return False
   if ((k != l) and (joint_degrees[k][l] > (degree_count[k] * degree_count[l]))):
    return False
   elif (k == l):
    if (joint_degrees[k][k] > (degree_count[k] * (degree_count[k] - 1))):
     return False
    if ((joint_degrees[k][k] % 2) != 0):
     return False
 return True

def is_valid_joint_degree ( joint_degrees ) : degree_count = { } for k in joint_degrees : if ( k > 0 ) : k_size = ( sum ( joint_degrees [ k ] . values ( ) ) / k ) if ( not k_size . is_integer ( ) ) : return False degree_count [ k ] = k_size for k in joint_degrees : for l in joint_degrees [ k ] : if ( not float ( joint_degrees [ k ] [ l ] ) . is_integer ( ) ) : return False if ( ( k != l ) and ( joint_degrees [ k ] [ l ] > ( degree_count [ k ] * degree_count [ l ] ) ) ) : return False elif ( k == l ) : if ( joint_degrees [ k ] [ k ] > ( degree_count [ k ] * ( degree_count [ k ] - 1 ) ) ) : return False if ( ( joint_degrees [ k ] [ k ] % 2 ) != 0 ) : return False return True
checks whether the given joint degree dictionary is realizable as a simple graph .