Module graph

Module graph 

Source
Expand description

Graph construction and analysis with cache-optimized CSR representation.

This module provides high-performance graph algorithms built on top of Compressed Sparse Row (CSR) format for maximum cache locality. Key features:

  • CSR representation (50-70% memory reduction vs HashMap)
  • Centrality measures (degree, betweenness, PageRank)
  • Parallel algorithms using Rayon
  • Numerical stability (Kahan summation in PageRank)

§Examples

use aprender::graph::Graph;

let mut g = Graph::new(false); // undirected graph
g.add_edge(0, 1, None).unwrap();
g.add_edge(1, 2, None).unwrap();
g.add_edge(2, 0, None).unwrap();

let dc = g.degree_centrality();
assert_eq!(dc.len(), 3);

Structs§

Edge
Graph edge with optional weight.
Graph
Graph structure using CSR (Compressed Sparse Row) for cache efficiency.

Type Aliases§

NodeId
Graph node identifier (contiguous integers for cache efficiency).