This function converts a vector of memberships into a proper vertex partition object.

as_vertex_partition(x)

Arguments

x

A list grouping the vertices by partition element or an integer or character vector of vertex memberships.

Value

A vertex_partition object storing the corresponding vertex partition.

Examples

m1 <- c("P1", "P3", "P4", "P1", "P2", "P2", "P3", "P1", "P4", "P3")
V1 <- as_vertex_partition(m1)
m2 <- as.integer(c(1, 3, 4, 1, 2, 2, 3, 1, 4, 3))
V2 <- as_vertex_partition(m2)