pub struct Dijkstra { /* private fields */ }
Expand description

Dijkstra algorithm

This crate implements a Dijkstra algorithm to compute the shortest path by given graph.

Implementations§

Create a new Dijkstra graph with edges(tuple) Vec

Example
use flex_algo::Dijkstra;
 
let times = vec![(1, 2, 9), (1, 4, 2), (2, 5, 1), (4, 2, 4), (4, 5, 6), (3, 2, 3), (5, 3, 7), (3, 1, 5)];
let dijkstra = Dijkstra::new(5, times);
 

Return the shortest path

Example
use flex_algo::Dijkstra;
 
let times = vec![(1, 2, 9), (1, 4, 2), (2, 5, 1), (4, 2, 4), (4, 5, 6), (3, 2, 3), (5, 3, 7), (3, 1, 5)];
let dijkstra = Dijkstra::new(5, times);
let (max, path) =  dijkstra.shortest_path(1).unwrap();
println!("shortest path: {:?}", path);
assert_eq!(max, 14);
 

Trait Implementations§

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.