Struct fast_graph::categories::CategoryGraph
source · pub struct CategoryGraph<N: Clone, E: Clone> {
pub nodes: SlotMap<NodeID, Node<N>>,
pub edges: SlotMap<EdgeID, Edge<E>>,
pub categories: HashMap<String, NodeID>,
}Expand description
A graph with category nodes (where the nodes contain an ID of the category and a list of nodes in that category) and a hash map that maps category names to category nodes efficiently.
Fields§
§nodes: SlotMap<NodeID, Node<N>>§edges: SlotMap<EdgeID, Edge<E>>§categories: HashMap<String, NodeID>Implementations§
Trait Implementations§
source§impl<N: Clone + Default, E: Clone + Default> Categorized<N, E, N> for CategoryGraph<N, E>where
Self: GraphWriter<N, E>,
impl<N: Clone + Default, E: Clone + Default> Categorized<N, E, N> for CategoryGraph<N, E>where
Self: GraphWriter<N, E>,
source§fn category_id_by_name(&self, category_name: &str) -> Option<&NodeID>
fn category_id_by_name(&self, category_name: &str) -> Option<&NodeID>
Returns the category ID by name. In the standard implementation this is a hashmap lookup.
source§fn insert_category_id_by_name(
&mut self,
category_name: &str,
category_id: NodeID
)
fn insert_category_id_by_name( &mut self, category_name: &str, category_id: NodeID )
In the default implementation this is used to insert the category ID into the hashmap.
source§fn create_category(
&mut self,
category: &str,
nodes: Vec<NodeID>,
data: N
) -> Result<NodeID, String>
fn create_category( &mut self, category: &str, nodes: Vec<NodeID>, data: N ) -> Result<NodeID, String>
source§fn category_by_id(&self, category: NodeID) -> Option<&Node<N>>
fn category_by_id(&self, category: NodeID) -> Option<&Node<N>>
Returns the category node by ID.
source§fn nodes_by_category_id(&self, category: NodeID) -> Vec<NodeID>
fn nodes_by_category_id(&self, category: NodeID) -> Vec<NodeID>
Returns a list of nodes in the category by ID.
source§fn nodes_by_category(&self, category: &str) -> Vec<NodeID>
fn nodes_by_category(&self, category: &str) -> Vec<NodeID>
Returns a list of nodes in the category by name.
source§fn category_exists(&self, category_name: &str) -> bool
fn category_exists(&self, category_name: &str) -> bool
Checks if the category exists by name.
source§fn add_to_category_by_id(
&mut self,
category_id: NodeID,
nodes: Vec<NodeID>
) -> Result<(), CategoryGraphError>
fn add_to_category_by_id( &mut self, category_id: NodeID, nodes: Vec<NodeID> ) -> Result<(), CategoryGraphError>
Adds a list of nodes to a category by ID. Returns
Ok(()) if successful, otherwise returns Error(CategoryGraphError::CategoryNotFound).source§fn add_to_category(&mut self, category_name: &str, nodes: Vec<NodeID>) -> NodeID
fn add_to_category(&mut self, category_name: &str, nodes: Vec<NodeID>) -> NodeID
If the category does not exist, it is created. Returns the NodeID of the category.
source§fn category_exists_by_id(&self, category: NodeID) -> bool
fn category_exists_by_id(&self, category: NodeID) -> bool
Checks if the category exists by ID.
source§impl<N: Clone + Clone, E: Clone + Clone> Clone for CategoryGraph<N, E>
impl<N: Clone + Clone, E: Clone + Clone> Clone for CategoryGraph<N, E>
source§fn clone(&self) -> CategoryGraph<N, E>
fn clone(&self) -> CategoryGraph<N, E>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moresource§impl<N: Clone, E: Clone> SlotMapGraph<N, E> for CategoryGraph<N, E>
impl<N: Clone, E: Clone> SlotMapGraph<N, E> for CategoryGraph<N, E>
fn nodes(&self) -> &SlotMap<NodeID, Node<N>>
fn nodes_mut(&mut self) -> &mut SlotMap<NodeID, Node<N>>
fn edges(&self) -> &SlotMap<EdgeID, Edge<E>>
fn edges_mut(&mut self) -> &mut SlotMap<EdgeID, Edge<E>>
fn node(&self, id: NodeID) -> Option<&Node<N>>
fn node_mut(&mut self, id: NodeID) -> Option<&mut Node<N>>
fn edge(&self, id: EdgeID) -> Option<&Edge<E>>
fn edge_mut(&mut self, id: EdgeID) -> Option<&mut Edge<E>>
Auto Trait Implementations§
impl<N, E> Freeze for CategoryGraph<N, E>
impl<N, E> RefUnwindSafe for CategoryGraph<N, E>where
N: RefUnwindSafe,
E: RefUnwindSafe,
impl<N, E> Send for CategoryGraph<N, E>
impl<N, E> Sync for CategoryGraph<N, E>
impl<N, E> Unpin for CategoryGraph<N, E>
impl<N, E> UnwindSafe for CategoryGraph<N, E>where
N: UnwindSafe,
E: 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