Skip to main content

schultz_index

Function schultz_index 

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

Compute the Schultz index (degree-distance index).

S(G) = Σ_{u<v} (d(u) + d(v)) · dist(u,v)

Only finite distances contribute. Returns 0 for graphs with fewer than 2 vertices.

§Examples

use rust_igraph::{Graph, schultz_index};

// Path 0-1-2: degrees [1,2,1], distances d(0,1)=1, d(0,2)=2, d(1,2)=1
// S = (1+2)·1 + (1+1)·2 + (2+1)·1 = 3+4+3 = 10
let g = Graph::from_edges(&[(0,1),(1,2)], false, Some(3)).unwrap();
assert_eq!(schultz_index(&g).unwrap(), 10);