import%20marimo%0A%0A__generated_with%20%3D%20%220.24.0%22%0Aapp%20%3D%20marimo.App(width%3D%22medium%22)%0A%0A%0A%40app.cell%0Adef%20_()%3A%0A%20%20%20%20import%20marimo%20as%20mo%0A%20%20%20%20import%20numpy%20as%20np%0A%20%20%20%20import%20pandas%20as%20pd%0A%20%20%20%20import%20plotly.graph_objects%20as%20go%0A%20%20%20%20from%20plotly.subplots%20import%20make_subplots%0A%0A%20%20%20%20return%20go%2C%20make_subplots%2C%20mo%2C%20np%2C%20pd%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%20Note%2007%3A%20Spectral%20Decomposition%20and%20Symmetric%20Matrix%20Eigenspaces%0A%0A%20%20%20%20%26larr%3B%20Previous%20Note%3A%20%5B06%20Moore-Penrose%20Pseudoinverse%5D(06_moore_penrose_inverse.py)%20%7C%20Next%20Note%3A%20%5B08%20Matrix%20Calculus%5D(08_matrix_calculus_short.py)%20%26rarr%3B%0A%0A%20%20%20%20---%0A%0A%20%20%20%20%23%23%20%5Ba%5D%20Why%20do%20you%20need%20to%20know%20these%20concepts%3F%0A%0A%20%20%20%20The%20Spectral%20Theorem%20is%20one%20of%20the%20most%20celebrated%20results%20in%20linear%20algebra%20and%20mathematical%20statistics.%20It%20guarantees%20that%20any%20real%20symmetric%20matrix%20can%20be%20factored%20into%20mutually%20perpendicular%20(orthogonal)%20coordinate%20axes%20scaled%20by%20purely%20real%20eigenvalues.%0A%0A%20%20%20%20In%20modern%20data%20science%20and%20AI%2C%20symmetric%20matrices%20appear%20everywhere%3A%0A%20%20%20%201.%20**Empirical%20Covariance%20Matrices**%3A%20In%20Principal%20Component%20Analysis%20(PCA)%2C%20eigendecomposition%20reveals%20the%20principal%20axes%20of%20maximum%20variance%20and%20decorrelates%20features.%0A%20%20%20%202.%20**Graph%20Laplacians%20in%20GNNs**%3A%20In%20Graph%20Neural%20Networks%20and%20spectral%20clustering%2C%20the%20eigenvectors%20of%20the%20Graph%20Laplacian%20define%20the%20graph%20Fourier%20transform%20modes%20(ChebNet%2C%20GCN).%0A%20%20%20%203.%20**Loss%20Function%20Hessians**%3A%20The%20spectrum%20of%20the%20Hessian%20%24%5Cmathbf%7BH%7D%20%3D%20%5Cnabla%5E2%20%5Cmathcal%7BL%7D(%5Cmathbf%7Bw%7D)%24%20governs%20optimization%20dynamics%2C%20gradient%20descent%20convergence%20rates%20(%24%5Ceta%20%3C%202%2F%5Clambda_%7B%5Cmax%7D%24)%2C%20and%20loss%20landscape%20sharpness.%0A%20%20%20%204.%20**Kernel%20Gram%20Matrices**%3A%20In%20Support%20Vector%20Machines%20and%20Gaussian%20Processes%2C%20positive%20semi-definite%20kernel%20matrices%20represent%20inner%20products%20in%20reproducing%20kernel%20Hilbert%20spaces%20(Mercer's%20Theorem).%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20---%0A%0A%20%20%20%20%23%23%20%5Bb%5D%20Concept%20explanation%20with%20their%20role%20in%20ML%2FAI%2FStats%3F%0A%0A%20%20%20%20%23%23%23%20The%20Spectral%20Theorem%20for%20Real%20Symmetric%20Matrices%0A%0A%20%20%20%20Let%20%24%5Cmathbf%7BS%7D%20%5Cin%20%5Cmathbb%7BR%7D%5E%7Bn%20%5Ctimes%20n%7D%24%20be%20a%20real%20symmetric%20matrix%2C%20meaning%20%24%5Cmathbf%7BS%7D%20%3D%20%5Cmathbf%7BS%7D%5ET%24.%20The%20Spectral%20Theorem%20establishes%20three%20fundamental%20properties%3A%0A%20%20%20%201.%20All%20%24n%24%20eigenvalues%20%24%5Clambda_1%2C%20%5Clambda_2%2C%20%5Cdots%2C%20%5Clambda_n%24%20are%20real%20numbers%20(%24%5Clambda_i%20%5Cin%20%5Cmathbb%7BR%7D%24).%0A%20%20%20%202.%20Eigenvectors%20corresponding%20to%20distinct%20eigenvalues%20are%20mutually%20orthogonal.%0A%20%20%20%203.%20There%20exists%20an%20orthonormal%20basis%20of%20%24%5Cmathbb%7BR%7D%5En%24%20composed%20entirely%20of%20eigenvectors%20of%20%24%5Cmathbf%7BS%7D%24.%0A%0A%20%20%20%20Therefore%2C%20%24%5Cmathbf%7BS%7D%24%20can%20be%20diagonalized%20by%20an%20orthogonal%20matrix%20%24%5Cmathbf%7BQ%7D%20%5Cin%20%5Cmathbb%7BR%7D%5E%7Bn%20%5Ctimes%20n%7D%24%20(%24%5Cmathbf%7BQ%7D%5ET%20%5Cmathbf%7BQ%7D%20%3D%20%5Cmathbf%7BI%7D%24)%3A%0A%0A%20%20%20%20%24%24%0A%20%20%20%20%5Cmathbf%7BS%7D%20%3D%20%5Cmathbf%7BQ%7D%20%5Cmathbf%7B%5CLambda%7D%20%5Cmathbf%7BQ%7D%5ET%0A%20%20%20%20%24%24%0A%0A%20%20%20%20where%20%24%5Cmathbf%7B%5CLambda%7D%20%3D%20%5Ctext%7Bdiag%7D(%5Clambda_1%2C%20%5Clambda_2%2C%20%5Cdots%2C%20%5Clambda_n)%24.%0A%0A%20%20%20%20Writing%20%24%5Cmathbf%7BQ%7D%24%20in%20terms%20of%20its%20orthonormal%20column%20eigenvectors%20%24%5B%5Cmathbf%7Bq%7D_1%2C%20%5Cdots%2C%20%5Cmathbf%7Bq%7D_n%5D%24%2C%20this%20expression%20is%20equivalent%20to%20an%20additive%20decomposition%20into%20rank-1%20orthogonal%20projections%3A%0A%0A%20%20%20%20%24%24%0A%20%20%20%20%5Cmathbf%7BS%7D%20%3D%20%5Csum_%7Bi%3D1%7D%5En%20%5Clambda_i%20%5Cmathbf%7Bq%7D_i%20%5Cmathbf%7Bq%7D_i%5ET%0A%20%20%20%20%24%24%0A%0A%20%20%20%20Each%20term%20%24%5Cmathbf%7Bq%7D_i%20%5Cmathbf%7Bq%7D_i%5ET%24%20is%20a%20symmetric%20rank-1%20projection%20matrix%20onto%20the%201D%20subspace%20spanned%20by%20%24%5Cmathbf%7Bq%7D_i%24.%0A%0A%20%20%20%20---%0A%0A%20%20%20%20%23%23%23%20Positive%20Semi-Definite%20(PSD)%20Matrices%0A%0A%20%20%20%20A%20symmetric%20matrix%20%24%5Cmathbf%7BS%7D%20%5Cin%20%5Cmathbb%7BR%7D%5E%7Bn%20%5Ctimes%20n%7D%24%20is%20**positive%20semi-definite**%20(%24%5Cmathbf%7BS%7D%20%5Csucceq%200%24)%20if%20for%20every%20vector%20%24%5Cmathbf%7Bx%7D%20%5Cin%20%5Cmathbb%7BR%7D%5En%24%3A%0A%0A%20%20%20%20%24%24%0A%20%20%20%20%5Cmathbf%7Bx%7D%5ET%20%5Cmathbf%7BS%7D%20%5Cmathbf%7Bx%7D%20%5Cgeq%200%0A%20%20%20%20%24%24%0A%0A%20%20%20%20Substituting%20the%20spectral%20decomposition%20%24%5Cmathbf%7BS%7D%20%3D%20%5Cmathbf%7BQ%7D%5Cmathbf%7B%5CLambda%7D%5Cmathbf%7BQ%7D%5ET%24%20and%20letting%20%24%5Cmathbf%7By%7D%20%3D%20%5Cmathbf%7BQ%7D%5ET%20%5Cmathbf%7Bx%7D%24%3A%0A%0A%20%20%20%20%24%24%0A%20%20%20%20%5Cmathbf%7Bx%7D%5ET%20%5Cmathbf%7BS%7D%20%5Cmathbf%7Bx%7D%20%3D%20%5Cmathbf%7By%7D%5ET%20%5Cmathbf%7B%5CLambda%7D%20%5Cmathbf%7By%7D%20%3D%20%5Csum_%7Bi%3D1%7D%5En%20%5Clambda_i%20y_i%5E2%20%5Cgeq%200%2C%20%5Cquad%20%5Cforall%20%5Cmathbf%7By%7D%20%5Cin%20%5Cmathbb%7BR%7D%5En%0A%20%20%20%20%24%24%0A%0A%20%20%20%20This%20immediately%20proves%20that%20a%20symmetric%20matrix%20is%20positive%20semi-definite%20if%20and%20only%20if%20all%20its%20eigenvalues%20are%20non-negative%3A%0A%0A%20%20%20%20%24%24%0A%20%20%20%20%5Cmathbf%7BS%7D%20%5Csucceq%200%20%5Ciff%20%5Clambda_i%20%5Cgeq%200%2C%20%5Cquad%20%5Cforall%20i%20%5Cin%20%5C%7B1%2C%20%5Cdots%2C%20n%5C%7D%0A%20%20%20%20%24%24%0A%0A%20%20%20%20If%20the%20quadratic%20form%20is%20strictly%20positive%20(%24%5Cmathbf%7Bx%7D%5ET%20%5Cmathbf%7BS%7D%20%5Cmathbf%7Bx%7D%20%3E%200%24%20for%20all%20%24%5Cmathbf%7Bx%7D%20%5Cneq%20%5Cmathbf%7B0%7D%24)%2C%20%24%5Cmathbf%7BS%7D%24%20is%20**positive%20definite**%20(%24%5Cmathbf%7BS%7D%20%5Csucc%200%24)%2C%20meaning%20all%20eigenvalues%20are%20strictly%20positive%20(%24%5Clambda_i%20%3E%200%24).%0A%0A%20%20%20%20---%0A%0A%20%20%20%20%23%23%23%20Universal%20Positive%20Semi-Definiteness%20of%20Gram%20Matrices%0A%0A%20%20%20%20For%20any%20rectangular%20real%20matrix%20%24%5Cmathbf%7BA%7D%20%5Cin%20%5Cmathbb%7BR%7D%5E%7Bm%20%5Ctimes%20n%7D%24%2C%20the%20Gram%20matrices%20%24%5Cmathbf%7BA%7D%5ET%20%5Cmathbf%7BA%7D%24%20and%20%24%5Cmathbf%7BA%7D%5Cmathbf%7BA%7D%5ET%24%20are%20unconditionally%20symmetric%20and%20positive%20semi-definite.%0A%0A%20%20%20%20%23%23%23%23%20Verification%20for%20%24%5Cmathbf%7BA%7D%5ET%20%5Cmathbf%7BA%7D%24%0A%0A%20%20%20%20Symmetry%3A%20%24(%5Cmathbf%7BA%7D%5ET%20%5Cmathbf%7BA%7D)%5ET%20%3D%20%5Cmathbf%7BA%7D%5ET%20(%5Cmathbf%7BA%7D%5ET)%5ET%20%3D%20%5Cmathbf%7BA%7D%5ET%20%5Cmathbf%7BA%7D%24.%0A%20%20%20%20Positive%20semi-definiteness%3A%20for%20any%20%24%5Cmathbf%7Bx%7D%20%5Cin%20%5Cmathbb%7BR%7D%5En%24%3A%0A%0A%20%20%20%20%24%24%0A%20%20%20%20%5Cmathbf%7Bx%7D%5ET%20(%5Cmathbf%7BA%7D%5ET%20%5Cmathbf%7BA%7D)%20%5Cmathbf%7Bx%7D%20%3D%20(%5Cmathbf%7BA%7D%5Cmathbf%7Bx%7D)%5ET%20(%5Cmathbf%7BA%7D%5Cmathbf%7Bx%7D)%20%3D%20%5C%7C%5Cmathbf%7BA%7D%5Cmathbf%7Bx%7D%5C%7C_2%5E2%20%5Cgeq%200%0A%20%20%20%20%24%24%0A%0A%20%20%20%20%23%23%23%23%20Verification%20for%20%24%5Cmathbf%7BA%7D%5Cmathbf%7BA%7D%5ET%24%0A%0A%20%20%20%20Symmetry%3A%20%24(%5Cmathbf%7BA%7D%20%5Cmathbf%7BA%7D%5ET)%5ET%20%3D%20(%5Cmathbf%7BA%7D%5ET)%5ET%20%5Cmathbf%7BA%7D%5ET%20%3D%20%5Cmathbf%7BA%7D%20%5Cmathbf%7BA%7D%5ET%24.%0A%20%20%20%20Positive%20semi-definiteness%3A%20for%20any%20%24%5Cmathbf%7By%7D%20%5Cin%20%5Cmathbb%7BR%7D%5E%7Bm%7D%24%3A%0A%0A%20%20%20%20%24%24%0A%20%20%20%20%5Cmathbf%7By%7D%5ET%20(%5Cmathbf%7BA%7D%20%5Cmathbf%7BA%7D%5ET)%20%5Cmathbf%7By%7D%20%3D%20(%5Cmathbf%7BA%7D%5ET%20%5Cmathbf%7By%7D)%5ET%20(%5Cmathbf%7BA%7D%5ET%20%5Cmathbf%7By%7D)%20%3D%20%5C%7C%5Cmathbf%7BA%7D%5ET%20%5Cmathbf%7By%7D%5C%7C_2%5E2%20%5Cgeq%200%0A%20%20%20%20%24%24%0A%0A%20%20%20%20---%0A%0A%20%20%20%20%23%23%23%20The%20Direct%20Bridge%20Between%20SVD%20and%20Spectral%20Decomposition%0A%0A%20%20%20%20Singular%20Value%20Decomposition%20(SVD)%20and%20Spectral%20Decomposition%20are%20intimately%20linked.%20Let%20the%20SVD%20of%20%24%5Cmathbf%7BA%7D%20%5Cin%20%5Cmathbb%7BR%7D%5E%7Bm%20%5Ctimes%20n%7D%24%20be%3A%0A%0A%20%20%20%20%24%24%0A%20%20%20%20%5Cmathbf%7BA%7D%20%3D%20%5Cmathbf%7BU%7D%20%5Cmathbf%7B%5CSigma%7D%20%5Cmathbf%7BV%7D%5ET%0A%20%20%20%20%24%24%0A%0A%20%20%20%20where%20%24%5Cmathbf%7BU%7D%20%5Cin%20%5Cmathbb%7BR%7D%5E%7Bm%20%5Ctimes%20m%7D%24%20and%20%24%5Cmathbf%7BV%7D%20%5Cin%20%5Cmathbb%7BR%7D%5E%7Bn%20%5Ctimes%20n%7D%24%20are%20orthogonal%2C%20and%20%24%5Cmathbf%7B%5CSigma%7D%20%5Cin%20%5Cmathbb%7BR%7D%5E%7Bm%20%5Ctimes%20n%7D%24%20contains%20singular%20values%20%24%5Csigma_1%20%5Cgeq%20%5Csigma_2%20%5Cgeq%20%5Cdots%20%5Cgeq%200%24.%0A%0A%20%20%20%20Computing%20the%20Gram%20matrices%20via%20SVD%20yields%3A%0A%0A%20%20%20%20%24%24%0A%20%20%20%20%5Cmathbf%7BA%7D%5ET%20%5Cmathbf%7BA%7D%20%3D%20(%5Cmathbf%7BU%7D%20%5Cmathbf%7B%5CSigma%7D%20%5Cmathbf%7BV%7D%5ET)%5ET%20(%5Cmathbf%7BU%7D%20%5Cmathbf%7B%5CSigma%7D%20%5Cmathbf%7BV%7D%5ET)%20%3D%20%5Cmathbf%7BV%7D%20%5Cmathbf%7B%5CSigma%7D%5ET%20%5Cmathbf%7B%5CSigma%7D%20%5Cmathbf%7BV%7D%5ET%20%3D%20%5Cmathbf%7BV%7D%20%5Cmathbf%7B%5CLambda%7D_%7B%5Ctext%7Bright%7D%7D%20%5Cmathbf%7BV%7D%5ET%0A%20%20%20%20%24%24%0A%0A%20%20%20%20%24%24%0A%20%20%20%20%5Cmathbf%7BA%7D%20%5Cmathbf%7BA%7D%5ET%20%3D%20(%5Cmathbf%7BU%7D%20%5Cmathbf%7B%5CSigma%7D%20%5Cmathbf%7BV%7D%5ET)%20(%5Cmathbf%7BU%7D%20%5Cmathbf%7B%5CSigma%7D%20%5Cmathbf%7BV%7D%5ET)%5ET%20%3D%20%5Cmathbf%7BU%7D%20%5Cmathbf%7B%5CSigma%7D%20%5Cmathbf%7B%5CSigma%7D%5ET%20%5Cmathbf%7BU%7D%5ET%20%3D%20%5Cmathbf%7BU%7D%20%5Cmathbf%7B%5CLambda%7D_%7B%5Ctext%7Bleft%7D%7D%20%5Cmathbf%7BU%7D%5ET%0A%20%20%20%20%24%24%0A%0A%20%20%20%20This%20reveals%20three%20structural%20facts%3A%0A%20%20%20%20*%20The%20right%20singular%20vectors%20%24%5Cmathbf%7BV%7D%24%20are%20the%20orthonormal%20eigenvectors%20of%20%24%5Cmathbf%7BA%7D%5ET%20%5Cmathbf%7BA%7D%24.%0A%20%20%20%20*%20The%20left%20singular%20vectors%20%24%5Cmathbf%7BU%7D%24%20are%20the%20orthonormal%20eigenvectors%20of%20%24%5Cmathbf%7BA%7D%20%5Cmathbf%7BA%7D%5ET%24.%0A%20%20%20%20*%20The%20singular%20values%20%24%5Csigma_i%24%20of%20%24%5Cmathbf%7BA%7D%24%20are%20the%20square%20roots%20of%20the%20non-zero%20eigenvalues%20of%20both%20%24%5Cmathbf%7BA%7D%5ET%20%5Cmathbf%7BA%7D%24%20and%20%24%5Cmathbf%7BA%7D%20%5Cmathbf%7BA%7D%5ET%24%3A%0A%0A%20%20%20%20%24%24%0A%20%20%20%20%5Csigma_i%20%3D%20%5Csqrt%7B%5Clambda_i(%5Cmathbf%7BA%7D%5ET%20%5Cmathbf%7BA%7D)%7D%20%3D%20%5Csqrt%7B%5Clambda_i(%5Cmathbf%7BA%7D%5Cmathbf%7BA%7D%5ET)%7D%0A%20%20%20%20%24%24%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20---%0A%0A%20%20%20%20%23%23%20%5Bc%5D%20Interactive%20Visualizations%3A%20Quadratic%20Form%20Geometry%20and%20Spectral%20Equivalence%0A%0A%20%20%20%20The%20interactive%20subplots%20below%20display%20the%20dual%20perspective%20of%20spectral%20decomposition%3A%0A%20%20%20%20*%20**Left%20Panel**%3A%20Transformation%20of%20the%20unit%20circle%20under%20a%202D%20symmetric%20positive%20definite%20matrix%20%24%5Cmathbf%7BS%7D%24.%20The%20eigenvectors%20%24%5Cmathbf%7Bq%7D_1%2C%20%5Cmathbf%7Bq%7D_2%24%20define%20the%20principal%20axes%20of%20the%20resulting%20ellipse%2C%20scaled%20by%20%24%5Clambda_1%2C%20%5Clambda_2%24.%0A%20%20%20%20*%20**Right%20Panel**%3A%20Verification%20that%20the%20non-zero%20eigenvalues%20of%20%24%5Cmathbf%7BA%7D%5ET%5Cmathbf%7BA%7D%24%20and%20%24%5Cmathbf%7BA%7D%5Cmathbf%7BA%7D%5ET%24%20exactly%20equal%20the%20squared%20singular%20values%20%24%5Csigma_i%5E2%24%20from%20SVD.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(go%2C%20make_subplots%2C%20np)%3A%0A%20%20%20%20%23%20Left%20Panel%3A%202D%20Ellipsoid%20Geometry%20for%20Symmetric%20Matrix%0A%20%20%20%20%23%20Construct%20a%202D%20symmetric%20PSD%20matrix%0A%20%20%20%20theta_deg%20%3D%2035.0%0A%20%20%20%20theta_rad%20%3D%20np.radians(theta_deg)%0A%20%20%20%20cos_t%2C%20sin_t%20%3D%20np.cos(theta_rad)%2C%20np.sin(theta_rad)%0A%20%20%20%20q_mat%20%3D%20np.array(%5B%5Bcos_t%2C%20-sin_t%5D%2C%20%5Bsin_t%2C%20cos_t%5D%5D)%0A%20%20%20%20lambdas%20%3D%20np.array(%5B2.4%2C%200.8%5D)%0A%20%20%20%20s_mat%20%3D%20q_mat%20%40%20np.diag(lambdas)%20%40%20q_mat.T%0A%0A%20%20%20%20%23%20Unit%20circle%20points%0A%20%20%20%20t%20%3D%20np.linspace(0%2C%202%20*%20np.pi%2C%20200)%0A%20%20%20%20circle_pts%20%3D%20np.vstack(%5Bnp.cos(t)%2C%20np.sin(t)%5D)%0A%0A%20%20%20%20%23%20Transformed%20ellipse%20points%3A%20S%20%40%20circle%0A%20%20%20%20ellipse_pts%20%3D%20s_mat%20%40%20circle_pts%0A%0A%20%20%20%20%23%20Eigenvector%20axes%20scaled%20by%20eigenvalues%0A%20%20%20%20q1%20%3D%20q_mat%5B%3A%2C%200%5D%0A%20%20%20%20q2%20%3D%20q_mat%5B%3A%2C%201%5D%0A%20%20%20%20axis1%20%3D%20lambdas%5B0%5D%20*%20q1%0A%20%20%20%20axis2%20%3D%20lambdas%5B1%5D%20*%20q2%0A%0A%20%20%20%20%23%20Right%20Panel%3A%20Gram%20matrix%20eigenvalue%20vs%20singular%20value%20comparison%0A%20%20%20%20%23%20Generate%20rectangular%20matrix%20A%20(4%20x%203)%0A%20%20%20%20rng%20%3D%20np.random.default_rng(101)%0A%20%20%20%20a_rect%20%3D%20np.array(%5B%5B2.0%2C%201.0%2C%200.5%5D%2C%20%5B1.5%2C%203.0%2C%201.2%5D%2C%20%5B0.8%2C%200.4%2C%202.5%5D%2C%20%5B1.2%2C%202.1%2C%200.9%5D%5D)%0A%20%20%20%20_%2C%20s_vals%2C%20_%20%3D%20np.linalg.svd(a_rect)%0A%20%20%20%20eig_ata%20%3D%20np.sort(np.linalg.eigvalsh(a_rect.T%20%40%20a_rect))%5B%3A%3A-1%5D%0A%20%20%20%20eig_aat%20%3D%20np.sort(np.linalg.eigvalsh(a_rect%20%40%20a_rect.T))%5B%3A%3A-1%5D%5B%3A3%5D%0A%20%20%20%20s_squared%20%3D%20s_vals**2%0A%0A%20%20%20%20fig%20%3D%20make_subplots(%0A%20%20%20%20%20%20%20%20rows%3D1%2C%0A%20%20%20%20%20%20%20%20cols%3D2%2C%0A%20%20%20%20%20%20%20%20subplot_titles%3D%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20f%22Symmetric%20Matrix%20Geometry%20(%CE%BB%E2%82%81%3D%7Blambdas%5B0%5D%3A.1f%7D%2C%20%CE%BB%E2%82%82%3D%7Blambdas%5B1%5D%3A.1f%7D)%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Gram%20Matrix%20Spectrum%20vs%20SVD%20Singular%20Values%22%2C%0A%20%20%20%20%20%20%20%20%5D%2C%0A%20%20%20%20)%0A%0A%20%20%20%20%23%20Left%3A%20Unit%20circle%0A%20%20%20%20fig.add_trace(%0A%20%20%20%20%20%20%20%20go.Scatter(%0A%20%20%20%20%20%20%20%20%20%20%20%20x%3Dcircle_pts%5B0%5D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20y%3Dcircle_pts%5B1%5D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20mode%3D%22lines%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20line%3Ddict(color%3D%22%23cbd5e1%22%2C%20dash%3D%22dash%22%2C%20width%3D1.5)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20name%3D%22Unit%20Circle%20%7C%7Cx%7C%7C%3D1%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20showlegend%3DTrue%2C%0A%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20row%3D1%2C%0A%20%20%20%20%20%20%20%20col%3D1%2C%0A%20%20%20%20)%0A%0A%20%20%20%20%23%20Left%3A%20Transformed%20ellipse%0A%20%20%20%20fig.add_trace(%0A%20%20%20%20%20%20%20%20go.Scatter(%0A%20%20%20%20%20%20%20%20%20%20%20%20x%3Dellipse_pts%5B0%5D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20y%3Dellipse_pts%5B1%5D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20mode%3D%22lines%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20line%3Ddict(color%3D%22%232563eb%22%2C%20width%3D2.5)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20name%3D%22Transformed%20Ellipse%20S%20x%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20showlegend%3DTrue%2C%0A%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20row%3D1%2C%0A%20%20%20%20%20%20%20%20col%3D1%2C%0A%20%20%20%20)%0A%0A%20%20%20%20%23%20Left%3A%20Principal%20Axis%201%0A%20%20%20%20fig.add_trace(%0A%20%20%20%20%20%20%20%20go.Scatter(%0A%20%20%20%20%20%20%20%20%20%20%20%20x%3D%5B0%2C%20axis1%5B0%5D%5D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20y%3D%5B0%2C%20axis1%5B1%5D%5D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20mode%3D%22lines%2Bmarkers%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20line%3Ddict(color%3D%22%23dc2626%22%2C%20width%3D3.5)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20marker%3Ddict(size%3D7%2C%20color%3D%22%23dc2626%22)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20name%3D%22Principal%20Axis%20%CE%BB%E2%82%81%20q%E2%82%81%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20showlegend%3DTrue%2C%0A%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20row%3D1%2C%0A%20%20%20%20%20%20%20%20col%3D1%2C%0A%20%20%20%20)%0A%0A%20%20%20%20%23%20Left%3A%20Principal%20Axis%202%0A%20%20%20%20fig.add_trace(%0A%20%20%20%20%20%20%20%20go.Scatter(%0A%20%20%20%20%20%20%20%20%20%20%20%20x%3D%5B0%2C%20axis2%5B0%5D%5D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20y%3D%5B0%2C%20axis2%5B1%5D%5D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20mode%3D%22lines%2Bmarkers%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20line%3Ddict(color%3D%22%2316a34a%22%2C%20width%3D3.5)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20marker%3Ddict(size%3D7%2C%20color%3D%22%2316a34a%22)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20name%3D%22Principal%20Axis%20%CE%BB%E2%82%82%20q%E2%82%82%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20showlegend%3DTrue%2C%0A%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20row%3D1%2C%0A%20%20%20%20%20%20%20%20col%3D1%2C%0A%20%20%20%20)%0A%0A%20%20%20%20%23%20Right%3A%20Bar%20comparison%0A%20%20%20%20categories%20%3D%20%5B%22Component%201%22%2C%20%22Component%202%22%2C%20%22Component%203%22%5D%0A%20%20%20%20fig.add_trace(%0A%20%20%20%20%20%20%20%20go.Bar(%0A%20%20%20%20%20%20%20%20%20%20%20%20x%3Dcategories%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20y%3Deig_ata%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20name%3D%22%CE%BB(A%E1%B5%80%20A)%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20marker_color%3D%22%232563eb%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20opacity%3D0.85%2C%0A%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20row%3D1%2C%0A%20%20%20%20%20%20%20%20col%3D2%2C%0A%20%20%20%20)%0A%20%20%20%20fig.add_trace(%0A%20%20%20%20%20%20%20%20go.Bar(%0A%20%20%20%20%20%20%20%20%20%20%20%20x%3Dcategories%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20y%3Deig_aat%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20name%3D%22%CE%BB(A%20A%E1%B5%80)%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20marker_color%3D%22%2306b6d4%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20opacity%3D0.85%2C%0A%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20row%3D1%2C%0A%20%20%20%20%20%20%20%20col%3D2%2C%0A%20%20%20%20)%0A%20%20%20%20fig.add_trace(%0A%20%20%20%20%20%20%20%20go.Scatter(%0A%20%20%20%20%20%20%20%20%20%20%20%20x%3Dcategories%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20y%3Ds_squared%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20mode%3D%22markers%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20marker%3Ddict(color%3D%22%23dc2626%22%2C%20size%3D11%2C%20symbol%3D%22circle-open%22%2C%20line%3Ddict(width%3D3))%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20name%3D%22%CF%83%C2%B2%20from%20SVD%22%2C%0A%20%20%20%20%20%20%20%20)%2C%0A%20%20%20%20%20%20%20%20row%3D1%2C%0A%20%20%20%20%20%20%20%20col%3D2%2C%0A%20%20%20%20)%0A%0A%20%20%20%20axis_config_left%20%3D%20dict(%0A%20%20%20%20%20%20%20%20range%3D%5B-3.0%2C%203.0%5D%2C%0A%20%20%20%20%20%20%20%20zeroline%3DTrue%2C%0A%20%20%20%20%20%20%20%20zerolinecolor%3D%22%23cbd5e1%22%2C%0A%20%20%20%20%20%20%20%20gridcolor%3D%22%23f1f5f9%22%2C%0A%20%20%20%20%20%20%20%20scaleanchor%3D%22x%22%2C%0A%20%20%20%20%20%20%20%20scaleratio%3D1%2C%0A%20%20%20%20)%0A%0A%20%20%20%20fig.update_layout(%0A%20%20%20%20%20%20%20%20template%3D%22plotly_white%22%2C%0A%20%20%20%20%20%20%20%20height%3D500%2C%0A%20%20%20%20%20%20%20%20margin%3Ddict(l%3D40%2C%20r%3D40%2C%20t%3D60%2C%20b%3D40)%2C%0A%20%20%20%20%20%20%20%20xaxis%3Daxis_config_left%2C%0A%20%20%20%20%20%20%20%20yaxis%3Daxis_config_left%2C%0A%20%20%20%20%20%20%20%20xaxis2%3Ddict(gridcolor%3D%22%23f1f5f9%22)%2C%0A%20%20%20%20%20%20%20%20yaxis2%3Ddict(title%3D%22Eigenvalue%20%2F%20%CF%83%C2%B2%22%2C%20gridcolor%3D%22%23f1f5f9%22)%2C%0A%20%20%20%20%20%20%20%20barmode%3D%22group%22%2C%0A%20%20%20%20%20%20%20%20legend%3Ddict(orientation%3D%22h%22%2C%20yanchor%3D%22bottom%22%2C%20y%3D-0.22%2C%20xanchor%3D%22center%22%2C%20x%3D0.5)%2C%0A%20%20%20%20)%0A%20%20%20%20return%20(fig%2C)%0A%0A%0A%40app.cell%0Adef%20_(fig%2C%20mo)%3A%0A%20%20%20%20mo.ui.plotly(fig)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20---%0A%0A%20%20%20%20%23%23%20%5Bd%5D%20Code%20Examples%0A%0A%20%20%20%20%23%23%23%20Example%201%3A%20Numerical%20Verification%20of%20Spectral%20Theorem%20and%20Gram%20Equivalence%0A%0A%20%20%20%20Below%2C%20we%20generate%20a%20rectangular%20matrix%20%24%5Cmathbf%7BA%7D%20%5Cin%20%5Cmathbb%7BR%7D%5E%7B5%20%5Ctimes%203%7D%24%2C%20construct%20its%20Gram%20matrices%20%24%5Cmathbf%7BA%7D%5ET%5Cmathbf%7BA%7D%24%20and%20%24%5Cmathbf%7BA%7D%5Cmathbf%7BA%7D%5ET%24%2C%20and%20verify%3A%0A%20%20%20%201.%20Reconstruction%20of%20the%20symmetric%20matrix%20from%20eigenvalues%20and%20eigenvectors%3A%20%24%5Cmathbf%7BQ%7D%20%5Cmathbf%7B%5CLambda%7D%20%5Cmathbf%7BQ%7D%5ET%20%3D%20%5Cmathbf%7BS%7D%24%0A%20%20%20%202.%20Orthogonality%20of%20eigenvectors%3A%20%24%5Cmathbf%7BQ%7D%5ET%20%5Cmathbf%7BQ%7D%20%3D%20%5Cmathbf%7BI%7D%24%0A%20%20%20%203.%20Non-negativity%20of%20all%20eigenvalues%20(%24%5Clambda_i%20%5Cgeq%200%24)%0A%20%20%20%204.%20Exact%20correspondence%20between%20Gram%20eigenvalues%20and%20SVD%20singular%20values%3A%20%24%7C%5Clambda_i%20-%20%5Csigma_i%5E2%7C%20%3C%2010%5E%7B-12%7D%24%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(np)%3A%0A%20%20%20%20rng_ex1%20%3D%20np.random.default_rng(42)%0A%0A%20%20%20%20%23%205%20x%203%20rectangular%20matrix%0A%20%20%20%20a_mat%20%3D%20rng_ex1.standard_normal((5%2C%203))%0A%0A%20%20%20%20%23%20Gram%20matrices%0A%20%20%20%20ata%20%3D%20a_mat.T%20%40%20a_mat%0A%20%20%20%20aat%20%3D%20a_mat%20%40%20a_mat.T%0A%0A%20%20%20%20%23%20Eigendecomposition%20of%20AtA%0A%20%20%20%20eigvals_ata%2C%20q_ata%20%3D%20np.linalg.eigh(ata)%0A%20%20%20%20%23%20Sort%20descending%0A%20%20%20%20sort_idx%20%3D%20np.argsort(eigvals_ata)%5B%3A%3A-1%5D%0A%20%20%20%20eigvals_ata%20%3D%20eigvals_ata%5Bsort_idx%5D%0A%20%20%20%20q_ata%20%3D%20q_ata%5B%3A%2C%20sort_idx%5D%0A%0A%20%20%20%20%23%20Reconstruct%20AtA%0A%20%20%20%20ata_reconstructed%20%3D%20q_ata%20%40%20np.diag(eigvals_ata)%20%40%20q_ata.T%0A%20%20%20%20recon_error%20%3D%20float(np.max(np.abs(ata%20-%20ata_reconstructed)))%0A%0A%20%20%20%20%23%20Orthogonality%20check%20of%20eigenvectors%0A%20%20%20%20ortho_error%20%3D%20float(np.max(np.abs(q_ata.T%20%40%20q_ata%20-%20np.eye(3))))%0A%0A%20%20%20%20%23%20SVD%20of%20A%0A%20%20%20%20_%2C%20s_values%2C%20_%20%3D%20np.linalg.svd(a_mat)%0A%20%20%20%20svd_sq_err%20%3D%20float(np.max(np.abs(eigvals_ata%20-%20s_values**2)))%0A%0A%20%20%20%20%23%20Minimum%20eigenvalue%20(confirming%20PSD%20property)%0A%20%20%20%20min_eigval%20%3D%20float(np.min(eigvals_ata))%0A%0A%20%20%20%20spectral_summary%20%3D%20%7B%0A%20%20%20%20%20%20%20%20%22Property%20%2F%20Verification%22%3A%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Reconstruction%20error%3A%20max%20%7CA%E1%B5%80%20A%20-%20Q%20%CE%9B%20Q%E1%B5%80%7C%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Orthogonality%20error%3A%20max%20%7CQ%E1%B5%80%20Q%20-%20I%7C%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Discrepancy%3A%20max%20%7C%CE%BB(A%E1%B5%80%20A)%20-%20%CF%83%C2%B2(A)%7C%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Minimum%20eigenvalue%20%CE%BB_min%20(must%20be%20%3E%3D%200)%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22All%20eigenvalues%20of%20A%E1%B5%80%20A%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22All%20squared%20singular%20values%20%CF%83%C2%B2%20of%20A%22%2C%0A%20%20%20%20%20%20%20%20%5D%2C%0A%20%20%20%20%20%20%20%20%22Value%22%3A%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20f%22%7Brecon_error%3A.2e%7D%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20f%22%7Bortho_error%3A.2e%7D%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20f%22%7Bsvd_sq_err%3A.2e%7D%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20f%22%7Bmin_eigval%3A.6f%7D%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22%2C%20%22.join(f%22%7Bv%3A.4f%7D%22%20for%20v%20in%20eigvals_ata)%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22%2C%20%22.join(f%22%7Bv%3A.4f%7D%22%20for%20v%20in%20(s_values**2))%2C%0A%20%20%20%20%20%20%20%20%5D%2C%0A%20%20%20%20%7D%0A%20%20%20%20return%20(spectral_summary%2C)%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo%2C%20pd%2C%20spectral_summary)%3A%0A%20%20%20%20df_spectral%20%3D%20pd.DataFrame(spectral_summary)%0A%20%20%20%20mo.ui.table(df_spectral)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20---%0A%0A%20%20%20%20%23%23%23%20Example%202%3A%20Spectral%20Graph%20Partitioning%20via%20the%20Fiedler%20Vector%0A%0A%20%20%20%20In%20spectral%20graph%20theory%20and%20Graph%20Neural%20Networks%2C%20community%20detection%20is%20performed%20by%20computing%20the%20eigendecomposition%20of%20the%20**Graph%20Laplacian**%3A%0A%0A%20%20%20%20%24%24%0A%20%20%20%20%5Cmathbf%7BL%7D%20%3D%20%5Cmathbf%7BD%7D%20-%20%5Cmathbf%7BA%7D_%7B%5Ctext%7Badj%7D%7D%0A%20%20%20%20%24%24%0A%0A%20%20%20%20where%20%24%5Cmathbf%7BD%7D%24%20is%20the%20diagonal%20degree%20matrix%20and%20%24%5Cmathbf%7BA%7D_%7B%5Ctext%7Badj%7D%7D%24%20is%20the%20adjacency%20matrix.%0A%0A%20%20%20%20Key%20mathematical%20properties%20of%20the%20Graph%20Laplacian%3A%0A%20%20%20%20*%20%24%5Cmathbf%7BL%7D%24%20is%20symmetric%20and%20positive%20semi-definite%20(%24%5Cmathbf%7BL%7D%20%5Csucceq%200%24).%0A%20%20%20%20*%20The%20smallest%20eigenvalue%20is%20always%20%24%5Clambda_1%20%3D%200%24%2C%20with%20eigenvector%20%24%5Cmathbf%7Bv%7D_1%20%3D%20%5Cfrac%7B1%7D%7B%5Csqrt%7Bn%7D%7D%20%5Cmathbf%7B1%7D%24.%0A%20%20%20%20*%20The%20second%20smallest%20eigenvalue%20%24%5Clambda_2%24%20is%20the%20**algebraic%20connectivity**%20(Fiedler%20value).%0A%20%20%20%20*%20Its%20eigenvector%20%24%5Cmathbf%7Bv%7D_2%24%20(the%20**Fiedler%20vector**)%20solves%20the%20relaxed%20normalized%20cut%20problem%3A%20sorting%20nodes%20by%20the%20sign%20of%20%24%5Cmathbf%7Bv%7D_2(i)%24%20partitions%20the%20graph%20into%20optimal%20clusters.%0A%0A%20%20%20%20Below%2C%20we%20construct%20a%206-node%20barbell%20graph%20with%20two%203-node%20cliques%20joined%20by%20a%20single%20edge%2C%20compute%20%24%5Cmathbf%7BL%7D%24%2C%20and%20verify%20exact%20community%20separation%20via%20the%20Fiedler%20vector.%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(np)%3A%0A%20%20%20%20%23%20Construct%206-node%20graph%20with%20two%20clusters%3A%20%7B0%2C%201%2C%202%7D%20and%20%7B3%2C%204%2C%205%7D%20connected%20by%20edge%20(2%2C%203)%0A%20%20%20%20adj%20%3D%20np.zeros((6%2C%206))%0A%0A%20%20%20%20%23%20Cluster%201%3A%20nodes%200%2C%201%2C%202%0A%20%20%20%20adj%5B0%2C%201%5D%20%3D%20adj%5B1%2C%200%5D%20%3D%201%0A%20%20%20%20adj%5B0%2C%202%5D%20%3D%20adj%5B2%2C%200%5D%20%3D%201%0A%20%20%20%20adj%5B1%2C%202%5D%20%3D%20adj%5B2%2C%201%5D%20%3D%201%0A%0A%20%20%20%20%23%20Bridge%20edge%0A%20%20%20%20adj%5B2%2C%203%5D%20%3D%20adj%5B3%2C%202%5D%20%3D%201%0A%0A%20%20%20%20%23%20Cluster%202%3A%20nodes%203%2C%204%2C%205%0A%20%20%20%20adj%5B3%2C%204%5D%20%3D%20adj%5B4%2C%203%5D%20%3D%201%0A%20%20%20%20adj%5B3%2C%205%5D%20%3D%20adj%5B5%2C%203%5D%20%3D%201%0A%20%20%20%20adj%5B4%2C%205%5D%20%3D%20adj%5B5%2C%204%5D%20%3D%201%0A%0A%20%20%20%20%23%20Degree%20matrix%0A%20%20%20%20degrees%20%3D%20np.sum(adj%2C%20axis%3D1)%0A%20%20%20%20d_mat%20%3D%20np.diag(degrees)%0A%0A%20%20%20%20%23%20Graph%20Laplacian%0A%20%20%20%20laplacian%20%3D%20d_mat%20-%20adj%0A%0A%20%20%20%20%23%20Spectral%20decomposition%20of%20symmetric%20Laplacian%0A%20%20%20%20eigvals_l%2C%20eigvecs_l%20%3D%20np.linalg.eigh(laplacian)%0A%0A%20%20%20%20%23%20Fiedler%20value%20and%20vector%20(index%201)%0A%20%20%20%20fiedler_value%20%3D%20float(eigvals_l%5B1%5D)%0A%20%20%20%20fiedler_vector%20%3D%20eigvecs_l%5B%3A%2C%201%5D%0A%0A%20%20%20%20%23%20Cluster%20assignment%20by%20sign%20of%20Fiedler%20vector%0A%20%20%20%20cluster_assignment%20%3D%20%5B%22Cluster%201%22%20if%20val%20%3C%200%20else%20%22Cluster%202%22%20for%20val%20in%20fiedler_vector%5D%0A%0A%20%20%20%20graph_summary%20%3D%20%7B%0A%20%20%20%20%20%20%20%20%22Node%22%3A%20%5Bf%22Node%20%7Bi%7D%22%20for%20i%20in%20range(6)%5D%2C%0A%20%20%20%20%20%20%20%20%22Degree%22%3A%20%5Bint(d)%20for%20d%20in%20degrees%5D%2C%0A%20%20%20%20%20%20%20%20%22Fiedler%20Vector%20Value%20v%E2%82%82(i)%22%3A%20%5Bf%22%7Bv%3A%2B.4f%7D%22%20for%20v%20in%20fiedler_vector%5D%2C%0A%20%20%20%20%20%20%20%20%22Predicted%20Partition%22%3A%20cluster_assignment%2C%0A%20%20%20%20%20%20%20%20%22Ground%20Truth%20Community%22%3A%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Community%20A%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Community%20A%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Community%20A%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Community%20B%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Community%20B%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Community%20B%22%2C%0A%20%20%20%20%20%20%20%20%5D%2C%0A%20%20%20%20%7D%0A%20%20%20%20return%20(graph_summary%2C)%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(graph_summary%2C%20mo%2C%20pd)%3A%0A%20%20%20%20df_graph%20%3D%20pd.DataFrame(graph_summary)%0A%20%20%20%20mo.ui.table(df_graph)%0A%20%20%20%20return%0A%0A%0Aif%20__name__%20%3D%3D%20%22__main__%22%3A%0A%20%20%20%20app.run()%0A
6fd8c400db22cc387df31a318c62abd1