Skip to main content

BipartiteHypergraph

Struct BipartiteHypergraph 

Source
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>
where N: Clone + Eq + Hash, E: Clone + Eq + Hash,

Source

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}
Source

pub fn add_node(&mut self, weight: N, side: bool) -> usize

Source

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}
Source

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}
Source

pub fn add_edges( &mut self, edges: impl Iterator<Item = (E, Vec<usize>, Vec<usize>)>, ) -> Result<(), HypergraphErrors>

Source

pub fn remove_node(&mut self, node_index: usize) -> Option<DirectedNode<N>>

Source

pub fn remove_nodes(&mut self, node_indices: Vec<usize>) -> Vec<DirectedNode<N>>

Source

pub fn remove_edge(&mut self, edge_index: usize) -> Option<DirectedEdge<E>>

Source

pub fn remove_edges(&mut self, edge_indices: Vec<usize>) -> Vec<DirectedEdge<E>>

Source

pub fn get_in_neighbours(&self, node_index: usize) -> Option<HashSet<&usize>>

Source

pub fn get_out_neighbours(&self, node_index: usize) -> Option<HashSet<&usize>>

Source

pub fn get_in_edges(&self, node_index: usize) -> Option<&Vec<usize>>

Source

pub fn get_out_edges(&self, node_index: usize) -> Option<&Vec<usize>>

Source

pub fn induced_shgraph(&self, node_indices: &[usize]) -> Self
where E: Clone + Eq + Hash, N: Clone,

Source

pub fn shgraph_by_order<const ORDER: usize>( &self, ) -> UniformHypergraph<N, E, ORDER>
where E: Clone + Eq + Hash, N: Clone,

Maybe change this to kpartite once I do that.

Trait Implementations§

Source§

impl<'a, N, E> GraphBasics<'a> for BipartiteHypergraph<N, E>
where N: 'a + Clone + Eq + Hash, E: 'a + Clone + Eq + Hash,

Source§

type NodeRef = <Hypergraph<N, E> as GraphBasics<'a>>::NodeRef

Source§

type EdgeRef = <Hypergraph<N, E> as GraphBasics<'a>>::EdgeRef

Source§

type EdgeIndex = <Hypergraph<N, E> as GraphBasics<'a>>::EdgeIndex

Source§

type NodeIndex = <Hypergraph<N, E> as GraphBasics<'a>>::NodeIndex

Source§

fn nodes(&'a self) -> impl Iterator<Item = Self::NodeRef>

Source§

fn edges(&'a self) -> impl Iterator<Item = Self::EdgeRef>

Source§

fn node_count(&'a self) -> usize

Source§

fn edge_count(&'a self) -> usize

Source§

fn is_directed(&self) -> bool

Source§

fn node( &'a self, node_index: <Self as GraphBasics<'a>>::NodeIndex, ) -> Option<<Self as GraphBasics<'a>>::NodeRef>

Source§

fn edge( &'a self, edge_index: <Self as GraphBasics<'a>>::EdgeIndex, ) -> Option<<Self as GraphBasics<'a>>::EdgeRef>

Source§

fn node_iter( &'a self, node_index: impl Iterator<Item = <Self as GraphBasics<'a>>::NodeIndex>, ) -> impl Iterator<Item = Option<<Self as GraphBasics<'a>>::NodeRef>>

Source§

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,

Source§

type Inner = Hypergraph<N, E>

Source§

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>

§

impl<N, E> Send for BipartiteHypergraph<N, E>
where N: Send, E: Send,

§

impl<N, E> Sync for BipartiteHypergraph<N, E>
where N: Sync, E: Sync,

§

impl<N, E> Unpin for BipartiteHypergraph<N, E>
where N: Unpin, E: Unpin,

§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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 more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

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

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.