pub struct SteinerTreeBuilder<'g, G, S = (), P = NoParent>where
G: Graph,
P: SteinerTreeParentPolicy<G>,{
graph: &'g G,
_marker: PhantomData<fn() -> (S, P)>,
}Fields§
§graph: &'g G§_marker: PhantomData<fn() -> (S, P)>Implementations§
Source§impl<'g, G, S, P> SteinerTreeBuilder<'g, G, S, P>where
G: Graph,
P: SteinerTreeParentPolicy<G>,
impl<'g, G, S, P> SteinerTreeBuilder<'g, G, S, P>where
G: Graph,
P: SteinerTreeParentPolicy<G>,
Sourcepub fn with_sp<T>(self) -> SteinerTreeBuilder<'g, G, T, P>where
T: ShortestPathSemiRing,
pub fn with_sp<T>(self) -> SteinerTreeBuilder<'g, G, T, P>where
T: ShortestPathSemiRing,
Examples found in repository?
crates/competitive/src/graph/steiner_tree.rs (line 108)
104 pub fn with_standard_sp<M>(self) -> SteinerTreeBuilder<'g, G, StandardSp<M>, P>
105 where
106 M: Monoid<T: Bounded + Ord>,
107 {
108 self.with_sp()
109 }
110
111 pub fn with_standard_sp_additive<T>(
112 self,
113 ) -> SteinerTreeBuilder<'g, G, StandardSp<AdditiveOperation<T>>, P>
114 where
115 T: Clone + Zero + Add<Output = T> + Bounded + Ord,
116 {
117 self.with_sp()
118 }
119
120 pub fn with_option_sp<M>(self) -> SteinerTreeBuilder<'g, G, OptionSp<M>, P>
121 where
122 M: Monoid<T: Ord>,
123 {
124 self.with_sp()
125 }
126
127 pub fn with_option_sp_additive<T>(
128 self,
129 ) -> SteinerTreeBuilder<'g, G, OptionSp<AdditiveOperation<T>>, P>
130 where
131 T: Clone + Zero + Add<Output = T> + Ord,
132 {
133 self.with_sp()
134 }pub fn with_standard_sp<M>(self) -> SteinerTreeBuilder<'g, G, StandardSp<M>, P>
Sourcepub fn with_standard_sp_additive<T>(
self,
) -> SteinerTreeBuilder<'g, G, StandardSp<AdditiveOperation<T>>, P>
pub fn with_standard_sp_additive<T>( self, ) -> SteinerTreeBuilder<'g, G, StandardSp<AdditiveOperation<T>>, P>
Examples found in repository?
crates/library_checker/src/graph/minimum_steiner_tree.rs (line 11)
5pub fn minimum_steiner_tree(reader: impl Read, writer: impl Write) {
6 prepare_io!(reader, writer);
7 sc!(n, m, (graph, weights): @UndirectedGraphScanner::<usize, u64>::new(n, m));
8 sc!(k, terminals: [usize; k]);
9 let tree = graph
10 .steiner_tree()
11 .with_standard_sp_additive()
12 .with_parent()
13 .solve(terminals[1..].iter().copied(), |eid| weights[eid]);
14 let edges = tree.edges_from_source(terminals[0]).unwrap();
15 pp!(tree.minimum_from_source(terminals[0]), edges.len(); @it edges);
16}pub fn with_option_sp<M>(self) -> SteinerTreeBuilder<'g, G, OptionSp<M>, P>
pub fn with_option_sp_additive<T>( self, ) -> SteinerTreeBuilder<'g, G, OptionSp<AdditiveOperation<T>>, P>
Source§impl<'g, G, S> SteinerTreeBuilder<'g, G, S>where
G: Graph,
impl<'g, G, S> SteinerTreeBuilder<'g, G, S>where
G: Graph,
Sourcepub fn with_parent(self) -> SteinerTreeBuilder<'g, G, S, RecordParent>where
RecordParent: SteinerTreeParentPolicy<G>,
pub fn with_parent(self) -> SteinerTreeBuilder<'g, G, S, RecordParent>where
RecordParent: SteinerTreeParentPolicy<G>,
Examples found in repository?
crates/library_checker/src/graph/minimum_steiner_tree.rs (line 12)
5pub fn minimum_steiner_tree(reader: impl Read, writer: impl Write) {
6 prepare_io!(reader, writer);
7 sc!(n, m, (graph, weights): @UndirectedGraphScanner::<usize, u64>::new(n, m));
8 sc!(k, terminals: [usize; k]);
9 let tree = graph
10 .steiner_tree()
11 .with_standard_sp_additive()
12 .with_parent()
13 .solve(terminals[1..].iter().copied(), |eid| weights[eid]);
14 let edges = tree.edges_from_source(terminals[0]).unwrap();
15 pp!(tree.minimum_from_source(terminals[0]), edges.len(); @it edges);
16}Source§impl<'g, G, S, P> SteinerTreeBuilder<'g, G, S, P>
impl<'g, G, S, P> SteinerTreeBuilder<'g, G, S, P>
Sourcepub fn solve<M, I>(
&self,
terminals: I,
weight: M,
) -> SteinerTreeOutput<'g, S, G, P>
pub fn solve<M, I>( &self, terminals: I, weight: M, ) -> SteinerTreeOutput<'g, S, G, P>
Requires commutative multiplication and nonnegative edge weights.
Examples found in repository?
crates/library_checker/src/graph/minimum_steiner_tree.rs (line 13)
5pub fn minimum_steiner_tree(reader: impl Read, writer: impl Write) {
6 prepare_io!(reader, writer);
7 sc!(n, m, (graph, weights): @UndirectedGraphScanner::<usize, u64>::new(n, m));
8 sc!(k, terminals: [usize; k]);
9 let tree = graph
10 .steiner_tree()
11 .with_standard_sp_additive()
12 .with_parent()
13 .solve(terminals[1..].iter().copied(), |eid| weights[eid]);
14 let edges = tree.edges_from_source(terminals[0]).unwrap();
15 pp!(tree.minimum_from_source(terminals[0]), edges.len(); @it edges);
16}Auto Trait Implementations§
impl<'g, G, S, P> Freeze for SteinerTreeBuilder<'g, G, S, P>
impl<'g, G, S, P> RefUnwindSafe for SteinerTreeBuilder<'g, G, S, P>
impl<'g, G, S, P> Send for SteinerTreeBuilder<'g, G, S, P>
impl<'g, G, S, P> Sync for SteinerTreeBuilder<'g, G, S, P>
impl<'g, G, S, P> Unpin for SteinerTreeBuilder<'g, G, S, P>
impl<'g, G, S, P> UnsafeUnpin for SteinerTreeBuilder<'g, G, S, P>
impl<'g, G, S, P> UnwindSafe for SteinerTreeBuilder<'g, G, S, P>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more