Struct fast_graph::categories::CategorizedGraph
source · pub struct CategorizedGraph<N, E> {
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§
source§impl<N, E> CategorizedGraph<N, E>
impl<N, E> CategorizedGraph<N, E>
Trait Implementations§
source§impl<N, E> Categorized<N, E, N> for CategorizedGraph<N, E>where
Self: GraphInterface<NodeData = N, EdgeData = E>,
impl<N, E> Categorized<N, E, N> for CategorizedGraph<N, E>where
Self: GraphInterface<NodeData = N, EdgeData = 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) -> Result<&Node<N>, GraphError>
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>
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 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, E> GraphInterface for CategorizedGraph<N, E>
impl<N, E> GraphInterface for CategorizedGraph<N, E>
type NodeData = N
type EdgeData = E
fn nodes(&self) -> impl Iterator<Item = NodeID>
fn node_count(&self) -> usize
fn remove_node(&mut self, id: NodeID) -> Result<(), GraphError>
fn remove_edge(&mut self, id: EdgeID) -> Result<(), GraphError>
fn add_node(&mut self, data: N) -> NodeID
fn add_nodes(&mut self, data: &[N]) -> Vec<NodeID>where
N: Clone,
fn add_edges(&mut self, data: &[(NodeID, NodeID)]) -> Vec<EdgeID>
fn add_edge(&mut self, from: NodeID, to: NodeID, data: E) -> EdgeID
fn node(&self, id: NodeID) -> Result<&Node<N>, GraphError>
fn node_mut(&mut self, id: NodeID) -> Result<&mut Node<N>, GraphError>
fn edge(&self, id: EdgeID) -> Result<&Edge<E>, GraphError>
fn edge_mut(&mut self, id: EdgeID) -> Result<&mut Edge<E>, GraphError>
fn remove_nodes(&mut self, ids: &[NodeID]) -> Result<(), GraphError>
Auto Trait Implementations§
impl<N, E> Freeze for CategorizedGraph<N, E>
impl<N, E> RefUnwindSafe for CategorizedGraph<N, E>where
N: RefUnwindSafe,
E: RefUnwindSafe,
impl<N, E> Send for CategorizedGraph<N, E>
impl<N, E> Sync for CategorizedGraph<N, E>
impl<N, E> Unpin for CategorizedGraph<N, E>
impl<N, E> UnwindSafe for CategorizedGraph<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
source§impl<'a, G> IterDepthFirst<'a, G> for Gwhere
G: GraphInterface,
impl<'a, G> IterDepthFirst<'a, G> for Gwhere
G: GraphInterface,
source§fn connected_components(&'a self) -> Vec<HashSet<NodeID>>
fn connected_components(&'a self) -> Vec<HashSet<NodeID>>
Returns a vector of sets of node IDs, where each set is a connected component.
Starts a DFS at every node (except if it’s already been visited) and marks all reachable nodes as being part of the same component.
source§fn iter_depth_first(&'a self, start: NodeID) -> DepthFirstSearch<'a, G> ⓘ
fn iter_depth_first(&'a self, start: NodeID) -> DepthFirstSearch<'a, G> ⓘ
Returns a depth first search iterator starting from a given node