R: plot larger components (clarifying another stackoverflow post)

点点圈 提交于 2021-01-05 07:16:05

问题


I am looking at this stackoverflow plot over here: How to plot only large communities/clusters in R

library(igraph)
set.seed(1)
g1 <- erdos.renyi.game(100, 1 / 70)
cls <- clusters(g1)
g2 <- delete_vertices(g1, V(g1)[cls$membership %in% which(cls$csize <= 10)])
plot(g2)

It seems that first a random graph is created (called "g1"). Then the "cluster()" function is used to find out "isolated subgraphs" of "g1". All the "isolated subgraphs of g1" are stored in another object called "cls". The user than makes a request to plot only the "isolated subgraphs" with more than 10 nodes. Is my understanding correct? (is a "cluster" the same as an "isolated subgraph"?)

Can someone please tell me:

  1. How many clusters (i.e. isolated subgraphs) are created? I am trying to find out a list of "each cluster produced, as well the size of each of these clusters" - how do you access this by writing R code?

  2. How do you plot just one of these clusters? E.g. I tried the following code: plot(cls[1], g1) but I got an error: Error in xy.coords(x, y, xlabel, ylabel, log) : 'x' and 'y' lengths differ

Can someone please help me here?

Thanks

Thanks

来源:https://stackoverflow.com/questions/65016504/r-plot-larger-components-clarifying-another-stackoverflow-post

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!