gistlib
main.rlibrary(igraph) # Create a community matrix community_matrix <- matrix(c(1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1), nrow = 5, byrow = TRUE) # Create an adjacency matrix from the community matrix adjacency_matrix <- community_matrix %*% t(community_matrix) # Create an igraph graph object from the adjacency matrix graph <- graph_from_adjacency_matrix(adjacency_matrix, mode = "undirected") # Get Laplacian matrix laplacian_matrix <- laplacian_matrix(graph) # Spectral analysis eigen_values <- eigen(laplacian_matrix)$values # Create a graph plot plot(graph,vertex.color=V(graph)$community, main="Cluster Graph") 772 chars25 lines
library(igraph) # Create a community matrix community_matrix <- matrix(c(1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1), nrow = 5, byrow = TRUE) # Create an adjacency matrix from the community matrix adjacency_matrix <- community_matrix %*% t(community_matrix) # Create an igraph graph object from the adjacency matrix graph <- graph_from_adjacency_matrix(adjacency_matrix, mode = "undirected") # Get Laplacian matrix laplacian_matrix <- laplacian_matrix(graph) # Spectral analysis eigen_values <- eigen(laplacian_matrix)$values # Create a graph plot plot(graph,vertex.color=V(graph)$community, main="Cluster Graph")
gistlibby LogSnag