igraph包的帮助文档原文:
vertex.attr.comb and/or edge.attr.comb that specify how to perform the mapping of the attributes.
默认是”sum”,比如说e->f 0.2,f->e 0.3 那么在不设置edge.attr.comb的情况下,默认e->f的权值是0.25,此时对应的是无向图。
library(igraph)
data<- read.table("G:/facebook_combined/test.txt",header = FALSE,sep=" ")#默认false,不把第一行作为列名称处理,如果为TRUE则把数据文件第一行作为列名称处理
g<- graph.data.frame(data,directed = FALSE)
g_data<- as_data_frame(g,what = c("both")) #显示所有元素
E(g)$weight<- data[,3] #给每条边赋予权重