pub trait Categorized<N: Clone + Default, E: Clone + Default, C: Clone>: SlotMapGraph<N, E> {
Show 14 methods // Required methods fn category_id_by_name(&self, category_name: &str) -> Option<&NodeID>; fn create_category( &mut self, category: &str, nodes: Vec<NodeID>, data: C ) -> Result<NodeID, String>; fn all_categories(&self) -> Vec<(&String, NodeID)>; fn category(&self, category: &str) -> Option<&Node<N>>; fn category_by_id(&self, category: NodeID) -> Option<&Node<N>>; fn nodes_by_category_id(&self, category: NodeID) -> Vec<NodeID>; fn nodes_by_category(&self, category: &str) -> Vec<NodeID>; // Provided methods fn category_exists(&self, category_name: &str) -> bool { ... } fn add_to_category_by_id( &mut self, category_id: NodeID, nodes: Vec<NodeID> ) -> Result<(), CategoryGraphError> { ... } fn insert_category_id_by_name( &mut self, category_name: &str, category_id: NodeID ) { ... } fn add_to_category( &mut self, category_name: &str, nodes: Vec<NodeID> ) -> NodeID { ... } fn category_exists_by_id(&self, category: NodeID) -> bool { ... } fn nodes_by_categories(&self, categories: Vec<&str>) -> Vec<NodeID> { ... } fn nodes_by_category_ids(&self, categories: Vec<NodeID>) -> Vec<NodeID> { ... }
}
Expand description

Methods for a graph with categories.

Required Methods§

source

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 create_category( &mut self, category: &str, nodes: Vec<NodeID>, data: C ) -> Result<NodeID, String>

Creates a new category Node with the given name, nodes, and (optionally) data.

Returns the NodeID of the category if successful, otherwise returns Error(CategoryGraphError::CategoryAlreadyExists).

An empty vector of nodes can be passed.

source

fn all_categories(&self) -> Vec<(&String, NodeID)>

Returns a list of all categories.

source

fn category(&self, category: &str) -> Option<&Node<N>>

Returns the category node by name.

source

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>

Returns a list of nodes in the category by ID.

source

fn nodes_by_category(&self, category: &str) -> Vec<NodeID>

Returns a list of nodes in the category by name.

Provided Methods§

source

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>

Adds a list of nodes to a category by ID. Returns Ok(()) if successful, otherwise returns Error(CategoryGraphError::CategoryNotFound).

source

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 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

Checks if the category exists by ID.

source

fn nodes_by_categories(&self, categories: Vec<&str>) -> Vec<NodeID>

Returns a list of nodes in the categories by name.

source

fn nodes_by_category_ids(&self, categories: Vec<NodeID>) -> Vec<NodeID>

Returns a list of nodes in the categories by ID.

Implementors§

source§

impl<N: Clone + Default, E: Clone + Default> Categorized<N, E, N> for CategoryGraph<N, E>
where Self: GraphWriter<N, E>,