
Count partitions of a graph
enum_count_partitions_graph.RdCount the number of valid partitions of an arbitrary graph into num_parts
connected subgraphs. Part sizes can be constrained either as a range via
min_size and max_size, or as an explicit set of allowed sizes via
exact_sizes. Prefer this over enum_partitions_graph() when only the
count is needed, as it avoids storing all partitions in memory.
Usage
enum_count_partitions_graph(
graph,
num_parts,
min_size = NULL,
max_size = NULL,
exact_sizes = NULL,
progress = TRUE
)Arguments
- graph
An
igraphoradjobject. Must be undirected and connected. Anadjobject is a list where elementicontains the integer indices (1-indexed) of vertices adjacent to vertexi.- num_parts
Integer. Number of parts to partition the graph into.
- min_size
Integer or
NULL. Minimum number of vertices per part. Must be supplied together withmax_size; mutually exclusive withexact_sizes.- max_size
Integer or
NULL. Maximum number of vertices per part. Must be supplied together withmin_size; mutually exclusive withexact_sizes.- exact_sizes
Integer vector or
NULL. The exact set of allowed part sizes. Mutually exclusive withmin_size/max_size.- progress
Logical. Whether to report enumeration progress. Default
TRUE.
Examples
g <- igraph::make_ring(6)
enum_count_partitions_graph(g, num_parts = 2, min_size = 3, max_size = 3)
#> ■ 0% | ETA: ?
#> ■■■■■■■■■■■ 33% | ETA: 0s
#> ■■■■■■■■■■■■■■■■■■■■■ 67% | ETA: 0s
#> [1] 3