pub trait Categorized<N, E, C>: GraphInterface<NodeData = N, EdgeData = 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> where E: Default + Clone, N: Clone + Default; fn all_categories(&self) -> Vec<(&String, NodeID)>; fn category(&self, category: &str) -> Option<&Node<N>>; fn category_by_id(&self, category: NodeID) -> Result<&Node<N>, GraphError>; 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<(), CategorizedGraphError> where E: Default + Clone, N: Clone { ... } 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 where E: Default + Clone, N: Clone + Default { ... } 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>
where E: Default + Clone, N: Clone + Default,

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

Returns the NodeID of the category if successful, otherwise returns Error(CategorizedGraphError::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) -> Result<&Node<N>, GraphError>

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<(), CategorizedGraphError>
where E: Default + Clone, N: Clone,

Adds a list of nodes to a category by ID. Returns Ok(()) if successful, otherwise returns Error(CategorizedGraphError::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
where E: Default + Clone, N: Clone + Default,

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.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<N, E> Categorized<N, E, N> for CategorizedGraph<N, E>
where Self: GraphInterface<NodeData = N, EdgeData = E>,