knitr::opts_chunk$set( collapse = TRUE, eval=TRUE, comment = "#>" )
This is the first version of the graphcluster package. This vignette provides a guideline for using this package.
library(graphcluster) library(stringr) library(igraph)
graphcluster requires inputting the dataset in the form of a dataframe or a matrix
data(iris) data=iris[,-5] ann=iris[,5] names(ann)<-rownames(data) f=factor(ann) ann=as.numeric(f)
Call the parallel_cluster function with suitable parameters. The following is an example:
system.time(elist_p<-parallel_cluster(5,50,4,data,0.65))
After all iterations are over, make graphs for the points that were not sampled even once. A sample code is as follows:
l=length(elist_p) l sub=as.character("",l*2) for(i in 1:l) { sub[i]=word(elist_p[i]) sub[i+l]=word(elist_p[i],2) } usub=unique(sub) if(length(usub)!=nrow(data)) { reducedbench_data <- data[!(rownames(data) %in% usub),] system.time(elist_p1<-parallel_cluster(1,nrow(reducedbench_data),4,reducedbench_data,0.65)) elist_p=append(elist_p,elist_p1) } elist_p2=append(elist_p,elist_p1) system.time(K<-graphcommunity(elist_p, ann))
```r mygr=K$graph table(data.frame("PREDICT" = K$comm$membership,"TRUE" = V(mygr)$color))
V(mygr)$color = K$comm$membership
set.seed(555)
plot(K$comm,mygr,vertex.size=5, vertex.label=NA,edge.color=NA)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.