Skip to main content

szeged_index

Function szeged_index 

Source
pub fn szeged_index(graph: &Graph) -> IgraphResult<u64>
Expand description

Compute the Szeged index of a graph.

Sz(G) = Σ_{(u,v)∈E} n_u(e) · n_v(e)

For each edge (u, v), n_u(e) counts vertices strictly closer to u than to v, and n_v(e) counts vertices strictly closer to v than to u.

§Examples

use rust_igraph::{Graph, szeged_index};

// Path 0-1-2: edge (0,1): n0=1, n1=2 → 2; edge (1,2): n1=2, n2=1 → 2
// Sz = 2 + 2 = 4
let g = Graph::from_edges(&[(0,1),(1,2)], false, Some(3)).unwrap();
assert_eq!(szeged_index(&g).unwrap(), 4);