scirs2_graph/hypergraph/mod.rs
1//! Hypergraph algorithms and simplicial complexes.
2//!
3//! This module provides four sub-modules:
4//!
5//! | Sub-module | Contents |
6//! |---|---|
7//! | [`core`] | Core data structures: [`IndexedHypergraph`], generic [`Hypergraph<N,E>`], clique/star/bipartite expansions |
8//! | [`algorithms`] | Spectral clustering, hyperedge cuts, stationary distribution, betweenness centrality, s-walks |
9//! | [`simplicial`] | [`SimplicialComplex`], boundary matrices, Betti numbers, Vietoris-Rips/Čech/nerve complexes |
10//! | [`higher_order`] | [`MotifTensor`], topological features, [`CellularSheaf`] and Hodge Laplacian |
11//!
12//! # Quick Start
13//!
14//! ```rust
15//! use scirs2_graph::hypergraph::{IndexedHypergraph, clique_expansion, SpectralClusteringResult};
16//! use scirs2_graph::hypergraph::{SimplicialComplex, CellularSheaf};
17//!
18//! // Build a hypergraph
19//! let mut hg = IndexedHypergraph::new(5);
20//! hg.add_hyperedge(vec![0,1,2], 1.0).unwrap();
21//! hg.add_hyperedge(vec![2,3,4], 1.0).unwrap();
22//!
23//! // Clique expansion → ordinary graph
24//! let g = clique_expansion(&hg);
25//! assert_eq!(g.node_count(), 5);
26//!
27//! // Simplicial complex topology
28//! let mut sc = SimplicialComplex::new();
29//! sc.add_simplex(vec![0,1,2]);
30//! let betti = sc.betti_numbers();
31//! assert_eq!(betti[0], 1); // connected
32//! ```
33
34pub mod algorithms;
35pub mod attention;
36pub mod core;
37pub mod edge_prediction;
38pub mod higher_order;
39pub mod neural;
40pub mod simplicial;
41
42// Core structures and free functions
43pub use core::{
44 clique_expansion, hyperedge_centrality, hypergraph_clustering_coefficient,
45 hypergraph_random_walk, hypergraph_random_walk_seeded, line_graph, Hyperedge, Hypergraph,
46 IndexedHypergraph,
47};
48
49// Algorithms
50pub use algorithms::{
51 betweenness_centrality as hypergraph_betweenness_centrality, hyperedge_cut,
52 s_betweenness_centrality, s_diameter, s_distance, s_reachability, spectral_clustering,
53 stationary_distribution, CutResult, SpectralClusteringResult,
54};
55
56// Simplicial complexes
57pub use simplicial::SimplicialComplex;
58
59// Higher-order analysis
60pub use higher_order::{
61 directed_motif_tensor, trivial_sheaf_from_graph, CellularSheaf, MotifTensor,
62 TopologicalFeatures,
63};