Trait traitgraph::interface::MutableGraphContainer
source · pub trait MutableGraphContainer: ImmutableGraphContainer {
// Required methods
fn node_data_mut(&mut self, node_id: Self::NodeIndex) -> &mut Self::NodeData;
fn edge_data_mut(&mut self, edge_id: Self::EdgeIndex) -> &mut Self::EdgeData;
fn add_node(&mut self, node_data: Self::NodeData) -> Self::NodeIndex;
fn add_edge(
&mut self,
from: Self::NodeIndex,
to: Self::NodeIndex,
edge_data: Self::EdgeData
) -> Self::EdgeIndex;
fn remove_node(
&mut self,
node_id: Self::NodeIndex
) -> Option<Self::NodeData>;
fn remove_edge(
&mut self,
edge_id: Self::EdgeIndex
) -> Option<Self::EdgeData>;
fn remove_edges_sorted(&mut self, edge_ids: &[Self::EdgeIndex]);
fn clear(&mut self);
// Provided method
fn remove_nodes_sorted_slice(&mut self, node_ids: &[Self::NodeIndex]) { ... }
}
Expand description
A container that allows adding and removing nodes and edges.
Required Methods§
sourcefn node_data_mut(&mut self, node_id: Self::NodeIndex) -> &mut Self::NodeData
fn node_data_mut(&mut self, node_id: Self::NodeIndex) -> &mut Self::NodeData
Returns a mutable reference to the node data associated with the given node id, or None if there is no such node.
sourcefn edge_data_mut(&mut self, edge_id: Self::EdgeIndex) -> &mut Self::EdgeData
fn edge_data_mut(&mut self, edge_id: Self::EdgeIndex) -> &mut Self::EdgeData
Returns a mutable reference to the edge data associated with the given edge id, or None if there is no such edge.
sourcefn add_node(&mut self, node_data: Self::NodeData) -> Self::NodeIndex
fn add_node(&mut self, node_data: Self::NodeData) -> Self::NodeIndex
Adds a new node with the given NodeData
to the graph.
sourcefn add_edge(
&mut self,
from: Self::NodeIndex,
to: Self::NodeIndex,
edge_data: Self::EdgeData
) -> Self::EdgeIndex
fn add_edge( &mut self, from: Self::NodeIndex, to: Self::NodeIndex, edge_data: Self::EdgeData ) -> Self::EdgeIndex
Adds a new edge with the given EdgeData
to the graph.
sourcefn remove_node(&mut self, node_id: Self::NodeIndex) -> Option<Self::NodeData>
fn remove_node(&mut self, node_id: Self::NodeIndex) -> Option<Self::NodeData>
Removes the node with the given id from the graph. Note that this may change the ids of existing nodes.
sourcefn remove_edge(&mut self, edge_id: Self::EdgeIndex) -> Option<Self::EdgeData>
fn remove_edge(&mut self, edge_id: Self::EdgeIndex) -> Option<Self::EdgeData>
Removes the edge with the given id from the graph. Note that this may change the ids of existing edges.
sourcefn remove_edges_sorted(&mut self, edge_ids: &[Self::EdgeIndex])
fn remove_edges_sorted(&mut self, edge_ids: &[Self::EdgeIndex])
Removes the edges with the given ids from the graph. The ids are expected to be given in sorted order.
Note that this may change the ids of existing edges.
Provided Methods§
sourcefn remove_nodes_sorted_slice(&mut self, node_ids: &[Self::NodeIndex])
fn remove_nodes_sorted_slice(&mut self, node_ids: &[Self::NodeIndex])
Removes all nodes with the given ids from the graph. The nodes must be passed as a slice and sorted in ascending order. Note that this may change the ids of existing nodes.