pub trait ShortestPathExt: GraphBase {
// Provided methods
fn standard_sp<'a, M>(
&'a self,
) -> ShortestPathBuilder<'a, Self, StandardSp<M>>
where Self: Sized + GraphBase,
M: Monoid<T: Bounded + Ord> { ... }
fn standard_sp_additive<'a, T>(
&'a self,
) -> ShortestPathBuilder<'a, Self, StandardSp<AdditiveOperation<T>>>
where Self: Sized + GraphBase,
T: Clone + Zero + Add<Output = T> + Bounded + Ord { ... }
fn option_sp<'a, M>(&'a self) -> ShortestPathBuilder<'a, Self, OptionSp<M>>
where Self: Sized + GraphBase,
M: Monoid<T: Ord> { ... }
fn option_sp_additive<'a, T>(
&'a self,
) -> ShortestPathBuilder<'a, Self, OptionSp<AdditiveOperation<T>>>
where Self: Sized + GraphBase,
T: Clone + Zero + Add<Output = T> + Ord { ... }
fn path_folding_sp<'a, M, S>(
&'a self,
) -> ShortestPathBuilder<'a, Self, PathFoldingSp<M, S>>
where Self: Sized + GraphBase,
M: Monoid<T: Bounded + Ord>,
S: SemiRing { ... }
fn path_folding_sp_additive_addmul<'a, T, U>(
&'a self,
) -> ShortestPathBuilder<'a, Self, PathFoldingSp<AdditiveOperation<T>, AddMulOperation<U>>>
where Self: Sized + GraphBase,
T: Clone + Zero + Add<Output = T> + Bounded + Ord,
U: Clone + Zero + One + Add<Output = U> + Mul<Output = U> { ... }
}Provided Methods§
fn standard_sp<'a, M>(&'a self) -> ShortestPathBuilder<'a, Self, StandardSp<M>>
Sourcefn standard_sp_additive<'a, T>(
&'a self,
) -> ShortestPathBuilder<'a, Self, StandardSp<AdditiveOperation<T>>>
fn standard_sp_additive<'a, T>( &'a self, ) -> ShortestPathBuilder<'a, Self, StandardSp<AdditiveOperation<T>>>
Examples found in repository?
More examples
crates/aizu_online_judge/src/grl/grl_1_a.rs (line 13)
9pub fn grl_1_a(reader: impl Read, mut writer: impl Write) {
10 let s = read_all_unchecked(reader);
11 let mut scanner = Scanner::new(&s);
12 scan!(scanner, vs, es, r, (graph, d): @DirectedGraphScanner::<usize, u64>::new(vs, es));
13 let cost = graph.standard_sp_additive().dijkstra([r], &d);
14 for u in graph.vertices() {
15 if cost[u].is_maximum() {
16 writeln!(writer, "INF").ok();
17 } else {
18 writeln!(writer, "{}", cost[u]).ok();
19 }
20 }
21}fn option_sp<'a, M>(&'a self) -> ShortestPathBuilder<'a, Self, OptionSp<M>>
Sourcefn option_sp_additive<'a, T>(
&'a self,
) -> ShortestPathBuilder<'a, Self, OptionSp<AdditiveOperation<T>>>
fn option_sp_additive<'a, T>( &'a self, ) -> ShortestPathBuilder<'a, Self, OptionSp<AdditiveOperation<T>>>
Examples found in repository?
crates/aizu_online_judge/src/grl/grl_1_a.rs (line 29)
24pub fn grl_1_a_option(reader: impl Read, mut writer: impl Write) {
25 let s = read_all_unchecked(reader);
26 let mut scanner = Scanner::new(&s);
27 scan!(scanner, vs, es, r, (graph, d): @DirectedGraphScanner::<usize, u64>::new(vs, es));
28 let cost = graph
29 .option_sp_additive()
30 .dijkstra([r], &|eid| Some(d[eid]));
31 for u in graph.vertices() {
32 match cost[u] {
33 Some(d) => writeln!(writer, "{}", d).ok(),
34 None => writeln!(writer, "INF").ok(),
35 };
36 }
37}More examples
crates/aizu_online_judge/src/grl/grl_1_b.rs (line 11)
6pub fn grl_1_b(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, r, (graph, d): @DirectedGraphScanner::<usize, i64>::new(vs, es));
10 let cost = graph
11 .option_sp_additive()
12 .bellman_ford([r], &|eid| Some(d[eid]), true);
13 if let Some(cost) = cost {
14 for u in graph.vertices() {
15 match cost[u] {
16 Some(d) => writeln!(writer, "{}", d).ok(),
17 None => writeln!(writer, "INF").ok(),
18 };
19 }
20 } else {
21 writeln!(writer, "NEGATIVE CYCLE").ok();
22 }
23}crates/aizu_online_judge/src/grl/grl_1_c.rs (line 14)
9pub fn grl_1_c(reader: impl Read, mut writer: impl Write) {
10 let s = read_all_unchecked(reader);
11 let mut scanner = Scanner::new(&s);
12 scan!(scanner, vs, es, (graph, d): @DirectedGraphScanner::<usize, i64>::new(vs, es));
13 let cost = graph
14 .option_sp_additive()
15 .warshall_floyd_ap(&|eid| Some(Saturating(d[eid])));
16 if graph.vertices().any(|u| cost[u][u].unwrap().0 < 0) {
17 writeln!(writer, "NEGATIVE CYCLE").ok();
18 } else {
19 for u in graph.vertices() {
20 for v in graph.vertices() {
21 match cost[u][v] {
22 Some(d) => write!(writer, "{}", d.0),
23 None => write!(writer, "INF"),
24 }
25 .ok();
26 write!(writer, "{}", if v + 1 == vs { '\n' } else { ' ' }).ok();
27 }
28 }
29 }
30}