[−][src]Struct floyd_warshall_alg::floyd_warshall::FloydWarshall
Floyd-Warshall algorithm structure.
FloydWarshall
algorithm is parameterized over:
- Number type
F
giving a weights to edges.
Methods
impl<F: FloydWarshallTrait> FloydWarshall<F>
[src]
pub fn new() -> Self
[src]
Create a new instance of FloydWarshall structure with default settings.
Examples
use floyd_warshall_alg::FloydWarshall; let alg: FloydWarshall<f32> = FloydWarshall::new();
pub fn new_customized(
op: Box<dyn Fn(F, F) -> F>,
cmp: Box<dyn Fn(F, F) -> bool>
) -> Self
[src]
op: Box<dyn Fn(F, F) -> F>,
cmp: Box<dyn Fn(F, F) -> bool>
) -> Self
Create a new instance of FloydWarshall structure with customized settings.
You can set:
- the
op
(operator) to be used for weighted edges - the
cmp
(comparison) to be used for weighted paths
Examples
use floyd_warshall_alg::FloydWarshall; use std::cmp::Ordering::{Greater, Less}; let mul = Box::new(|x: f32, y: f32| x * y); let sharp_greater = Box::new(|x: f32, y: f32| x.partial_cmp(&y).unwrap_or(Less) == Greater); let alg: FloydWarshall<f32> = FloydWarshall::new_customized(mul, sharp_greater);
pub fn new_fully_customized(
op: Box<dyn Fn(F, F) -> F>,
cmp: Box<dyn Fn(F, F) -> bool>,
discard_loops: bool
) -> Self
[src]
op: Box<dyn Fn(F, F) -> F>,
cmp: Box<dyn Fn(F, F) -> bool>,
discard_loops: bool
) -> Self
Create a new instance of FloydWarshall structure with customized settings.
You can set:
- the
op
(operator) to be used for weighted edges - the
cmp
(comparison) to be used for weighted paths - the
discard_loops
to discard loops (e.g. edges starting and ending in the same node) from calculation.
Examples
use floyd_warshall_alg::FloydWarshall; use std::cmp::Ordering::{Greater, Less}; let mul = Box::new(|x: f32, y: f32| x * y); let sharp_greater = Box::new(|x: f32, y: f32| x.partial_cmp(&y).unwrap_or(Less) == Greater); let discard_loops = false; let alg: FloydWarshall<f32> = FloydWarshall::new_customized(mul, sharp_greater);
pub fn find_paths<N>(&self, graph: &Graph<N, F>) -> FloydWarshallResult<N, F> where
N: NodeTrait,
[src]
N: NodeTrait,
Find all the shortest paths (or best rated paths based on algorithm customized settings).
The result of type FloydWarshallResult holds both:
- best rates for all possible paths
- next node on the best rated (shortest) path for each possible path
Method is parameterized over:
- Node index / label
N
. - Number type
E
giving a weight to edges.
Auto Trait Implementations
impl<F> !Send for FloydWarshall<F>
impl<F> !Sync for FloydWarshall<F>
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From for T
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
🔬 This is a nightly-only experimental API. (
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
🔬 This is a nightly-only experimental API. (
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,