Trait fast_graph::categories::Categorized
source · 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§
sourcefn 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.
sourcefn create_category(
&mut self,
category: &str,
nodes: Vec<NodeID>,
data: C
) -> Result<NodeID, String>
fn create_category( &mut self, category: &str, nodes: Vec<NodeID>, data: C ) -> Result<NodeID, String>
sourcefn all_categories(&self) -> Vec<(&String, NodeID)>
fn all_categories(&self) -> Vec<(&String, NodeID)>
Returns a list of all categories.
sourcefn category_by_id(&self, category: NodeID) -> Result<&Node<N>, GraphError>
fn category_by_id(&self, category: NodeID) -> Result<&Node<N>, GraphError>
Returns the category node by ID.
sourcefn 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.
sourcefn 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.
Provided Methods§
sourcefn category_exists(&self, category_name: &str) -> bool
fn category_exists(&self, category_name: &str) -> bool
Checks if the category exists by name.
sourcefn add_to_category_by_id(
&mut self,
category_id: NodeID,
nodes: Vec<NodeID>
) -> Result<(), CategorizedGraphError>
fn add_to_category_by_id( &mut self, category_id: NodeID, nodes: Vec<NodeID> ) -> Result<(), CategorizedGraphError>
Adds a list of nodes to a category by ID. Returns Ok(())
if successful, otherwise returns Error(CategorizedGraphError::CategoryNotFound).
sourcefn 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.
sourcefn 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.
sourcefn category_exists_by_id(&self, category: NodeID) -> bool
fn category_exists_by_id(&self, category: NodeID) -> bool
Checks if the category exists by ID.
Object Safety§
This trait is not object safe.