Filter a tidygraph object by component size.

filter_component_size(.data, min_size = 0, max_size = Inf)

Arguments

.data

a tidygraph object (for use in a pipeline)

min_size, max_size

minumum and maximum sizes of components to keep (inclussive bounds)

Value

An object of the same class as .data.

Examples

gr <- tidygraph::bind_graphs(tidygraph::play_barabasi_albert(3, 2), tidygraph::play_barabasi_albert(6, 2)) igraph::count_components(gr)
#> [1] 2
new_gr <- filter_component_size(gr, min_size = 4)
#> Warning: `as_quosure()` requires an explicit environment as of rlang 0.3.0. #> Please supply `env`. #> This warning is displayed once per session.
igraph::count_components(new_gr)
#> [1] 1