Expand description
Graph structure algorithms: connected components and strongly connected components
Provides structural analysis algorithms:
connected_components: Count weakly connected componentskosaraju_scc: Find strongly connected components using Kosaraju’s algorithm
§Example
use trueno_graph::{CsrGraph, NodeId, connected_components, kosaraju_scc};
// Build a graph with two components: 0 → 1, 2 → 3
let edges = vec![
(NodeId(0), NodeId(1), 1.0),
(NodeId(2), NodeId(3), 1.0),
];
let graph = CsrGraph::from_edge_list(&edges).unwrap();
// Two weakly connected components
assert_eq!(connected_components(&graph), 2);
// Four SCCs (each node is its own SCC in a DAG)
let sccs = kosaraju_scc(&graph);
assert_eq!(sccs.len(), 4);Functions§
- connected_
components - Count the number of weakly connected components in the graph
- kosaraju_
scc - Find strongly connected components using Kosaraju’s algorithm