pub struct ComponentResult {
pub assignments: HashMap<EntityId, usize>,
pub num_components: usize,
}Expand description
Result of a connected components computation.
Contains the component assignment for each node, along with metadata about the computation.
Fields§
§assignments: HashMap<EntityId, usize>Component assignments: node -> component ID. Component IDs are contiguous integers starting from 0.
num_components: usizeNumber of distinct components found.
Implementations§
Source§impl ComponentResult
impl ComponentResult
Sourcepub fn component(&self, node: EntityId) -> Option<usize>
pub fn component(&self, node: EntityId) -> Option<usize>
Get the component ID for a specific node.
Sourcepub fn nodes_in_component(&self, component_id: usize) -> Vec<EntityId>
pub fn nodes_in_component(&self, component_id: usize) -> Vec<EntityId>
Get all nodes in a specific component.
Sourcepub fn component_sizes(&self) -> HashMap<usize, usize>
pub fn component_sizes(&self) -> HashMap<usize, usize>
Get component sizes.
Sourcepub fn components_by_size(&self) -> Vec<(usize, usize)>
pub fn components_by_size(&self) -> Vec<(usize, usize)>
Get components sorted by size (descending).
Sourcepub fn largest_component(&self) -> Option<(usize, usize)>
pub fn largest_component(&self) -> Option<(usize, usize)>
Get the largest component.
Sourcepub fn smallest_component(&self) -> Option<(usize, usize)>
pub fn smallest_component(&self) -> Option<(usize, usize)>
Get the smallest component.
Sourcepub fn same_component(&self, node1: EntityId, node2: EntityId) -> bool
pub fn same_component(&self, node1: EntityId, node2: EntityId) -> bool
Check if two nodes are in the same component.
Sourcepub fn component_size(&self, component_id: usize) -> usize
pub fn component_size(&self, component_id: usize) -> usize
Get the number of nodes in a specific component.
Trait Implementations§
Source§impl Clone for ComponentResult
impl Clone for ComponentResult
Source§fn clone(&self) -> ComponentResult
fn clone(&self) -> ComponentResult
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ComponentResult
impl RefUnwindSafe for ComponentResult
impl Send for ComponentResult
impl Sync for ComponentResult
impl Unpin for ComponentResult
impl UnsafeUnpin for ComponentResult
impl UnwindSafe for ComponentResult
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