Skip to main content

Module bridge

Module bridge 

Source
Expand description

Graph <-> matrix conversions: adjacency (boolean, min-plus, sparse), incidence, and Laplacian, with explicit multiedge policies and a mapping witness.

Bridge matrices omit graph self-loops. This keeps adjacency, incidence, and Laplacian exports aligned with the simple-graph matrix contract while preserving the original graph value unchanged.

Structs§

GraphMatrixMap
Mapping metadata recording how graph elements landed in the matrix.

Enums§

MultiedgePolicy
How to collapse parallel edges between the same endpoints into one cell.

Functions§

graph_to_bool_adjacency
Boolean adjacency: true where at least one non-self-loop edge connects the pair.
graph_to_incidence
Incidence matrix as a sparse IntRing matrix. Directed: -1 at the source, +1 at the target. Undirected: +1 at both endpoints. One column per non-self-loop edge.
graph_to_laplacian
Unweighted graph Laplacian L = D - A over IntRing, ignoring self-loops. For an undirected graph each row sums to zero.
graph_to_minplus_adjacency
Min-plus weighted adjacency (Inf = no non-self-loop edge), applying a multiedge policy.
graph_to_sparse_adjacency
Sparse min-plus weighted adjacency, applying a multiedge policy and omitting self-loops.
minplus_adjacency_to_graph
Reconstruct a graph from a min-plus adjacency matrix (Inf = no edge). Node labels are their indices. Directedness is supplied by the caller.