Skip to main content

SteinerTreeBuilder

Struct SteinerTreeBuilder 

Source
pub struct SteinerTreeBuilder<'g, G, S = (), P = NoParent>{
    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>

Source

pub fn with_sp<T>(self) -> SteinerTreeBuilder<'g, G, T, P>

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    }
Source

pub fn with_standard_sp<M>(self) -> SteinerTreeBuilder<'g, G, StandardSp<M>, P>
where M: Monoid<T: Bounded + Ord>,

Source

pub fn with_standard_sp_additive<T>( self, ) -> SteinerTreeBuilder<'g, G, StandardSp<AdditiveOperation<T>>, P>
where T: Clone + Zero + Add<Output = T> + Bounded + Ord,

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}
Source

pub fn with_option_sp<M>(self) -> SteinerTreeBuilder<'g, G, OptionSp<M>, P>
where M: Monoid<T: Ord>,

Source

pub fn with_option_sp_additive<T>( self, ) -> SteinerTreeBuilder<'g, G, OptionSp<AdditiveOperation<T>>, P>
where T: Clone + Zero + Add<Output = T> + Ord,

Source§

impl<'g, G, S> SteinerTreeBuilder<'g, G, S>
where G: Graph,

Source

pub fn with_parent(self) -> SteinerTreeBuilder<'g, G, S, RecordParent>

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>

Source

pub fn solve<M, I>( &self, terminals: I, weight: M, ) -> SteinerTreeOutput<'g, S, G, P>
where M: Fn(G::Label) -> S::T, I: ExactSizeIterator<Item = G::Vertex>,

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToArrayVecScalar for T

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.