简体   繁体   English

您如何规定顶点在igraph中的位置?

[英]How do you dictate the position of the vertices in igraph?

I want to show how a social network changes over time. 我想展示一下社交网络如何随着时间变化。 I'm using igraph. 我正在使用igraph。

The problem is that each time I create a graph representation of a time period within the social network, the program puts the vertices into a different position for each created graph. 问题是,每次我在社交网络中创建时间段的图形表示时,程序都会为每个创建的图形将顶点放置在不同的位置。 This is problem because I'm trying to show how social network groups continue/discontinue over time. 这是有问题的,因为我试图显示社交网络组如何随着时间继续/停止。

I've tried dictating the position of the vertices by typing l<-layout.fruchterman.reingold(g) then using layout=l for each subsequent graph I create. 我尝试通过输入l<-layout.fruchterman.reingold(g)来指定顶点的位置,然后为我创建的每个后续图形使用layout=l However, I get an error message that looks like this: 但是,我收到一条错误消息,如下所示:

Error in layout[v, , drop = FALSE] : subscript out of bounds

Here's the code I am using: 这是我正在使用的代码:

    require(igraph)
cat<-read.csv(file="Bigplayers_3_36505-36605 - Copy.csv",header=F,sep=",")
cat<-as.matrix(cat)
set.seed(230)
g <- graph.adjacency(cat, weighted=T, mode = "undirected")
g2<-V(g)[degree(g)<1]
g<-delete.vertices(g,g2)
fg<-cluster_fast_greedy(g,merges=T,modularity=T,membership=T)
colors<-rainbow(max(membership(fg)))
V(g)$label<-V(g)$name
plot(g,vertex.size=10,vertex.color=colors[membership(fg)],mark.groups=communities(fg),layout=layout.fruchterman.reingold, main='Enron Email Dataset', vertex.label.dist=0.5, vertex.frame.color='blue', vertex.label.color='black', vertex.label.font=1)

Here are two datasets that represent the same vertices over different time frames: here and here 这是两个表示不同时间范围内相同顶点的数据集: 此处此处

To solve this problem, I had to get rid of the lines 为了解决这个问题,我不得不摆脱界限

g2<-V(g)[degree(g)<1]
g<-delete.vertices(g,g2)

With these lines gone, vertices stay in the same position no matter which dataset I use. 随着这些线的消失,无论我使用哪个数据集,顶点都将停留在相同的位置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM