pub struct BipartiteHypergraph<N, E> { /* private fields */ }Expand description
A hypergraph that preserves the bipartiteness invariant. Because of partiteness-weirdness, this has to be directed. I might make a different k-partite undirected graph over k-uniform hypergraphs.
Implementations§
Source§impl<N, E> BipartiteHypergraph<N, E>
impl<N, E> BipartiteHypergraph<N, E>
Sourcepub fn new() -> Self
pub fn new() -> Self
Examples found in repository?
examples/partite.rs (line 14)
4fn main() {
5 let mut g = partite::BipartiteGraph::<(), ()>::new();
6 // g.add_node((), 0);
7 // g.add_node((), 0);
8 // g.add_node((), 1);
9 g.add_nodes([((), 0), ((), 0), ((), 1)].into_iter());
10
11 dbg!(g.add_edge((), [0, 2])); // Ok
12 dbg!(g.add_edge((), [0, 1])); // Err
13
14 let mut g = partite::directed_bipartite::BipartiteHypergraph::<(), ()>::new();
15 // g.add_node((), false);
16 // g.add_node((), false);
17 // g.add_node((), true);
18 g.add_nodes([((), false), ((), false), ((), true)].into_iter());
19
20 dbg!(g.add_edge((), vec![0], vec![2])); // Ok
21 dbg!(g.add_edge((), vec![0], vec![1])); // Err
22 dbg!(g.add_edge((), vec![0, 1], vec![2])); // Ok
23 dbg!(g.add_edge((), vec![0, 2], vec![1])); // Err
24
25 let mut g = partite::kpartite::PartiteHypergraph::<(), (), 3>::new();
26 // g.add_node((), 0);
27 // g.add_node((), 1);
28 // g.add_node((), 2);
29 // g.add_node((), 2);
30 g.add_nodes([((), 0), ((), 1), ((), 2), ((), 2)].into_iter());
31 dbg!(g.add_edge((), vec![0, 2])); // Ok
32 dbg!(g.add_edge((), vec![0, 1])); // Ok
33 dbg!(g.add_edge((), vec![0, 1, 2])); // Ok
34 dbg!(g.add_edge((), vec![0, 1, 2, 3])); // Err
35}pub fn add_node(&mut self, weight: N, side: bool) -> usize
Sourcepub fn add_edge(
&mut self,
weight: E,
source_indices: Vec<usize>,
target_indices: Vec<usize>,
) -> Result<usize, HypergraphErrors>
pub fn add_edge( &mut self, weight: E, source_indices: Vec<usize>, target_indices: Vec<usize>, ) -> Result<usize, HypergraphErrors>
Examples found in repository?
examples/partite.rs (line 20)
4fn main() {
5 let mut g = partite::BipartiteGraph::<(), ()>::new();
6 // g.add_node((), 0);
7 // g.add_node((), 0);
8 // g.add_node((), 1);
9 g.add_nodes([((), 0), ((), 0), ((), 1)].into_iter());
10
11 dbg!(g.add_edge((), [0, 2])); // Ok
12 dbg!(g.add_edge((), [0, 1])); // Err
13
14 let mut g = partite::directed_bipartite::BipartiteHypergraph::<(), ()>::new();
15 // g.add_node((), false);
16 // g.add_node((), false);
17 // g.add_node((), true);
18 g.add_nodes([((), false), ((), false), ((), true)].into_iter());
19
20 dbg!(g.add_edge((), vec![0], vec![2])); // Ok
21 dbg!(g.add_edge((), vec![0], vec![1])); // Err
22 dbg!(g.add_edge((), vec![0, 1], vec![2])); // Ok
23 dbg!(g.add_edge((), vec![0, 2], vec![1])); // Err
24
25 let mut g = partite::kpartite::PartiteHypergraph::<(), (), 3>::new();
26 // g.add_node((), 0);
27 // g.add_node((), 1);
28 // g.add_node((), 2);
29 // g.add_node((), 2);
30 g.add_nodes([((), 0), ((), 1), ((), 2), ((), 2)].into_iter());
31 dbg!(g.add_edge((), vec![0, 2])); // Ok
32 dbg!(g.add_edge((), vec![0, 1])); // Ok
33 dbg!(g.add_edge((), vec![0, 1, 2])); // Ok
34 dbg!(g.add_edge((), vec![0, 1, 2, 3])); // Err
35}Sourcepub fn add_nodes(&mut self, weights: impl Iterator<Item = (N, bool)>)
pub fn add_nodes(&mut self, weights: impl Iterator<Item = (N, bool)>)
Examples found in repository?
examples/partite.rs (line 18)
4fn main() {
5 let mut g = partite::BipartiteGraph::<(), ()>::new();
6 // g.add_node((), 0);
7 // g.add_node((), 0);
8 // g.add_node((), 1);
9 g.add_nodes([((), 0), ((), 0), ((), 1)].into_iter());
10
11 dbg!(g.add_edge((), [0, 2])); // Ok
12 dbg!(g.add_edge((), [0, 1])); // Err
13
14 let mut g = partite::directed_bipartite::BipartiteHypergraph::<(), ()>::new();
15 // g.add_node((), false);
16 // g.add_node((), false);
17 // g.add_node((), true);
18 g.add_nodes([((), false), ((), false), ((), true)].into_iter());
19
20 dbg!(g.add_edge((), vec![0], vec![2])); // Ok
21 dbg!(g.add_edge((), vec![0], vec![1])); // Err
22 dbg!(g.add_edge((), vec![0, 1], vec![2])); // Ok
23 dbg!(g.add_edge((), vec![0, 2], vec![1])); // Err
24
25 let mut g = partite::kpartite::PartiteHypergraph::<(), (), 3>::new();
26 // g.add_node((), 0);
27 // g.add_node((), 1);
28 // g.add_node((), 2);
29 // g.add_node((), 2);
30 g.add_nodes([((), 0), ((), 1), ((), 2), ((), 2)].into_iter());
31 dbg!(g.add_edge((), vec![0, 2])); // Ok
32 dbg!(g.add_edge((), vec![0, 1])); // Ok
33 dbg!(g.add_edge((), vec![0, 1, 2])); // Ok
34 dbg!(g.add_edge((), vec![0, 1, 2, 3])); // Err
35}pub fn add_edges( &mut self, edges: impl Iterator<Item = (E, Vec<usize>, Vec<usize>)>, ) -> Result<(), HypergraphErrors>
pub fn remove_node(&mut self, node_index: usize) -> Option<DirectedNode<N>>
pub fn remove_nodes(&mut self, node_indices: Vec<usize>) -> Vec<DirectedNode<N>>
pub fn remove_edge(&mut self, edge_index: usize) -> Option<DirectedEdge<E>>
pub fn remove_edges(&mut self, edge_indices: Vec<usize>) -> Vec<DirectedEdge<E>>
pub fn get_in_neighbours(&self, node_index: usize) -> Option<HashSet<&usize>>
pub fn get_out_neighbours(&self, node_index: usize) -> Option<HashSet<&usize>>
pub fn get_in_edges(&self, node_index: usize) -> Option<&Vec<usize>>
pub fn get_out_edges(&self, node_index: usize) -> Option<&Vec<usize>>
pub fn induced_shgraph(&self, node_indices: &[usize]) -> Self
Sourcepub fn shgraph_by_order<const ORDER: usize>(
&self,
) -> UniformHypergraph<N, E, ORDER>
pub fn shgraph_by_order<const ORDER: usize>( &self, ) -> UniformHypergraph<N, E, ORDER>
Maybe change this to kpartite once I do that.
Trait Implementations§
Source§impl<'a, N, E> GraphBasics<'a> for BipartiteHypergraph<N, E>
impl<'a, N, E> GraphBasics<'a> for BipartiteHypergraph<N, E>
type NodeRef = <Hypergraph<N, E> as GraphBasics<'a>>::NodeRef
type EdgeRef = <Hypergraph<N, E> as GraphBasics<'a>>::EdgeRef
type EdgeIndex = <Hypergraph<N, E> as GraphBasics<'a>>::EdgeIndex
type NodeIndex = <Hypergraph<N, E> as GraphBasics<'a>>::NodeIndex
fn nodes(&'a self) -> impl Iterator<Item = Self::NodeRef>
fn edges(&'a self) -> impl Iterator<Item = Self::EdgeRef>
fn node_count(&'a self) -> usize
fn edge_count(&'a self) -> usize
fn is_directed(&self) -> bool
fn node( &'a self, node_index: <Self as GraphBasics<'a>>::NodeIndex, ) -> Option<<Self as GraphBasics<'a>>::NodeRef>
fn edge( &'a self, edge_index: <Self as GraphBasics<'a>>::EdgeIndex, ) -> Option<<Self as GraphBasics<'a>>::EdgeRef>
fn node_iter( &'a self, node_index: impl Iterator<Item = <Self as GraphBasics<'a>>::NodeIndex>, ) -> impl Iterator<Item = Option<<Self as GraphBasics<'a>>::NodeRef>>
fn edge_iter( &'a self, edge_index: impl Iterator<Item = <Self as GraphBasics<'a>>::EdgeIndex>, ) -> impl Iterator<Item = Option<<Self as GraphBasics<'a>>::EdgeRef>>
Source§impl<'a, N, E> GraphWrapper<'a> for BipartiteHypergraph<N, E>where
DirectedHypergraph<N, E>: GraphBasics<'a>,
N: 'a + Clone + Eq + Hash,
E: 'a + Clone + Eq + Hash,
impl<'a, N, E> GraphWrapper<'a> for BipartiteHypergraph<N, E>where
DirectedHypergraph<N, E>: GraphBasics<'a>,
N: 'a + Clone + Eq + Hash,
E: 'a + Clone + Eq + Hash,
type Inner = Hypergraph<N, E>
fn into_inner(&'a self) -> &'a Self::Inner
Auto Trait Implementations§
impl<N, E> Freeze for BipartiteHypergraph<N, E>
impl<N, E> RefUnwindSafe for BipartiteHypergraph<N, E>where
N: RefUnwindSafe,
E: RefUnwindSafe,
impl<N, E> Send for BipartiteHypergraph<N, E>
impl<N, E> Sync for BipartiteHypergraph<N, E>
impl<N, E> Unpin for BipartiteHypergraph<N, E>
impl<N, E> UnsafeUnpin for BipartiteHypergraph<N, E>
impl<N, E> UnwindSafe for BipartiteHypergraph<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<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>
Converts
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>
Converts
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 moreSource§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.