Expand description
Dense integer adjacency-matrix constructor (ALGO-CN-029).
Counterpart of igraph_adjacency() in
references/igraph/src/constructors/adjacency.c:335-386.
Builds a Graph from a square n × n integer matrix whose
entries are edge multiplicities (non-negative). The shape of the
resulting graph (directed / undirected, which triangle drives the
edge count, how the diagonal becomes self-loops) is controlled by
two enums:
AdjacencyMode— one of seven dispatch flavours (Directed,Undirected,Max,Min,Plus,Upper,Lower).LoopsMode— how to interpret the diagonal:NoLoopszeroes it,OncetreatsA(i,i)as the loop count,Twicetreats it as twice the loop count (must be even).
For consistency with upstream igraph the Twice request is silently
collapsed to Once for the Directed, Upper and Lower modes —
the matrix only stores one copy of each loop in those layouts.
Matrix layout: &[&[i64]] — a slice of equal-length rows in
row-major form. Every row must have the same length as the outer
slice; ragged input is rejected. A 0 × 0 matrix produces an empty
graph (matching the C semantics for an IGRAPH_MATRIX_NULL of
shape 0 × 0).
Time complexity: O(|V|² + |E|).
Enums§
- Adjacency
Mode - How to interpret the input matrix as an adjacency matrix.
- Loops
Mode - How to convert diagonal entries into self-loops.
Functions§
- adjacency
- Build a graph from a dense integer adjacency matrix.