Skip to main content

ParametricMaxFlow

Struct ParametricMaxFlow 

Source
pub struct ParametricMaxFlow { /* private fields */ }
Expand description

A parametric s-t flow network with affine, GGT-monotone arc capacities.

Implementations§

Source§

impl ParametricMaxFlow

Source

pub fn new(n: usize, source: usize, sink: usize) -> GraphalgResult<Self>

Create an empty parametric network on n nodes with the given source/sink.

Source

pub fn num_nodes(&self) -> usize

Number of nodes.

Source

pub fn source(&self) -> usize

Source node.

Source

pub fn sink(&self) -> usize

Sink node.

Source

pub fn arcs(&self) -> &[ParametricArc]

Arcs of the network.

Source

pub fn add_arc( &mut self, from: usize, to: usize, base: f64, slope: f64, ) -> GraphalgResult<()>

Add a parametric arc from -> to with capacity base + slope * lambda.

Enforces the GGT monotone structure (see module docs) and rejects out-of-range endpoints and non-finite coefficients.

Source

pub fn from_linear_capacities( n: usize, source: usize, sink: usize, from: &[usize], to: &[usize], base: &[f64], slope: &[f64], ) -> GraphalgResult<Self>

Build a parametric network from parallel coefficient slices.

All slices must share the same length, otherwise a GraphalgError::DimensionMismatch is returned. Each tuple position i describes arc from[i] -> to[i] with capacity base[i] + slope[i] * lambda.

Source

pub fn solve_at(&self, lambda: f64) -> GraphalgResult<ParametricSolution>

Solve the maximum flow at a single lambda, returning the flow value and the minimal source side of the minimum cut (sorted ascending).

Source

pub fn solve_grid( &self, lambdas: &[f64], ) -> GraphalgResult<Vec<ParametricSolution>>

Solve the whole family over the provided lambda grid.

Each entry is an exact independent single-parameter max-flow solve. When the grid is non-decreasing the returned source_sets are nested.

Source

pub fn find_breakpoints( &self, lambda_min: f64, lambda_max: f64, ) -> GraphalgResult<Vec<ParametricBreakpoint>>

Locate every lambda in [lambda_min, lambda_max] at which the minimal minimum-cut source side changes, via Gallo-Grigoriadis-Tarjan slicing.

Returns the breakpoints sorted by ascending lambda. Each breakpoint carries the source side optimal immediately above it. Assumes the affine capacities stay non-negative across the interval (the standard GGT regime); otherwise the breakpoint geometry uses the un-clamped lines.

Trait Implementations§

Source§

impl Clone for ParametricMaxFlow

Source§

fn clone(&self) -> ParametricMaxFlow

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ParametricMaxFlow

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.