[][src]Module graphrepresentations::simplegraph

A mutable graph representation.

While cheap to update, this representation should not be used in any algorithms. It does not implement any of the more interesting feature traits like NavigableGraph.

The SimpleGraphs main use is to aid construction of static graph representations.

  • Example

Constructing an AdjacencyArray using a SimpleGraph.

use graphrepresentations::simplegraph::SimpleGraph;
use graphrepresentations::graph::{MutableGraph, Node, Edge, Graph};
use graphrepresentations::adjacencyarray::AdjacencyArray;

let mut simple_graph = SimpleGraph::new();
let n1 = simple_graph.add_node(Node::new(5));
let n2 = simple_graph.add_node(Node::new(7));
let e1 = simple_graph.add_edge(Edge::new(n1, n2, 'c')).unwrap_or_else(|error| panic!("The edge refers nonexistent nodes: {:?}", error));
let adjacency_array = AdjacencyArray::from(&simple_graph);

let mut node_iter = adjacency_array.node_id_iter();
let mut edge_iter = adjacency_array.edge_id_iter();
assert_eq!(node_iter.next(), Some(n1)); // The order of the nodes is guaranteed to stay the same
assert_eq!(node_iter.next(), Some(n2));
assert_eq!(node_iter.next(), None);
assert_eq!(adjacency_array.edge(edge_iter.next().expect("Edge was not converted correctly")), simple_graph.edge(e1));
assert_eq!(edge_iter.next(), None);

Modules

iterators

Iterator types for the SimpleGraph.

Structs

SimpleGraph

A simple graph representation that is inefficient to use, but cheap to construct.