Skip to main content

Module graph

Module graph 

Source
Expand description

Minimal graph adapter traits.

Every operator in this crate is generic over one of these traits, so callers can plug in any representation that exposes node count and a neighbor query. Four traits cover the product of two axes: owned vs borrowed neighbor lists, unweighted vs weighted edges.

UnweightedWeighted
Owned VecGraphWeightedGraph
Borrowed sliceGraphRefWeightedGraphRef

Pick the owned variant for ease of implementation; pick the borrowed variant when the operator runs in a tight loop (random walks, message passing) and neighbor-list allocation would dominate.

Structs§

AdjacencyMatrix
Row-major adjacency-matrix adapter.
PetgraphRef
Pre-built adjacency list adapter for petgraph graphs. Converts a petgraph graph into a structure implementing GraphRef by pre-computing neighbor lists.

Traits§

Graph
Owned-neighbor graph adapter. The simplest adapter to implement — each neighbors(node) call returns a fresh Vec.
GraphRef
Graph view that returns borrowed neighbor slices, avoiding per-query allocation.
WeightedGraph
Graph with scalar f64 edge weights.
WeightedGraphRef
Weighted graph view returning borrowed (neighbors, weights) slice pairs.