#![doc(html_root_url = "https://docs.rs/petgraph/0.3/")]
extern crate fixedbitset;
extern crate itertools;
#[doc(no_inline)]
pub use graph::Graph;
pub use graphmap::GraphMap;
#[cfg(feature = "stable_graph")]
#[doc(no_inline)]
pub use stable_graph::StableGraph;
pub use visit::{
Bfs,
BfsIter,
Dfs,
DfsIter,
};
pub use EdgeDirection::{Outgoing, Incoming};
mod scored;
pub mod algo;
#[cfg(feature = "generate")]
pub mod generate;
pub mod graphmap;
#[path = "graph.rs"]
mod graph_impl;
pub mod dot;
pub mod visit;
pub mod unionfind;
mod dijkstra;
mod isomorphism;
mod traits_graph;
#[cfg(feature = "quickcheck")]
mod quickcheck;
pub mod graph {
pub use graph_impl::{
Edge,
EdgeIndex,
EdgeIndices,
EdgeReference,
EdgeReferences,
EdgeWeightsMut,
Edges,
Externals,
Frozen,
Graph,
Neighbors,
Node,
NodeIndex,
NodeIndices,
NodeWeightsMut,
WalkNeighbors,
GraphIndex,
IndexType,
edge_index,
node_index,
DefaultIx,
};
}
#[cfg(feature = "stable_graph")]
pub use graph_impl::stable as stable_graph;
macro_rules! copyclone {
($name:ident) => {
impl Clone for $name {
#[inline]
fn clone(&self) -> Self { *self }
}
}
}
#[derive(Copy, Debug, PartialEq, PartialOrd, Ord, Eq, Hash)]
pub enum EdgeDirection {
Outgoing = 0,
Incoming = 1
}
copyclone!(EdgeDirection);
impl EdgeDirection {
#[inline]
pub fn opposite(&self) -> EdgeDirection {
match *self {
Outgoing => Incoming,
Incoming => Outgoing,
}
}
}
#[derive(Copy, Debug)]
pub enum Directed { }
copyclone!(Directed);
#[derive(Copy, Debug)]
pub enum Undirected { }
copyclone!(Undirected);
pub trait EdgeType {
fn is_directed() -> bool;
}
impl EdgeType for Directed {
#[inline]
fn is_directed() -> bool { true }
}
impl EdgeType for Undirected {
#[inline]
fn is_directed() -> bool { false }
}
pub trait IntoWeightedEdge<E> {
type NodeId;
fn into_weighted_edge(self) -> (Self::NodeId, Self::NodeId, E);
}
impl<Ix, E> IntoWeightedEdge<E> for (Ix, Ix)
where E: Default
{
type NodeId = Ix;
fn into_weighted_edge(self) -> (Ix, Ix, E) {
let (s, t) = self;
(s, t, E::default())
}
}
impl<Ix, E> IntoWeightedEdge<E> for (Ix, Ix, E)
{
type NodeId = Ix;
fn into_weighted_edge(self) -> (Ix, Ix, E) {
self
}
}
impl<'a, Ix, E> IntoWeightedEdge<E> for (Ix, Ix, &'a E)
where E: Clone
{
type NodeId = Ix;
fn into_weighted_edge(self) -> (Ix, Ix, E) {
let (a, b, c) = self;
(a, b, c.clone())
}
}
impl<'a, Ix, E> IntoWeightedEdge<E> for &'a (Ix, Ix)
where Ix: Copy, E: Default
{
type NodeId = Ix;
fn into_weighted_edge(self) -> (Ix, Ix, E) {
let (s, t) = *self;
(s, t, E::default())
}
}
impl<'a, Ix, E> IntoWeightedEdge<E> for &'a (Ix, Ix, E)
where Ix: Copy, E: Clone
{
type NodeId = Ix;
fn into_weighted_edge(self) -> (Ix, Ix, E) {
self.clone()
}
}