Skip to contents

Identifies bottleneck nodes in an igraph network as those with low degree and high betweenness centrality. The function supports both standardized (z-score) and quantile-based thresholding. Optionally, it produces a 2D scatter plot with bottlenecks highlighted.

Usage

find_bottlenecks(
  graph,
  method = c("zscore", "quantile"),
  degree_threshold = -1,
  betweenness_threshold = 1,
  degree_quantile = 0.25,
  betweenness_quantile = 0.75,
  log_transform = TRUE,
  plot = TRUE,
  focus_color = "skyblue",
  bottleneck_names = TRUE,
  bottleneck_cex = 3,
  gg_extra = list()
)

Arguments

graph

An igraph object representing the network to analyze 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 define bottlenecks: "zscore" or "quantile".

degree_threshold

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

betweenness_threshold

Numeric. Lower threshold for standardized betweenness (used in both methods).

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 log1p transformation to degree and betweenness.

plot

Logical. If TRUE, generates a plot of degree vs. betweenness highlighting bottlenecks.

focus_color

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

bottleneck_names

Logical. If TRUE, labels bottleneck nodes on the plot.

bottleneck_cex

Numeric. Font size scaling for bottleneck 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

A message describing the method and thresholds used.

result

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

graph

The original graph with a new vertex attribute bottleneck (logical).

If plot = TRUE, a scatter plot of degree vs. betweenness is displayed, highlighting bottlenecks.

Examples

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