跳到内容

如果您想使用在成员向量上定义的函数,但您的成员向量不是来自igraph聚类方法,这将非常有用。

用法

as_membership(x)

参数

x

输入向量。

输入向量,添加了membership类。

示例

## Compare to the correct clustering
g <- (make_full_graph(10) + make_full_graph(10)) %>%
  rewire(each_edge(p = 0.2))
correct <- rep(1:2, each = 10) %>% as_membership()
fc <- cluster_fast_greedy(g)
compare(correct, fc)
#> [1] 0
compare(correct, membership(fc))
#> [1] 0