所以我已经在csv文件中读取了我的网络数据,并通过执行以下操作将其转换为图形对象
g = read.csv"somefile.csv", header = FALSE)
G = graph.data.frame(g,directed=FALSE)
fc = cluster_fast_greedy(G)
Error in cluster_fast_greedy(G) :
At fast_community.c:639 : fast-greedy community finding works only on graphs
without multiple edges, Invalid value
非常有趣的是,我尝试直接加载graphml版本并且可以运行fast greedy
函数而没有错误。
我的问题是,如果我仅限于csv文件,我该如何运行fast_greedy函数呢?
正如错误消息所示,
快速贪婪的社区发现仅适用于没有多边的图形
但您可以使用simplify
函数删除多个边。这是一个例子。首先,我创建了一个具有多个边的图 - fastgreedy.community
失败了。但简化后,它的工作原理。
set.seed(1234)
g = erdos.renyi.game(12, 0.3)
g = add_edges(g, c(1,5, 7,10))
fastgreedy.community(g)
Error in .Call("R_igraph_community_fastgreedy", graph, as.logical(merges), :
At fast_community.c:553 : fast-greedy community finding works
only on graphs without multiple edges, Invalid value
g = simplify(g)
fastgreedy.community(g)
IGRAPH clustering fast greedy, groups: 2, mod: 0.26
+ groups:
$`1`
[1] 1 3 4 5 9 10 11
$`2`
[1] 2 6 7 8 12