Skip to contents

This function identifies hub nodes in an igraph network based on degree and betweenness centrality using either z-score or quantile thresholds. Optionally, it visualizes the classification using a scatter plot with marginal histograms.

Usage

find_hubs(
  graph,
  method = c("zscore", "quantile"),
  degree_threshold = 3,
  betweenness_threshold = 1,
  degree_quantile = 0.95,
  betweenness_quantile = 0.95,
  log_transform = TRUE,
  plot = TRUE,
  focus_color = "darkgreen",
  label.size = 12,
  hub_names = TRUE,
  hub_cex = 3,
  gg_extra = list()
)

Arguments

graph

An igraph object or a data frame containing a symbolic edge list in the first two columns. Additional columns are considered as edge attributes.

method

Character. Method to identify hubs: "zscore" (standardized metrics) or "quantile" (empirical percentiles).

degree_threshold

Numeric. Threshold for standardized degree (only used if method = "zscore").

betweenness_threshold

Numeric. Threshold for standardized betweenness (only used if method = "zscore").

degree_quantile

Numeric between 0 and 1. Quantile threshold for degree (used if method = "quantile").

betweenness_quantile

Numeric between 0 and 1. Quantile threshold for betweenness (used if method = "quantile").

log_transform

Logical. If TRUE, applies log-transformation to degree and betweenness metrics.

plot

Logical. If TRUE, generates a plot of the degree vs. betweenness classification.

focus_color

Character. Color to display in the focus area of the plot (hubs region).

label.size

Numeric. Base font size for plot elements. Passed to theme_classic.

hub_names

Logical. If TRUE, adds node labels to identified hubs on the plot.

hub_cex

Numeric. Font size scaling factor for hub labels on the plot.

gg_extra

List. Additional user-defined layers for the returned ggplot. eg. list(ylim(-2,2), theme_bw(), theme(legend.position = "none"))

Value

A list with the following components:

method

Description of the method and thresholds used.

result

A tibble with node name, degree, betweenness, transformed metrics, and hub status.

graph

The original graph with a new vertex attribute is_hub.

If plot = TRUE, a scatter plot of degree vs. betweenness is displayed with hub nodes highlighted.

Examples

if (FALSE) { # \dontrun{
library(igraph)
g <- sample_pa(100)
find_hubs(g, method = "quantile", plot = TRUE)
} # }