pub fn pagerank_linsys(graph: &Graph) -> IgraphResult<Vec<f64>>Expand description
PageRank via GMRES on (I - α · Mᵀ) · pr = (1 - α)/N · 1.
Returns a Vec<f64> of length vcount() summing approximately to
1.0, agreeing with crate::pagerank to 1e-9 elementwise on
the shared conformance fixtures (the limit comes from PR-011’s
eps = 1e-10 stopping rule; GMRES itself reaches the true fixed
point to ≤ machine precision). Empty graphs return an empty vector;
singleton graphs return vec![1.0] — matching the PR-011 edge-case
contract.
Internally uses restarted GMRES with restart_dim = 30,
max_restarts = 50, relative residual tolerance 1e-13. No
unsafe, no external linear-algebra deps; the Arnoldi + Givens +
back-sub routine is implemented in this module.
§Errors
Returns crate::IgraphError only via the underlying graph
accessors (e.g. an Internal error if ecount() overflows u32).
GMRES non-convergence after max_restarts returns the best iterate
it had — no error, mirroring PR-011’s power-iter “fall through after
max_iter” behaviour.
§Examples
use rust_igraph::{Graph, pagerank, pagerank_linsys};
// Triangle: both backends agree on uniform 1/3.
let mut g = Graph::with_vertices(3);
g.add_edge(0, 1).unwrap();
g.add_edge(1, 2).unwrap();
g.add_edge(2, 0).unwrap();
let a = pagerank(&g).unwrap();
let b = pagerank_linsys(&g).unwrap();
for v in 0..3 {
assert!((a[v] - b[v]).abs() < 1e-12);
}