pub struct Graph<T> { /* private fields */ }Expand description
The graph structure, containing a list of nodes.
Implementations§
Source§impl<T> Graph<T>
impl<T> Graph<T>
Sourcepub fn add_node(&mut self, value: T) -> usize
pub fn add_node(&mut self, value: T) -> usize
Adds a node with the given value to the graph. Returns the index of the new node.
Sourcepub fn add_edge(&self, from_index: usize, to_index: usize)
pub fn add_edge(&self, from_index: usize, to_index: usize)
Adds an edge from the node at from_index to the node at to_index.
Sourcepub fn get_node_value(&self, index: usize) -> Option<T>where
T: Clone,
pub fn get_node_value(&self, index: usize) -> Option<T>where
T: Clone,
Returns a clone of the value of the node at the given index.