def faster_could_be_isomorphic(G1, G2):
 if (G1.order() != G2.order()):
  return False
 d1 = sorted((d for (n, d) in G1.degree()))
 d2 = sorted((d for (n, d) in G2.degree()))
 if (d1 != d2):
  return False
 return True

def faster_could_be_isomorphic ( G1 , G2 ) : if ( G1 . order ( ) != G2 . order ( ) ) : return False d1 = sorted ( ( d for ( n , d ) in G1 . degree ( ) ) ) d2 = sorted ( ( d for ( n , d ) in G2 . degree ( ) ) ) if ( d1 != d2 ) : return False return True
returns false if graphs are definitely not isomorphic .