Skip to contents

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")
}
#>        measure  method correlation      mae nodes
#> degree  degree pearson  0.03088574 2.866667    30