1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//! `graphalgs` is a graph algorithms library based on the Rust
//! [petgraph](https://docs.rs/petgraph/0.5.1/petgraph/) crate.
//!
//! # Examples
//!
//! ```
//! use graphalgs::shortest_path::floyd_warshall;
//! use graphalgs::metrics::{ weighted_radius, weighted_diameter };
//! use petgraph::Graph;
//!
//! let inf = f32::INFINITY;
//!
//! // Create a graph with `f32` edge weights.
//! let graph = Graph::<(), f32>::from_edges(&[
//!     (0, 1, 2.0), (1, 2, 10.0), (1, 3, -5.0),
//!     (3, 2, 2.0), (2, 3, 20.0),
//! ]);
//!
//! // Calculate the distance matrix using the Floyd-Warshall algorithm.
//! assert_eq!(
//!     floyd_warshall(&graph, |edge| *edge.weight()),
//!     Ok(vec![vec![0.0, 2.0, -1.0, -3.0],
//!             vec![inf, 0.0, -3.0, -5.0],
//!             vec![inf, inf,  0.0, 20.0],
//!             vec![inf, inf,  2.0,  0.0]])
//! );
//!
//! // Calculate the radius and diameter of this graph,
//! // taking into account the weights of the edges.
//! assert_eq!(weighted_radius(&graph, |edge| *edge.weight()), Some(2.0));
//! assert_eq!(weighted_diameter(&graph, |edge| *edge.weight()), Some(inf));
//! ```

#[doc(no_inline)]
pub extern crate nalgebra;
#[doc(no_inline)]
pub extern crate petgraph;

pub mod adj_matrix;
pub mod connect;
pub mod elementary_circuits;
pub mod generate;
pub mod metrics;
pub mod mst;
pub mod shortest_path;
pub mod spec;
pub mod tournament;
pub mod traits;