return len(spectrum)
laplacian1 = nx.spectrum.laplacian_spectrum(graph1)
laplacian2 = nx.spectrum.laplacian_spectrum(graph2)
k1 = select_k(laplacian1)
k2 = select_k(laplacian2)
k = min(k1, k2)
similarity = sum((laplacian1[:k] - laplacian2[:k]) ** 2)
Python-реализация алгоритма оценки сходства графов