Skip to main content

edge_szeged_index

Function edge_szeged_index 

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

Compute the edge-Szeged index.

Sz_e(G) = Σ_{(u,v)∈E} m_u(e) · m_v(e)

where m_u(e) is the number of edges whose midpoint is closer to u than to v. An edge (a,b) is closer to u when dist(u,a) + dist(u,b) < dist(v,a) + dist(v,b).

§Examples

use rust_igraph::{Graph, edge_szeged_index};

// Path 0-1-2: 2 edges
// edge (0,1): m_0=0, m_1=1 (edge (1,2) closer to 1) → 0
// edge (1,2): m_1=1 (edge (0,1) closer to 1), m_2=0 → 0
// Sz_e = 0
let g = Graph::from_edges(&[(0,1),(1,2)], false, Some(3)).unwrap();
assert_eq!(edge_szeged_index(&g).unwrap(), 0);