Function graphalgos::algos::dijkstra

source ·
pub fn dijkstra<E>(g: Graph, start_vertex: String)where
    E: Clone + Debug,
Expand description

Dijkstra Algorithm - Find the single source shortest path given a graph and a starting vertex

Parameters:

  1. g - the graph that needs to be traversed. This will be of type Graph
  2. start_vertex - the source vertex from which you want to find the shortest distance of all other vertex

Return Value:

Void

Example Usage:


use graphalgos::algos;
use graphalgos::graphs;

let mut g: graphs::Graph = graphs::Graph::new(false); // creates an undirected graph

// Add vertices

g.add_vertex(String::from("A")); // add vertex A
g.add_vertex(String::from("B")); // add vertex B
...
...
g.add_vertex(String::from("I")); // add vertex I

// Add edges

// Add multiple edges
g.add_edge(
    (String::from("A"), String::from('B')),
    graphs::GNumber::I32(4),
);
...
...
algos::dijkstra(g);