pub fn hub_and_authority_scores_weighted(
graph: &Graph,
weights: &[f64],
) -> IgraphResult<HitsScores>Expand description
Weighted Kleinberg hub and authority scores.
weights[e] is the weight of edge id e; must have length
graph.ecount() or this returns IgraphError::InvalidArgument.
The weighted adjacency matrix is W[i,j] = Σ_{e: i→j} w_e; the
returned hub/authority vectors approximate the principal
eigenvectors of W·Wᵀ and Wᵀ·W respectively.
Behaviour mirrors upstream igraph_hub_and_authority_scores when
weights is non-NULL:
- Length must match
ecount(). - All-zero weights → both vectors filled with
1.0, eigenvalue0. - Empty edges → same as the unweighted empty case.
- Negative weights are accepted: the sign-cleanup pass that normally zeros tiny negative drifts is skipped, since Perron-Frobenius no longer guarantees a non-negative eigenvector.
- Undirected graphs delegate to a self-rolled shifted power
iteration on
(W + I), and the reported eigenvalue isλ²(square of the dominant adjacency eigenvalue).
Counterpart of igraph_hub_and_authority_scores(g, h, a, &val, weights, /*options=*/NULL) from
references/igraph/src/centrality/hub_authority.c.
§Examples
Weighted 2×2 bipartite block where weights tilt the authority:
use rust_igraph::{Graph, hub_and_authority_scores_weighted};
// 0→2 (w=1), 0→3 (w=4), 1→2 (w=2), 1→3 (w=3).
let mut g = Graph::new(4, true).unwrap();
g.add_edges(vec![(0u32, 2u32), (0, 3), (1, 2), (1, 3)]).unwrap();
let weights = vec![1.0, 4.0, 2.0, 3.0];
let s = hub_and_authority_scores_weighted(&g, &weights).unwrap();
// Both vertex 0 and 1 are hubs; vertex 2,3 are authorities.
assert!(s.hub[2].abs() < 1e-9);
assert!(s.hub[3].abs() < 1e-9);
assert!(s.authority[0].abs() < 1e-9);
assert!(s.authority[1].abs() < 1e-9);
// Authority 3 has heavier in-weight than authority 2.
assert!(s.authority[3] > s.authority[2]);