select_k_core: Select the k-Core of a Network

View source: R/wrangle-structure.R

select_k_coreR Documentation

Select the k-Core of a Network

Description

The k-core is the maximal subgraph in which every node has degree at least k, found by repeatedly removing nodes of degree below k.

Usage

select_k_core(x, k, keep_format = FALSE, directed = NULL)

Arguments

x

Network input.

k

Integer. The core number.

keep_format

Logical. Return the input format when TRUE.

directed

Logical or NULL. If NULL (default), auto-detect.

Value

A cograph_network holding the k-core, or the input format when keep_format = TRUE. An empty network when no node reaches coreness k.

References

Seidman, S. B. (1983). Network structure and minimum degree. Social Networks, 5(3), 269–287.

See Also

select_nodes, centrality

Examples

adj <- matrix(c(0, 1, 1, 1,
                1, 0, 1, 0,
                1, 1, 0, 0,
                1, 0, 0, 0), 4, 4, byrow = TRUE)
rownames(adj) <- colnames(adj) <- c("A", "B", "C", "D")

select_k_core(adj, k = 2)

cograph documentation built on Sept. 30, 2026, 5:08 p.m.