Skip to main content

betweenness_weighted

Function betweenness_weighted 

Source
pub fn betweenness_weighted(
    graph: &Graph,
    weights: &[f64],
) -> IgraphResult<Vec<f64>>
Expand description

Per-vertex weighted betweenness centrality.

Returns Vec<f64> of length vcount. Raw (unnormalised) counts: for undirected graphs the result is divided by 2 to match the unweighted variant (each unordered pair is counted once).

weights[e] is the weight of edge e; weights.len() must equal graph.ecount(). All weights must be >= 0 and finite.

§Examples

use rust_igraph::{Graph, betweenness_weighted};

// Path 0-1-2-3-4, all weights 1.0 → matches unweighted result.
let mut g = Graph::with_vertices(5);
for i in 0..4u32 { g.add_edge(i, i + 1).unwrap(); }
let b = betweenness_weighted(&g, &[1.0; 4]).unwrap();
// Same as unweighted PR-008 path test.
assert_eq!(b, vec![0.0, 3.0, 4.0, 3.0, 0.0]);