Expand description
Centrality measure algorithms for graph analysis
Provides implementations for three key centrality measures:
- Degree Centrality: Measures node connectivity through edge count
- Betweenness Centrality: Quantifies a node’s role as a network bridge
- Closeness Centrality: Assesses average distance to other nodes
All methods return Result types to handle potential errors gracefully instead of panicking.
§Examples
Basic usage with error handling:
use xgraph::graph::graph::Graph;
use xgraph::graph::algorithms::centrality::Centrality;
let matrix = vec![
vec![0, 1, 1],
vec![1, 0, 1],
vec![1, 1, 0]
];
let graph = Graph::from_adjacency_matrix(&matrix, false, 0, 0).unwrap();
let degree = graph.degree_centrality().unwrap();
let betweenness = graph.betweenness_centrality().unwrap();
let closeness = graph.closeness_centrality().unwrap();Enums§
- Centrality
Error - Error type for centrality computation failures.
Traits§
- Centrality
- Trait for calculating centrality measures in graphs