Skip to contents

This function compares two networks using summary metrics, degree distributions, and topological similarity measures. It overlays the complementary cumulative frequency distributions (CCDFs) of degree and returns a combined report.

Usage

compare_networks(
  graph1,
  graph2,
  remove_singles = FALSE,
  show_PL = TRUE,
  PL_exponents = c(2, 3),
  colors = c("#e41a1c", "#000831", "#9c52f2", "#b8b8ff"),
  label.size = 12
)

Arguments

graph1

An igraph object or data.frame (edge list).

graph2

An igraph object or data.frame (edge list).

remove_singles

Logical; remove single nodes before analysis.

show_PL

Logical; whether to fit and display power law exponents.

PL_exponents

Vector; power-law slopes to show.

colors

Optional vector of colors for the CCDF plot.

label.size

Labels' size in the CCDF plot.

Value

A list with:

  • metrics1: Summary metrics for graph1

  • metrics2: Summary metrics for graph2

  • CCDF_plot: ggplot overlay of ccdfs

  • jaccard_similarity: Jaccard index of edge sets

  • node_overlap: Fraction of shared nodes

  • edge_overlap: Fraction of shared edges

  • ks_test: KS test result for degree distributions

Examples

if (FALSE) { # \dontrun{
library(igraph)
g1 <- sample_pa(100)
g2 <- sample_gnp(100, 0.05, directed = F)
compare_networks(g1, g2)
} # }