main.r541 chars21 lines
This code snippet first generates a Laplacian matrix from a sample graph using the igraph package in R. Then, it calculates the eigenvalues and eigenvectors of the Laplacian matrix. Next, it performs clustering using k-means on the eigenvectors (excluding the first eigenvector). Finally, it plots the graph with each vertex colored according to the cluster it belongs to.
gistlibby LogSnag