pub struct Graph<Node, EdgeData> {
pub nodes: HashMap<NodeIndex, Node>,
pub edges: HashMap<EdgeIndex, Edge<EdgeData>>,
}
Expand description
A graph generic over node and edge data.
Nodes and edges are public because this graph makes no guarantees as to its structure beyond being a graph.
The graph does provide convenience functions for some simple operations over its data.
Fields§
§nodes: HashMap<NodeIndex, Node>
§edges: HashMap<EdgeIndex, Edge<EdgeData>>
Implementations§
Source§impl<Node, EdgeData> Graph<Node, EdgeData>
impl<Node, EdgeData> Graph<Node, EdgeData>
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new graph with empty nodes and edges.
To initialize with capacity or other pre-defined settings, create it using public fields.
Sourcepub fn nodes<'a>(&'a self) -> impl Iterator + 'a
pub fn nodes<'a>(&'a self) -> impl Iterator + 'a
An iterator over this graph’s nodes, in no particular order.
Sourcepub fn edges<'a>(&'a self) -> impl Iterator + 'a
pub fn edges<'a>(&'a self) -> impl Iterator + 'a
An iterator over this graph’s edges, in no particular order.
Sourcepub fn edge(&mut self, edge: Edge<EdgeData>) -> EdgeIndex
pub fn edge(&mut self, edge: Edge<EdgeData>) -> EdgeIndex
A convenience function to insert an edge at a new index.
Sourcepub fn r_edge(&mut self, idx: EdgeIndex) -> Option<Edge<EdgeData>>
pub fn r_edge(&mut self, idx: EdgeIndex) -> Option<Edge<EdgeData>>
Attempt to remove an edge from this graph, returning it if it existed.
Trait Implementations§
Auto Trait Implementations§
impl<Node, EdgeData> Freeze for Graph<Node, EdgeData>
impl<Node, EdgeData> RefUnwindSafe for Graph<Node, EdgeData>where
Node: RefUnwindSafe,
EdgeData: RefUnwindSafe,
impl<Node, EdgeData> Send for Graph<Node, EdgeData>
impl<Node, EdgeData> Sync for Graph<Node, EdgeData>
impl<Node, EdgeData> Unpin for Graph<Node, EdgeData>
impl<Node, EdgeData> UnwindSafe for Graph<Node, EdgeData>where
Node: UnwindSafe,
EdgeData: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more