robustness: Network Robustness Analysis

View source: R/robustness.R

robustnessR Documentation

Network Robustness Analysis

Description

Performs a targeted attack or random failure analysis on a network, calculating the size of the largest connected component after sequential vertex or edge removal.

In a targeted attack, vertices are sorted by degree or betweenness centrality (or edges by betweenness), and successively removed from highest to lowest. In a random failure analysis, vertices/edges are removed in random order.

Usage

robustness(
  x,
  type = c("vertex", "edge"),
  measure = c("betweenness", "degree", "random"),
  strategy = c("sequential", "static"),
  n_iter = 1000,
  mode = "all",
  seed = NULL,
  ...
)

Arguments

x

Network input: matrix, igraph, network, cograph_network, or tna object

type

Character string; either "vertex" or "edge" removals. Default: "vertex"

measure

Character string; sort by "betweenness", "degree", or "random". Default: "betweenness"

strategy

Character string; "sequential" (default) recalculates centrality after each removal. "static" computes centrality once on the original network and removes nodes in that fixed order (brainGraph-style). Only affects targeted attacks; random removal is unaffected.

n_iter

Integer; number of iterations for random analysis. Default: 1000 (matching brainGraph convention)

mode

For directed networks: "all", "in", or "out". Default "all".

seed

Random seed for reproducibility. Default NULL.

...

Additional arguments passed to to_igraph

Details

Three attack strategies are available:

Targeted Attack - Betweenness (default): Vertices/edges are sorted by betweenness centrality and removed from highest to lowest. This targets nodes that bridge different network regions.

Targeted Attack - Degree: Vertices are sorted by degree and removed from highest to lowest. This targets highly connected hub nodes. Note: for edge attacks, degree is not available; use betweenness instead.

Random Failure: Vertices/edges are removed in random order, averaged over n_iter iterations. This simulates random component failures.

Strategy: The strategy parameter controls how targeted attacks work:

  • "sequential" (default): Recalculates centrality after each removal. This is a stronger attack because removing a hub changes which nodes become the new bridges/hubs.

  • "static": Computes centrality once on the original network and removes nodes in that fixed order (as in brainGraph). This matches the original Albert et al. (2000) method.

Scale-free networks are typically robust to random failures but vulnerable to targeted attacks, while random networks degrade more uniformly.

Value

A data frame (class "cograph_robustness") with columns:

removed_pct

Fraction of vertices/edges removed (0 to 1)

comp_size

Size of largest component after removal

comp_pct

Ratio of component size to original maximum

measure

Attack strategy used

type

Type of analysis (vertex or edge removal)

References

Albert, R., Jeong, H., & Barabasi, A.L. (2000). Error and attack tolerance of complex networks. Nature, 406, 378-381. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1038/35019019")}

See Also

plot_robustness, robustness_auc

Examples

# Create a scale-free network
if (requireNamespace("igraph", quietly = TRUE)) {
  g <- igraph::sample_pa(50, m = 2, directed = FALSE)

  # Targeted attack by betweenness
  rob_btw <- robustness(g, measure = "betweenness")

  # Targeted attack by degree
  rob_deg <- robustness(g, measure = "degree")

  # Random failure
  rob_rnd <- robustness(g, measure = "random", n_iter = 50)

  # View results
  head(rob_btw)
}


cograph documentation built on April 1, 2026, 1:07 a.m.