Module rs_graph::adjacencies [−][src]
Abstraction of neighboring edges.
This module implements the arguably simplest representation of a graph: for each node the list of adjacent edges and nodes. No further information like the number of nodes or edges in a graph is available.
The purpose of the trait Adjacencies
is therefore to abstract over the concept
of adjacent edges and nodes. Standard examples are “all edges” (in the
undirected sense), “incoming edges” and “outgoing edges” represented by the structs
Neighbors
, InEdges
and OutEdges
.
Some algorithms (e.g. breadth-first search or depth-first search) can be described in terms of adjacencies only.
Example
use rs_graph::classes; use rs_graph::Net; use rs_graph::traits::*; use rs_graph::adjacencies::*; let g = classes::peterson::<Net>(); let neighs = Neighbors(&g); let neighs = neighs.filter(|&(e, _)| { let (u,v) = g.enodes(e); (g.node_id(u) < 5) == (g.node_id(v) < 5) }); for u in g.nodes() { assert_eq!(neighs.neighs(u).count(), 2); }
Structs
AdjacenciesWrapIt | |
FilterAdjacencies | |
Filtered | |
InEdges | Neighbor access over all incoming edges of a |
Neighbors | Neighbor access over all adjacent (undirected) edges. |
OutEdges | Neighbor access over all outgoing edges of a |
Traits
Adjacencies |