[−][src]Struct structures::graph::Graph
Directed Graph
Examples
use structures::graph::Graph; let graph: Graph = vec![ (1, 2, 7), (1, 3, 9), (1, 6, 14), (2, 3, 10), (2, 4, 15), (3, 4, 11), (3, 6, 2), (4, 5, 6), (6, 5, 9), ].into_iter().collect(); assert_eq!(graph.shortest_path(1, Some(5))[&5], (20, vec![1, 3, 6, 5])); assert_eq!(graph.shortest_paths()[&1][&5], (20, vec![1, 3, 6, 5]));
Methods
impl Graph
[src]
pub fn new() -> Self
[src]
pub fn vertices(&self) -> Vertices
[src]
pub fn vertices_outgoing_from(&self, source: Vertex) -> Vertices
[src]
pub fn edges(&self) -> Edges
[src]
pub fn weight(&self, source: Vertex, target: Vertex) -> Option<Weight>
[src]
pub fn add_edge(&mut self, source: Vertex, target: Vertex, weight: Weight)
[src]
impl Graph
[src]
pub fn shortest_path(
&self,
source: Vertex,
target: Option<Vertex>
) -> HashMap<Vertex, (Weight, Path)>
[src]
&self,
source: Vertex,
target: Option<Vertex>
) -> HashMap<Vertex, (Weight, Path)>
Dijkstra's Algorithm
pub fn shortest_paths(&self) -> HashMap<Vertex, HashMap<Vertex, (Weight, Path)>>
[src]
Floyd-Warshall Algorithm
pub fn topo_sort(&self) -> Option<Path>
[src]
Topological Sorting
Trait Implementations
impl Extend<(usize, usize, usize)> for Graph
[src]
impl Default for Graph
[src]
impl FromIterator<(usize, usize, usize)> for Graph
[src]
Auto Trait Implementations
Blanket Implementations
impl<T> From for T
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
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> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?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>,