pub type UndirectedSparseGraph = SparseGraph<UndirectedEdge>;
Aliased Type§
pub struct UndirectedSparseGraph {
pub start: Vec<usize>,
pub elist: Vec<Adjacency>,
pub edges: Vec<(usize, usize)>,
/* private fields */
}
Fields§
§start: Vec<usize>
§elist: Vec<Adjacency>
§edges: Vec<(usize, usize)>
Implementations§
Source§impl UndirectedSparseGraph
impl UndirectedSparseGraph
Sourcepub fn tree_depth(&self, root: usize) -> Vec<u64>
pub fn tree_depth(&self, root: usize) -> Vec<u64>
Source§impl UndirectedSparseGraph
impl UndirectedSparseGraph
Sourcepub fn weighted_tree_depth<M: Monoid, F: Fn(usize) -> M::T>(
&self,
root: usize,
weight: F,
) -> Vec<M::T>
pub fn weighted_tree_depth<M: Monoid, F: Fn(usize) -> M::T>( &self, root: usize, weight: F, ) -> Vec<M::T>
Examples found in repository?
crates/aizu_online_judge/src/grl/grl_5_a.rs (line 10)
6pub fn grl_5_a(reader: impl Read, mut writer: impl Write) {
7 let s = read_all_unchecked(reader);
8 let mut scanner = Scanner::new(&s);
9 scan!(scanner, n, (graph, w): @TreeGraphScanner::<usize, u64>::new(n));
10 let d = graph.weighted_tree_depth::<AdditiveOperation<_>, _>(0, |eid| w[eid]);
11 let r = (0..n).max_by_key(|&u| d[u]).unwrap();
12 let ans = graph
13 .weighted_tree_depth::<AdditiveOperation<_>, _>(r, |eid| w[eid])
14 .into_iter()
15 .max()
16 .unwrap();
17 writeln!(writer, "{}", ans).ok();
18}