Skip to main content

scirs2_graph/gpu/
mod.rs

1//! GPU-accelerated and parallel graph algorithms.
2//!
3//! This module provides parallel graph traversal and shortest-path algorithms
4//! designed with a GPU-ready interface. Current implementations use CPU-parallel
5//! execution via Rayon-compatible patterns and are ready to be backed by actual
6//! GPU kernels in future releases.
7//!
8//! # Algorithms
9//!
10//! - [`algorithms::gpu_bfs`] — Parallel BFS (level-synchronous, frontier-based)
11//! - [`algorithms::gpu_sssp_bellman_ford`] — Bellman-Ford SSSP (GPU-friendly, detects
12//!   negative cycles)
13//! - [`algorithms::gpu_sssp_delta_stepping`] — Delta-stepping SSSP (highly parallel,
14//!   better cache behavior than Dijkstra)
15//!
16//! # Graph Format
17//!
18//! Algorithms in this module accept graphs in **Compressed Sparse Row (CSR)** format
19//! for BFS/Bellman-Ford, or adjacency-list format for delta-stepping. CSR is the
20//! preferred format for GPU workloads due to coalesced memory access.
21//!
22//! ```rust,no_run
23//! use scirs2_graph::gpu::algorithms::{gpu_bfs, GpuBfsConfig};
24//!
25//! // 3-node path: 0 -> 1 -> 2
26//! let row_ptr = vec![0, 1, 2, 2];
27//! let col_idx = vec![1, 2];
28//! let config = GpuBfsConfig::default();
29//! let dist = gpu_bfs(&row_ptr, &col_idx, 0, &config).expect("bfs failed");
30//! assert_eq!(dist[0], 0);
31//! assert_eq!(dist[1], 1);
32//! assert_eq!(dist[2], 2);
33//! ```
34
35pub mod algorithms;
36
37pub use algorithms::{
38    gpu_bfs, gpu_sssp_bellman_ford, gpu_sssp_delta_stepping, GpuBfsConfig, GpuGraphBackend,
39};