as_membership: Declare a numeric vector as a membership vector

Description Usage Arguments Value Examples

View source: R/community.R

Description

This is useful if you want to use functions defined on membership vectors, but your membership vector does not come from an igraph clustering method.

Usage

1

Arguments

x

The input vector.

Value

The input vector, with the membership class added.

Examples

1
2
3
4
5
6
7
## 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)
compare(correct, membership(fc))

Example output

Attaching package: 'igraph'

The following objects are masked from 'package:stats':

    decompose, spectrum

The following object is masked from 'package:base':

    union

[1] 0
[1] 0

igraph documentation built on Oct. 15, 2021, 5:06 p.m.

Related to as_membership in igraph...