README.md

April 30, 2026 ยท View on GitHub

graph


GitHub Workflow Status Crates.io docs.rs

Hypergraph is a data structure library to generate directed hypergraphs.

A hypergraph is a generalization of a graph in which a hyperedge can join any number of vertices.

๐Ÿ“ฃ Goal

This library aims at providing the necessary methods for modeling complex, multiway (non-pairwise) relational data found in complex networks. One of the main advantages of using a hypergraph model over a graph one is to provide a more flexible and natural framework to represent entities and their relationships (e.g. Alice uses some social network, shares some data to Bob, who shares it to Carol, etc).

๐ŸŽ Features

This library enables you to represent:

  • non-simple hypergraphs with two or more hyperedges containing the exact same set of vertices
  • self-loops โ€” i.e., hyperedges containing vertices directed to themselves one or more times
  • unaries โ€” i.e., hyperedges containing a unique vertex

And to compute:

  • Graph traversal: BFS, DFS, reachability, topological sort
  • Shortest paths: Dijkstra point-to-point and single-source
  • Structural analysis: strongly connected components, weakly connected components, all simple paths, subgraph extraction, cycle detection
  • Filtered views: retain_vertices, retain_hyperedges

โš—๏ธ Implementation

  • 100% safe Rust
  • Proper error handling
  • Stable indexes for each hyperedge and each vertex โ€” identity is the index, not the weight; duplicate weights are allowed on both sides
  • Parallelism (with Rayon)
  • Optional serde support (features = ["serde"] in Cargo.toml)

๐Ÿ› ๏ธ Installation

Add this to your Cargo.toml (replace current_version with the latest version of the library):

[dependencies]
hypergraph = "current_version"

โšก๏ธ Usage

Please read the documentation to get started.