def fast_could_be_isomorphic(G1, G2):
 if (G1.order() != G2.order()):
  return False
 d1 = G1.degree()
 t1 = nx.triangles(G1)
 props1 = [[d, t1[v]] for (v, d) in d1]
 props1.sort()
 d2 = G2.degree()
 t2 = nx.triangles(G2)
 props2 = [[d, t2[v]] for (v, d) in d2]
 props2.sort()
 if (props1 != props2):
  return False
 return True

def fast_could_be_isomorphic ( G1 , G2 ) : if ( G1 . order ( ) != G2 . order ( ) ) : return False d1 = G1 . degree ( ) t1 = nx . triangles ( G1 ) props1 = [ [ d , t1 [ v ] ] for ( v , d ) in d1 ] props1 . sort ( ) d2 = G2 . degree ( ) t2 = nx . triangles ( G2 ) props2 = [ [ d , t2 [ v ] ] for ( v , d ) in d2 ] props2 . sort ( ) if ( props1 != props2 ) : return False return True
returns false if graphs are definitely not isomorphic .