pub fn get_biadjacency_matrix(
graph: &Graph,
types: &[bool],
) -> IgraphResult<GetBiadjacencyResult>Expand description
Extract the biadjacency matrix from a bipartite graph.
Given a graph and a per-vertex type vector (false = row partition,
true = column partition), returns the n1 × n2 biadjacency
matrix where entry (i, j) counts the number of edges between
row-vertex i and column-vertex j.
Edges within the same partition are silently ignored (as in the C implementation).
§Parameters
graph— the input graph (directed or undirected).types— per-vertex boolean:false= row (partition 1),true= column (partition 2). Must have length equal tograph.vcount().
§Errors
IgraphError::InvalidArgument— iftypes.len() != graph.vcount().
§Examples
use rust_igraph::{biadjacency, get_biadjacency_matrix, BipartiteMode};
let matrix: &[&[f64]] = &[
&[1.0, 0.0, 2.0],
&[0.0, 1.0, 0.0],
];
let r = biadjacency(matrix, false, BipartiteMode::All, true).unwrap();
let extracted = get_biadjacency_matrix(&r.graph, &r.types).unwrap();
assert_eq!(extracted.matrix.len(), 2); // 2 rows
assert_eq!(extracted.matrix[0].len(), 3); // 3 columns
assert_eq!(extracted.matrix[0][0], 1.0);
assert_eq!(extracted.matrix[0][2], 2.0);
assert_eq!(extracted.matrix[1][1], 1.0);