compare_centralities: Compare node centralities between two networks

View source: R/network_analysis.R

compare_centralitiesR Documentation

Compare node centralities between two networks

Description

Compare node centralities between two networks

Usage

compare_centralities(
  x,
  y,
  measures = c("degree", "betweenness", "closeness"),
  method = c("pearson", "spearman", "kendall"),
  directed = NULL
)

Arguments

x, y

Supported network representations.

measures

Centralities passed to network_centrality().

method

Correlation method.

directed

Treat networks as directed. NULL (the default) takes it from each network's settings table.

Value

A tidy base data.frame with one row per measure and columns measure, method, correlation, mae, and nodes. Nodes present in only one network contribute a centrality of zero to the other. correlation is NA when either set of centralities has no variance. Requires the suggested igraph package.

Examples

a <- simulate_network(nodes = 30, model = "bernoulli", probability = 0.1, seed = 1)
b <- simulate_network(nodes = 30, model = "bernoulli", probability = 0.1, seed = 2)
if (requireNamespace("igraph", quietly = TRUE)) {
  compare_centralities(a, b, measures = "degree")
}

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