pub struct Hypergraph<N: Node, E: EdgeWeight, Ix: IndexType = u32> { /* private fields */ }Expand description
A hypergraph structure
Implementations§
Source§impl<N: Node + Debug, E: EdgeWeight, Ix: IndexType> Hypergraph<N, E, Ix>
impl<N: Node + Debug, E: EdgeWeight, Ix: IndexType> Hypergraph<N, E, Ix>
Sourcepub fn hyperedges(&self) -> &Vec<Hyperedge<N, E>>
pub fn hyperedges(&self) -> &Vec<Hyperedge<N, E>>
Get all hyperedges in the hypergraph
Sourcepub fn add_hyperedge_from_vec(
&mut self,
nodes: Vec<N>,
weight: E,
) -> Result<usize>where
N: Clone,
pub fn add_hyperedge_from_vec(
&mut self,
nodes: Vec<N>,
weight: E,
) -> Result<usize>where
N: Clone,
Add a hyperedge from a vector of nodes
Sourcepub fn add_hyperedge(&mut self, nodes: Vec<N>, weight: E) -> Result<usize>where
N: Clone,
pub fn add_hyperedge(&mut self, nodes: Vec<N>, weight: E) -> Result<usize>where
N: Clone,
Add a hyperedge
Sourcepub fn are_connected(&self, source: &N, target: &N) -> boolwhere
N: PartialEq,
pub fn are_connected(&self, source: &N, target: &N) -> boolwhere
N: PartialEq,
Check if two nodes are connected through any hyperedge
Sourcepub fn connecting_hyperedges(
&self,
source: &N,
target: &N,
) -> Vec<&Hyperedge<N, E>>where
N: PartialEq,
pub fn connecting_hyperedges(
&self,
source: &N,
target: &N,
) -> Vec<&Hyperedge<N, E>>where
N: PartialEq,
Get hyperedges that connect two nodes
Sourcepub fn hyperedges_containing_node(&self, node: &N) -> Vec<&Hyperedge<N, E>>where
N: PartialEq,
pub fn hyperedges_containing_node(&self, node: &N) -> Vec<&Hyperedge<N, E>>where
N: PartialEq,
Get all hyperedges containing a specific node
Sourcepub fn neighbors(&self, node: &N) -> Vec<N>
pub fn neighbors(&self, node: &N) -> Vec<N>
Get neighbors of a node (all nodes connected through hyperedges)
Sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
Get the number of nodes in the hypergraph
Sourcepub fn hyperedge_count(&self) -> usize
pub fn hyperedge_count(&self) -> usize
Get the number of hyperedges in the hypergraph
Sourcepub fn degree(&self, node: &N) -> usizewhere
N: PartialEq,
pub fn degree(&self, node: &N) -> usizewhere
N: PartialEq,
Get the degree of a node (number of hyperedges it belongs to)
Sourcepub fn remove_hyperedge(
&mut self,
hyperedge_id: usize,
) -> Result<Hyperedge<N, E>>
pub fn remove_hyperedge( &mut self, hyperedge_id: usize, ) -> Result<Hyperedge<N, E>>
Remove a hyperedge by its ID
Sourcepub fn incidence_matrix(&self) -> Vec<Vec<f64>>
pub fn incidence_matrix(&self) -> Vec<Vec<f64>>
Get the incidence matrix of the hypergraph Returns a matrix where rows represent nodes and columns represent hyperedges A value of 1.0 indicates the node is in the hyperedge, 0.0 otherwise
Sourcepub fn maximal_cliques(&self) -> Vec<Vec<N>>
pub fn maximal_cliques(&self) -> Vec<Vec<N>>
Find maximal cliques in the hypergraph This is a simplified implementation that finds connected components A more sophisticated algorithm would be needed for true maximal cliques
Sourcepub fn hyperedge_size_stats(&self) -> (usize, usize, f64)
pub fn hyperedge_size_stats(&self) -> (usize, usize, f64)
Get statistics about hyperedge sizes Returns (min_size, max_size, avg_size)
Sourcepub fn is_uniform(&self) -> bool
pub fn is_uniform(&self) -> bool
Check if the hypergraph is uniform (all hyperedges have the same size)
Trait Implementations§
Auto Trait Implementations§
impl<N, E, Ix> Freeze for Hypergraph<N, E, Ix>
impl<N, E, Ix> RefUnwindSafe for Hypergraph<N, E, Ix>
impl<N, E, Ix> Send for Hypergraph<N, E, Ix>where
Ix: Send,
impl<N, E, Ix> Sync for Hypergraph<N, E, Ix>where
Ix: Sync,
impl<N, E, Ix> Unpin for Hypergraph<N, E, Ix>
impl<N, E, Ix> UnwindSafe for Hypergraph<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