[][src]Struct floyd_warshall_alg::floyd_warshall::FloydWarshall

pub struct FloydWarshall<F: FloydWarshallTrait> { /* fields omitted */ }

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]

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]

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]

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]

impl<T> From for T[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

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.

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]