The goal of ‘rSpectral’ is to make Spectral Modularity graph clustering method available to most of R graph frameworks.
You can install the development version of rSpectral from GitHub with:
# install.packages("devtools")
::install_github("cmclean5/rSpectral") devtools
This is a basic example which shows you how to solve a common problem
library(rSpectral)
library(igraph)
#>
#> Attaching package: 'igraph'
#> The following objects are masked from 'package:stats':
#>
#> decompose, spectrum
#> The following object is masked from 'package:base':
#>
#> union
data(karate, package="igraphdata")
<-layout_nicely(karate)
l<-V(karate)$Faction
memT<- rainbow(max(as.numeric(memT)))
palette plot(karate,vertex.color=palette[memT],layout=l)
<-igraph::membership(rSpectral::spectral_igraph_communities(karate)) mem0
<- rainbow(max(as.numeric(mem0)))
palette plot(karate,vertex.color=palette[mem0],layout=l)
<-igraph::membership(
mem1::spectral_igraph_communities(karate, fix_neig=1)) rSpectral
<- rainbow(max(as.numeric(mem1)))
palette plot(karate,vertex.color=palette[mem1],layout=l)
.5<-igraph::membership(
mem1::spectral_igraph_communities(karate, fix_neig=1,Cn_min=5)) rSpectral
<- rainbow(max(as.numeric(mem1.5)))
palette plot(karate,vertex.color=palette[mem1.5],layout=l)
GraphNEL
objects could be processed similarily, all
other graph types could be converted either to igraph
or to
GraphNEL
by packages such as Intergraph
.