Module pool

Module pool 

Source
Expand description

Memory pools for BFS and graph traversal allocations

Provides reusable memory pools to reduce allocation overhead during repeated BFS/DFS operations in minimum cut algorithms.

§Overview

Graph algorithms like BFS perform many allocations:

  • Queue for vertices to visit
  • HashSet/BitSet for visited vertices
  • Vec for collecting results

By reusing these structures, we avoid repeated allocation/deallocation overhead, which can be significant for algorithms that perform many traversals.

§Thread Safety

The pools use thread-local storage for zero-contention access. Each thread gets its own pool of resources.

§Example

use ruvector_mincut::pool::BfsPool;

// Acquire resources from the pool
let mut resources = BfsPool::acquire(256);

// Use resources for BFS
resources.queue.push_back(0);
resources.visited.insert(0);

// Clear and return to pool automatically when dropped
drop(resources);

Structs§

BfsPool
Pool for BFS memory allocation
BfsResources
BFS resources acquired from the pool
CompactBfsResources
Compact bitset pool for small graphs
DistanceBfsResources
Pool for distance-annotated BFS