pub struct BipartiteGraph<N: Node, E: EdgeWeight, Ix: IndexType = u32> { /* private fields */ }
Expand description
A specialized bipartite graph structure
A bipartite graph is a graph whose vertices can be divided into two disjoint sets such that no two vertices within the same set are adjacent. This implementation enforces the bipartite property and provides optimized operations.
Implementations§
Source§impl<N: Node + Debug, E: EdgeWeight, Ix: IndexType> BipartiteGraph<N, E, Ix>
impl<N: Node + Debug, E: EdgeWeight, Ix: IndexType> BipartiteGraph<N, E, Ix>
Sourcepub fn from_graph(graph: Graph<N, E, Ix>) -> Result<Self>
pub fn from_graph(graph: Graph<N, E, Ix>) -> Result<Self>
Sourcepub fn add_node_to_set_a(&mut self, node: N)
pub fn add_node_to_set_a(&mut self, node: N)
Add a node to set A of the bipartition
Sourcepub fn add_node_to_set_b(&mut self, node: N)
pub fn add_node_to_set_b(&mut self, node: N)
Add a node to set B of the bipartition
Sourcepub fn set_a_size(&self) -> usize
pub fn set_a_size(&self) -> usize
Get the size of set A
Sourcepub fn set_b_size(&self) -> usize
pub fn set_b_size(&self) -> usize
Get the size of set B
Sourcepub fn neighbors(&self, node: &N) -> Result<Vec<N>>where
N: Clone,
pub fn neighbors(&self, node: &N) -> Result<Vec<N>>where
N: Clone,
Get neighbors of a node (always from the opposite set)
Sourcepub fn neighbors_in_a(&self, node: &N) -> Result<Vec<N>>where
N: Clone,
pub fn neighbors_in_a(&self, node: &N) -> Result<Vec<N>>where
N: Clone,
Get neighbors in set A for a node in set B
Sourcepub fn neighbors_in_b(&self, node: &N) -> Result<Vec<N>>where
N: Clone,
pub fn neighbors_in_b(&self, node: &N) -> Result<Vec<N>>where
N: Clone,
Get neighbors in set B for a node in set A
Sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
Number of nodes in the graph
Sourcepub fn edge_count(&self) -> usize
pub fn edge_count(&self) -> usize
Number of edges in the graph
Sourcepub fn has_edge(&self, source: &N, target: &N) -> bool
pub fn has_edge(&self, source: &N, target: &N) -> bool
Check if an edge exists between two nodes
Sourcepub fn edge_weight(&self, source: &N, target: &N) -> Result<E>where
E: Clone,
pub fn edge_weight(&self, source: &N, target: &N) -> Result<E>where
E: Clone,
Get the weight of an edge between two nodes
Sourcepub fn biadjacency_matrix(&self) -> Array2<E>
pub fn biadjacency_matrix(&self) -> Array2<E>
Get the adjacency matrix representation of the bipartite graph
Returns a matrix where rows correspond to set A and columns to set B
Sourcepub fn is_complete(&self) -> bool
pub fn is_complete(&self) -> bool
Check if the graph is complete bipartite (all possible edges exist)
Trait Implementations§
Auto Trait Implementations§
impl<N, E, Ix> Freeze for BipartiteGraph<N, E, Ix>
impl<N, E, Ix> RefUnwindSafe for BipartiteGraph<N, E, Ix>
impl<N, E, Ix> Send for BipartiteGraph<N, E, Ix>where
Ix: Send,
impl<N, E, Ix> Sync for BipartiteGraph<N, E, Ix>where
Ix: Sync,
impl<N, E, Ix> Unpin for BipartiteGraph<N, E, Ix>
impl<N, E, Ix> UnwindSafe for BipartiteGraph<N, E, Ix>
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> 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