Label Propagation for hypergraphs across multiple backends: OpenMP (CPU and offload), SYCL, Kokkos, and CUDA. A unified CLI configures generators, algorithm limits, labels, and binary I/O.
- Implementations: OpenMP, SYCL, Kokkos, and CUDA.
- Unified CLI via cxxopts for all backends.
- Built‑in random hypergraph generators: uniform, fixed (a.k.a. d‑uniform ER), planted partition, and hSBM.
- Binary save/load for reproducible experiments.
include/ # Public headers (Hypergraph, generators, CLI options)
src/common/ # Shared hypergraph + generators + CLI parsing
src/openmp/ # OpenMP implementation + entry point
src/sycl/ # SYCL implementation + entry point
src/kokkos/ # Kokkos implementation + entry point
src/cuda/ # CUDA implementation + entry point
Prereqs
- CMake ≥ 3.16
- C++17 compiler
- Optional: SYCL toolchain; Kokkos installation; CUDA Toolkit 11+
Configure + build (OpenMP)
mkdir build && cd build
cmake -DBUILD_OPENMP=ON ..
cmake --build . -jOther backends
- SYCL:
cmake -DBUILD_SYCL=ON -DSYCL_TARGETS="spir64,nvptx64-nvidia-cuda" .. && cmake --build . -j - Kokkos:
cmake -DBUILD_KOKKOS=ON -DKokkos_ROOT=/path/to/kokkos .. && cmake --build . -j - CUDA:
cmake -DBUILD_CUDA=ON -DOFFLOAD_TARGET=sm_80 .. && cmake --build . -j
Install
cmake --install . --prefix ./installGeneral
--vertices, -vnumber of vertices (default 1000)--edges, -enumber of hyperedges (default 5000)--iterations, -imax iterations (default 100)--tolerance, -tconvergence tolerance (default 1e-6)--threads, -pOpenMP threads (0=auto)--seedRNG seed for graph (0=nondeterministic)
Labels
--label-classesnumber of classes to assign randomly (0=skip)--label-seedRNG seed for labels (0=nondeterministic)
I/O
--load <file>load a hypergraph from file (binary or JSON)--save <file>save the generated/loaded hypergraph to binary
Generator selection
--generator {uniform|fixed|planted|hsbm}or shortcuts--uniform,--fixed,--planted,--hsbm
Generator parameters
- uniform:
--min-edge-size,--max-edge-size - fixed:
--edge-size(d‑uniform ER G^(d)(n,m) is equivalent to fixed with edge‑size=d) - planted:
--communities,--p-intra,--min-edge-size,--max-edge-size - hsbm:
--communities,--p-intra,--p-inter,--min-edge-size,--max-edge-size
Help/Version
--help,--version
Examples
# OpenMP: uniform generator
./label_propagation_openmp \
--uniform -v 1000 -e 5000 --min-edge-size 2 --max-edge-size 6 \
--iterations 100 --tolerance 1e-6 --threads 0 --save data/uniform.bin
# Fixed (aka d-uniform ER with d=4)
./label_propagation_openmp --fixed -v 2000 -e 10000 --edge-size 4
# Planted partition
./label_propagation_openmp --planted -v 4000 -e 20000 \
--communities 8 --p-intra 0.85 --min-edge-size 2 --max-edge-size 5
# hSBM with explicit inter probability
./label_propagation_openmp --hsbm -v 5000 -e 20000 \
--communities 10 --p-intra 0.9 --p-inter 0.05 --min-edge-size 3 --max-edge-size 6
# Load from file and re-label
./label_propagation_openmp --load data/uniform.bin --label-classes 6 --label-seed 42
# Load from JSON
./label_propagation_openmp --load data/graph.json- uniform: Edge sizes sampled uniformly in
[min-edge-size, max-edge-size]; vertices chosen uniformly without replacement. - fixed: All edges have exactly
edge-sizevertices. Equivalent to d‑uniform ER when you view edges as uniform d‑subsets. - planted: Partition vertices into
communities. For each edge, sample size in range; with probabilityp-intra, draw mostly from a single community (fill from outside if needed); otherwise mix across communities. - hSBM: Rejection sampling. For a random k‑set, accept with
p-intraif all vertices are in the same community; otherwise withp-inter. Edge size k sampled in range.
Saved via --save and loaded via --load (little‑endian):
- uint32 magic:
HGR1 - uint32 version:
1 - uint64
num_vertices - uint64
num_edges - For each edge: uint64
edge_size, followed byedge_sizex uint64 vertex ids - uint8
has_labels - If
has_labels:num_verticesx int32 labels
--load also accepts a simple JSON file with this schema:
{
"num_vertices": <number>,
"edges": [[v0, v1, ...], [ ... ], ...],
"labels": [l0, l1, ..., l_{num_vertices-1}] // optional
}
Notes:
- Keys can appear in any order;
edgesmay also be underhyperedges. num_verticesmust be > 0; each edge must be non-empty; iflabelsis present its size must equalnum_vertices.
Alternatively, a richer schema is supported (commonly used in hypergraph tools):
{
"type": "hypergraph",
"hypergraph-data": { "name": "..." },
"node-data": {
"1": { "name": "..." },
"2": { "name": "..." }
},
"edge-dict": {
"0": ["1", "2"],
"1": ["2", "3"]
}
}
Rules for this schema:
- Node ids are strings; they are mapped to contiguous 0..N-1 in the order first seen.
- Vertices are the union of ids from
node-datakeys and all ids appearing inedge-dictarrays. - Each edge’s array must be non-empty. Labels are optional and, if provided separately as
labels, must match the vertex count.
- Per iteration, each vertex adopts the label maximizing the weighted count from incident hyperedges (weight 1/edge_size per neighbor occurrence).
- Stop when the fraction of label changes drops below tolerance or after
--iterations.
- OpenMP target offload path uses a flattened hypergraph representation for device access.
benchmark.shcontains simple driver samples for quick runs.
Apache 2.0. See LICENSE.