library_checker/graph/
scc.rs1#[doc(no_inline)]
2pub use competitive::graph::{DirectedSparseGraph, StronglyConnectedComponent};
3use competitive::prelude::*;
4
5#[verify::library_checker("scc")]
6pub fn scc(reader: impl Read, mut writer: impl Write) {
7 let s = read_all_unchecked(reader);
8 let mut scanner = Scanner::new(&s);
9 scan!(scanner, vs, es, edges: [(usize, usize); es]);
10 let graph = DirectedSparseGraph::from_edges(vs, edges);
11 let scc = StronglyConnectedComponent::new(&graph);
12 let comp = scc.components();
13 writeln!(writer, "{}", comp.len()).ok();
14 for vs in comp.into_iter() {
15 iter_print!(writer, vs.len(), @it vs);
16 }
17}