【发布时间】:2014-05-08 20:39:34
【问题描述】:
我有包含 1000 个顶点的二分列表(帖子、单词类别),我想使用快速贪心算法进行社区检测,但我不确定是否必须在二分图或二分投影上运行它。
我的二分列表如下所示:
post word
1 66 2
2 312 1
3 432 7
4 433 7
5 434 1
6 435 5
7 436 1
8 437 4
当我在没有投影的情况下运行它时,我在第二步中出现聚类问题:
### Load bipartie list and create graph ###
bipartite_list <- read.csv("bipartite_list_tnf.csv", header = TRUE, sep = ";")
bipartite_graph <- graph.incidence(bipartite_list)
g<-bipartite_graph
fc <- fastgreedy.community(g) ## communities / clusters
set.seed(123)
l <- layout.fruchterman.reingold(g, niter=1000, coolexp=0.5) ## layout
membership(fc)
# 2. checking who is in each cluster
cl <- data.frame(name = fc$post, cluster = fc$membership, stringsAsFactors=F)
cl <- cl[order(cl$cluster),]
cl[cl$cluster==1,]
# 3. preparing data for plot
d <- data.frame(l); names(d) <- c("x", "y")
d$cluster <- factor(fc$membership)
# 4. plot with only nodes, colored by cluster
p <- ggplot(d, aes(x=x, y=y, color=cluster))
pq <- p + geom_point()
pq
也许我必须对投影运行社区检测?但是我总是失败,因为投影不是图形对象:
bipartite_graph <- graph.incidence(bipartite_list)
#projection (both directions)
projection_word_post <- bipartite.projection(bipartite_graph)
fc <- fastgreedy.community(projection_word_post)
Fehler in fastgreedy.community(projection_word_post) : Not a graph object
我很乐意提供帮助!
【问题讨论】:
-
projection_word_post是两张图的列表,一张用于帖子,一张用于文字。第二个代码块到底有什么问题? -
谢谢。所以我需要像这样对特定投影进行社区检测吗?:#create graph bipartite_graph
-
第二个块调整为在 projection1 上运行的新的快速和贪婪算法的问题现在是:cl