Skip to content

Simulation and analysis of network robustness under node removal strategies. Includes standard centrality-based attacks and entanglement-based robustness using mutual information profiles. Provides tools to generate synthetic networks, compute robustness curves, and visualize critical thresholds.

License

Notifications You must be signed in to change notification settings

CoMuNeLab/RobustnessProfiles

Repository files navigation

networkRobustness

Robustness profiles and visualization for complex networks.
Simulate static node failures (random or targeted by centrality/entanglement), aggregate across many network realizations, and produce ribbons + critical-fraction bar plots.


Repository layout

R/
  critical_points.R            # pc computation (critical fractions)
  Graphics.R                   # palettes, multiplot, helpers
  io_profiles.R                # read/write helpers for robustness profiles
  labels.R                     # model/measure pretty names
  networkRobustness-package.R  # package docs
  plots.R                      # plotting helpers (ribbons, bars)
  Robustness.R                 # core robustness simulation API
  zzz.R                        # package init

inst/scripts/
  batch_entanglement_profiles.R          # build entanglement robustness from MI profiles
  build_profiles.R                        # aggregate+plot standard measures
  build_profiles_with_entanglement.R      # aggregate+plot (standard + entanglement)
  generate_proxy_MI_profiles.R            # optional: (re)generate MI profiles (proxy)
  generate_synthetic_networks_and_profiles.R # generate synthetic networks + standard profiles

Installation

# from a clean R session
install.packages(c(
  "igraph","ggplot2","ggraph","gplots","RColorBrewer","ggsci"
))

# install devtools if needed
if (!requireNamespace("devtools", quietly = TRUE)) install.packages("devtools")

# install this package from your local checkout
devtools::document()   # generate Rd docs
devtools::install()    # install networkRobustness
devtools::check()      # optional: run R CMD check (should pass cleanly)

# run unit tests (optional)
devtools::test()

Note: We target igraph >= 2.0. The code already uses the non-deprecated API (e.g., delete_vertices(), components()).


Data directories expected by the scripts

Scripts assume a project root working directory with the following (created or to be created):

<project root>/
  ER_N256/       BA_N256/      WS_N256/      RGG_N256/      SBM4_N256/      HSBM4_N256/
    <MODEL>_r<ID>.edges             # undirected edgelist, 0-based node ids
    <MODEL>_r<ID>_robustness.csv    # (standard measures; created by generate_* script)
  Entanglement/
    <MODEL>_N256/
      <MODEL>_r<ID>_MI-profile.csv[.gz]    # MI profiles (inputs for entanglement)
      <MODEL>_r<ID>_robustness.csv         # entanglement robustness (output)
  • Edgelists in <MODEL>_N256/ use 0-based node labels; scripts shift them to 1..N internally.
  • MI profiles may be gzipped (.csv.gz). Scripts accept both .csv and .csv.gz.

What each script does (and in what order to run)

0) Quick glossary

  • Standard measures: degree, betweenness, PageRank, eigenvector, coreness, clustering, plus random.
  • Entanglement: the MI-based ranking read from *_MI-profile.csv(.gz) (we pick the β* that minimizes mean entropy).

1) Generate synthetic networks + standard robustness (optional)

Rscript "$(Rscript -e 'cat(system.file("scripts","generate_synthetic_networks_and_profiles.R", package="networkRobustness"))')"

Inputs: none (networks are generated).
Outputs: in each <MODEL>_N256/ folder: - <MODEL>_r<ID>.edges - <MODEL>_r<ID>_robustness.csv (standard measures only)

If you already have <MODEL>_N256/*.edges and standard *_robustness.csv, you can skip this step.


2) Provide (or generate) MI entanglement profiles

If you already have MI profiles: place them under Entanglement/<MODEL>_N256/ as <MODEL>_r<ID>_MI-profile.csv or <MODEL>_r<ID>_MI-profile.csv.gz.

If you need to (re)generate proxy MI profiles:

Rscript "$(Rscript -e 'cat(system.file("scripts","generate_proxy_MI_profiles.R", package="networkRobustness"))')"

Outputs: Entanglement/<MODEL>_N256/<MODEL>_r<ID>_MI-profile.csv.gz (or .csv).


3) Build entanglement robustness from MI profiles

Rscript "$(Rscript -e 'cat(system.file("scripts","batch_entanglement_profiles.R", package="networkRobustness"))')"

Inputs: - Entanglement/<MODEL>_N256/<MODEL>_r<ID>_MI-profile.csv[.gz] - <MODEL>_N256/<MODEL>_r<ID>.edges

Outputs: - Entanglement/<MODEL>_N256/<MODEL>_r<ID>_robustness.csv (with centr = "ent")


4) Aggregate + plot (standard measures only)

Rscript "$(Rscript -e 'cat(system.file("scripts","build_profiles.R", package="networkRobustness"))')"

Outputs: synth_robustness_standard.png


5) Aggregate + plot (standard + entanglement), legacy style

Rscript "$(Rscript -e 'cat(system.file("scripts","build_profiles_with_entanglement.R", package="networkRobustness"))')"

Outputs: synth_robustness_with_bars.png


Troubleshooting

  • Ensure files are named <MODEL>_r<ID>_MI-profile.csv or .csv.gz exactly.\
  • Check robustness CSVs have a centr column (older may use attack).\
  • Missing entanglement = missing robustness files in Entanglement/….\
  • Differences in RGG/SBM curves usually mean different β* selected.

Minimal R example

library(igraph)
library(networkRobustness)

set.seed(1)
g <- sample_gnp(100, 0.05)

deg <- igraph::degree(g)
prof_deg <- getStaticFailureProfile(g, deg, attack = "deg")
prof_rnd <- getStaticFailureProfile(g, NULL, attack = "random", MC = 10)

head(prof_deg)
head(prof_rnd)

License

MIT © Authors.

Issues: https://github.com/CoMuNeLab/RobustnessProfiles/issues

About

Simulation and analysis of network robustness under node removal strategies. Includes standard centrality-based attacks and entanglement-based robustness using mutual information profiles. Provides tools to generate synthetic networks, compute robustness curves, and visualize critical thresholds.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages