network_centrality: Calculate tidy network centralities

View source: R/network_analysis.R

network_centralityR Documentation

Calculate tidy network centralities

Description

Calculate tidy network centralities

Usage

network_centrality(
  network,
  measures = c("degree", "strength", "betweenness", "closeness", "eigenvector",
    "pagerank"),
  directed = NULL
)

Arguments

network

A supported network representation.

measures

Centrality measures.

directed

Treat edges as directed. NULL (the default) takes it from the network's settings table, as as_igraph() does. This governs the graph conversion and the betweenness, eigenvector, and pagerank measures only; degree, strength, and closeness always combine incoming and outgoing ties. betweenness and closeness use ⁠1 / |weight|⁠ as the edge distance.

Value

A tidy base data.frame with one row per node and measure and columns node, measure, and value, stacked measure after measure. Requires the suggested igraph package.

Examples

network <- simulate_network(nodes = 30, model = "bernoulli", probability = 0.1, seed = 1)
if (requireNamespace("igraph", quietly = TRUE)) {
  head(network_centrality(network, measures = c("degree", "strength")))
}

simulab documentation built on Oct. 15, 2026, 5:08 p.m.