.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/eigenvalue_concentration.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_examples_eigenvalue_concentration.py: Concentration of the eigenvalues. ================================ The eigenvalues of the graph Laplacian concentrates to the same value as the graph becomes full. .. GENERATED FROM PYTHON SOURCE LINES 8-41 .. image-sg:: /examples/images/sphx_glr_eigenvalue_concentration_001.png :alt: Ring(n_vertices=17, n_edges=17, k=1), Ring(n_vertices=17, n_edges=34, k=2), Ring(n_vertices=17, n_edges=85, k=5), Ring(n_vertices=17, n_edges=136, k=8), k=1, k=2, k=5, k=8 :srcset: /examples/images/sphx_glr_eigenvalue_concentration_001.png :class: sphx-glr-single-img .. code-block:: Python import numpy as np from matplotlib import pyplot as plt import pygsp2 as pg n_neighbors = [1, 2, 5, 8] fig, axes = plt.subplots(3, len(n_neighbors), figsize=(15, 8)) for k, ax in zip(n_neighbors, axes.T): graph = pg.graphs.Ring(17, k=k) graph.compute_fourier_basis() graph.plot(graph.U[:, 1], ax=ax[0]) ax[0].axis('equal') ax[1].spy(graph.W) ax[2].plot(graph.e, '.') ax[2].set_title('k={}'.format(k)) #graph.set_coordinates('line1D') #graph.plot(graph.U[:, :4], ax=ax[3], title='') # Check that the DFT matrix is an eigenbasis of the Laplacian. U = np.fft.fft(np.identity(graph.n_vertices)) LambdaM = (graph.L.todense().dot(U)) / (U + 1e-15) # Eigenvalues should be real. assert np.all(np.abs(np.imag(LambdaM)) < 1e-10) LambdaM = np.real(LambdaM) # Check that the eigenvectors are really eigenvectors of the laplacian. Lambda = np.mean(LambdaM, axis=0) assert np.all(np.abs(LambdaM - Lambda) < 1e-10) fig.tight_layout() plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.698 seconds) **Estimated memory usage:** 182 MB .. _sphx_glr_download_examples_eigenvalue_concentration.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: eigenvalue_concentration.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: eigenvalue_concentration.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: eigenvalue_concentration.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_