pub fn weighted_biadjacency(
matrix: &[&[f64]],
directed: bool,
mode: BipartiteMode,
) -> IgraphResult<WeightedBiadjacencyResult>Expand description
Build a bipartite graph from a weighted biadjacency matrix.
The matrix has n1 rows and n2 columns. The resulting graph has
n1 + n2 vertices: vertices [0, n1) correspond to rows (partition 1)
and vertices [n1, n1+n2) correspond to columns (partition 2).
Each non-zero entry in the matrix produces one edge (or two mutual
edges when directed = true and mode = All) whose weight equals
the matrix entry value.
§Parameters
matrix— row-majorn1 × n2weighted biadjacency matrix (all rows must have equal lengthn2).directed— whether the resulting graph is directed.mode— edge direction policy (only meaningful whendirected = true):BipartiteMode::Out— arcs from rows to columns.BipartiteMode::In— arcs from columns to rows.BipartiteMode::All— mutual arcs in both directions.
§Errors
IgraphError::InvalidArgument— ragged matrix or vertex count overflow.
§Examples
use rust_igraph::{weighted_biadjacency, BipartiteMode};
let matrix: &[&[f64]] = &[
&[1.5, 0.0],
&[0.0, 2.5],
];
let r = weighted_biadjacency(matrix, false, BipartiteMode::All).unwrap();
assert_eq!(r.graph.vcount(), 4);
assert_eq!(r.graph.ecount(), 2);
assert_eq!(r.weights, vec![1.5, 2.5]);
assert_eq!(r.types, vec![false, false, true, true]);