pub struct BitGraph { /* private fields */ }
Expand description
A BitGraph
is an undirected graph data structure
Its capacity is limited to mem::size_of::<usize>.pow(4)
Implementations§
Source§impl BitGraph
impl BitGraph
Sourcepub fn with_capacity(capacity: u32) -> BitGraph
pub fn with_capacity(capacity: u32) -> BitGraph
Creates a new BitGraph preallocated with up to capacity
vertices
It is not possible later add vertices >= capacity
Sourcepub fn complete(capacity: u32) -> BitGraph
pub fn complete(capacity: u32) -> BitGraph
Creates a new BitGraph with capacity
vertices, with all vertices connected to each other.
It is not possible later add vertices >= capacity
Sourcepub fn add_edge(&mut self, u: u32, v: u32)
pub fn add_edge(&mut self, u: u32, v: u32)
Adds a new undirected edge from u
to v
If the edge already exists, the graph is not updated
It is not possible to add edges with endpoints >= capacity
Sourcepub fn add_edge_unchecked(&mut self, u: u32, v: u32)
pub fn add_edge_unchecked(&mut self, u: u32, v: u32)
Same as add_edge
except that no boundary checks are performed.
Can corrupt the underlying data
Sourcepub fn remove_edge(&mut self, u: u32, v: u32)
pub fn remove_edge(&mut self, u: u32, v: u32)
Removes the edge from u
to v
after performing boundary checks.
If the edge is not present the graph is not updated
Sourcepub fn remove_edge_unchecked(&mut self, u: u32, v: u32)
pub fn remove_edge_unchecked(&mut self, u: u32, v: u32)
Same as remove_edge
except that no boundary checks are performed
Can corrupt the underlying data
Sourcepub fn contract_edge(&mut self, target: u32, source: u32)
pub fn contract_edge(&mut self, target: u32, source: u32)
Contracts the edge (target, source) by adding all neighbors
of source to target
and removing source
Sourcepub fn contract_edge_unchecked(&mut self, target: u32, source: u32)
pub fn contract_edge_unchecked(&mut self, target: u32, source: u32)
Same as contract_edge
without any boundary checks
This is very unsafe, and can corrupt the entire graph if the function is called
with invalid arguments
Sourcepub fn neighbors(&self, v: u32) -> BitIter<&BitSet>
pub fn neighbors(&self, v: u32) -> BitIter<&BitSet>
Returns an iterator over the neighborhood of vertex v
Sourcepub fn dfs(&self, v: u32) -> DfsIterator<'_> ⓘ
pub fn dfs(&self, v: u32) -> DfsIterator<'_> ⓘ
Returns a DfsIterator
starting at vertex v
Trait Implementations§
Auto Trait Implementations§
impl Freeze for BitGraph
impl RefUnwindSafe for BitGraph
impl Send for BitGraph
impl Sync for BitGraph
impl Unpin for BitGraph
impl UnwindSafe for BitGraph
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more