Struct hypergraph::Hypergraph

source ·
pub struct Hypergraph<V, HE> { /* private fields */ }
Expand description

A directed hypergraph composed of generic vertices and hyperedges.

Implementations§

source§

impl<V, HE> Hypergraph<V, HE>where V: VertexTrait, HE: HyperedgeTrait,

source

pub fn add_hyperedge( &mut self, vertices: Vec<VertexIndex>, weight: HE ) -> Result<HyperedgeIndex, HypergraphError<V, HE>>

Adds a hyperedge as an array of vertices indexes and a custom weight in the hypergraph. Returns the weighted index of the hyperedge.

source§

impl<V, HE> Hypergraph<V, HE>where V: VertexTrait, HE: HyperedgeTrait,

source

pub fn clear_hyperedges(&mut self) -> Result<(), HypergraphError<V, HE>>

Clears all the hyperedges from the hypergraph.

source§

impl<V, HE> Hypergraph<V, HE>where V: VertexTrait, HE: HyperedgeTrait,

source

pub fn contract_hyperedge_vertices( &mut self, hyperedge_index: HyperedgeIndex, vertices: Vec<VertexIndex>, target: VertexIndex ) -> Result<Vec<VertexIndex>, HypergraphError<V, HE>>

Contracts a set of the vertices of a hyperedge into one single vertex. Returns the updated vertices. Based on https://en.wikipedia.org/wiki/Edge_contraction

source§

impl<V, HE> Hypergraph<V, HE>where V: VertexTrait, HE: HyperedgeTrait,

source

pub fn count_hyperedges(&self) -> usize

Returns the number of hyperedges in the hypergraph.

source§

impl<V, HE> Hypergraph<V, HE>where V: VertexTrait, HE: HyperedgeTrait,

source

pub fn get_hyperedge_vertices( &self, hyperedge_index: HyperedgeIndex ) -> Result<Vec<VertexIndex>, HypergraphError<V, HE>>

Gets the vertices of a hyperedge.

source§

impl<V, HE> Hypergraph<V, HE>where V: VertexTrait, HE: HyperedgeTrait,

source

pub fn get_hyperedge_weight( &self, hyperedge_index: HyperedgeIndex ) -> Result<&HE, HypergraphError<V, HE>>

Gets the weight of a hyperedge from its index.

source§

impl<V, HE> Hypergraph<V, HE>where V: VertexTrait, HE: HyperedgeTrait,

source

pub fn get_hyperedges_connecting( &self, from: VertexIndex, to: VertexIndex ) -> Result<Vec<HyperedgeIndex>, HypergraphError<V, HE>>

Gets the hyperedges directly connecting a vertex to another.

source§

impl<V, HE> Hypergraph<V, HE>where V: VertexTrait, HE: HyperedgeTrait,

source

pub fn get_hyperedges_intersections( &self, hyperedges: Vec<HyperedgeIndex> ) -> Result<Vec<VertexIndex>, HypergraphError<V, HE>>

Gets the intersections of a set of hyperedges as a vector of vertices.

source§

impl<V, HE> Hypergraph<V, HE>where V: VertexTrait, HE: HyperedgeTrait,

source

pub fn join_hyperedges( &mut self, hyperedges: &[HyperedgeIndex] ) -> Result<(), HypergraphError<V, HE>>

Joins two or more hyperedges from the hypergraph into one single entity. All the vertices are moved to the first hyperedge in the provided order.

source§

impl<V, HE> Hypergraph<V, HE>where V: VertexTrait, HE: HyperedgeTrait,

source

pub fn remove_hyperedge( &mut self, hyperedge_index: HyperedgeIndex ) -> Result<(), HypergraphError<V, HE>>

Removes a hyperedge by index.

source§

impl<V, HE> Hypergraph<V, HE>where V: VertexTrait, HE: HyperedgeTrait,

source

pub fn reverse_hyperedge( &mut self, hyperedge_index: HyperedgeIndex ) -> Result<(), HypergraphError<V, HE>>

source§

impl<V, HE> Hypergraph<V, HE>where V: VertexTrait, HE: HyperedgeTrait,

source

pub fn update_hyperedge_vertices( &mut self, hyperedge_index: HyperedgeIndex, vertices: Vec<VertexIndex> ) -> Result<(), HypergraphError<V, HE>>

Updates the vertices of a hyperedge by index.

source§

impl<V, HE> Hypergraph<V, HE>where V: VertexTrait, HE: HyperedgeTrait,

source

pub fn update_hyperedge_weight( &mut self, hyperedge_index: HyperedgeIndex, weight: HE ) -> Result<(), HypergraphError<V, HE>>

Updates the weight of a hyperedge by index.

source§

impl<V, HE> Hypergraph<V, HE>where V: VertexTrait, HE: HyperedgeTrait,

source

pub fn add_vertex( &mut self, weight: V ) -> Result<VertexIndex, HypergraphError<V, HE>>

Adds a vertex with a custom weight to the hypergraph. Returns the index of the vertex.

source§

impl<V, HE> Hypergraph<V, HE>where V: VertexTrait, HE: HyperedgeTrait,

source

pub fn count_vertices(&self) -> usize

Returns the number of vertices in the hypergraph.

source§

impl<V, HE> Hypergraph<V, HE>where V: VertexTrait, HE: HyperedgeTrait,

source

pub fn get_adjacent_vertices_from( &self, from: VertexIndex ) -> Result<Vec<VertexIndex>, HypergraphError<V, HE>>

Gets the list of all vertices connected from a given vertex.

source§

impl<V, HE> Hypergraph<V, HE>where V: VertexTrait, HE: HyperedgeTrait,

source

pub fn get_adjacent_vertices_to( &self, to: VertexIndex ) -> Result<Vec<VertexIndex>, HypergraphError<V, HE>>

Gets the list of all vertices connected to a given vertex.

source§

impl<V, HE> Hypergraph<V, HE>where V: VertexTrait, HE: HyperedgeTrait,

source

pub fn get_dijkstra_connections( &self, from: VertexIndex, to: VertexIndex ) -> Result<Vec<(VertexIndex, Option<HyperedgeIndex>)>, HypergraphError<V, HE>>

Gets a list of the cheapest path of vertices between two vertices as a vector of tuples of the form (VertexIndex, Option<HyperedgeIndex>) where the second member is the hyperedge that has been traversed to reach the vertex. Please note that the initial tuple holds None as hyperedge since none has been traversed yet. The implementation of the algorithm is partially based on: https://doc.rust-lang.org/std/collections/binary_heap/#examples

source§

impl<V, HE> Hypergraph<V, HE>where V: VertexTrait, HE: HyperedgeTrait,

source

pub fn get_full_adjacent_vertices_from( &self, from: VertexIndex ) -> Result<Vec<(VertexIndex, Vec<HyperedgeIndex>)>, HypergraphError<V, HE>>

Gets the list of all vertices connected from a given vertex as tuples of the form (VertexIndex, Vec).

source§

impl<V, HE> Hypergraph<V, HE>where V: VertexTrait, HE: HyperedgeTrait,

source

pub fn get_full_adjacent_vertices_to( &self, to: VertexIndex ) -> Result<Vec<(VertexIndex, Vec<HyperedgeIndex>)>, HypergraphError<V, HE>>

Gets the list of all vertices connected to a given vertex as tuples of the form (VertexIndex, Vec).

source§

impl<V, HE> Hypergraph<V, HE>where V: VertexTrait, HE: HyperedgeTrait,

source

pub fn get_full_vertex_hyperedges( &self, vertex_index: VertexIndex ) -> Result<Vec<Vec<VertexIndex>>, HypergraphError<V, HE>>

Gets the hyperedges of a vertex as a vector of vectors of VertexIndex.

source§

impl<V, HE> Hypergraph<V, HE>where V: VertexTrait, HE: HyperedgeTrait,

source§

impl<V, HE> Hypergraph<V, HE>where V: VertexTrait, HE: HyperedgeTrait,

source§

impl<V, HE> Hypergraph<V, HE>where V: VertexTrait, HE: HyperedgeTrait,

source

pub fn get_vertex_hyperedges( &self, vertex_index: VertexIndex ) -> Result<Vec<HyperedgeIndex>, HypergraphError<V, HE>>

Gets the hyperedges of a vertex as a vector of HyperedgeIndex.

source§

impl<V, HE> Hypergraph<V, HE>where V: VertexTrait, HE: HyperedgeTrait,

source

pub fn get_vertex_weight( &self, vertex_index: VertexIndex ) -> Result<&V, HypergraphError<V, HE>>

Gets the weight of a vertex from its index.

source§

impl<V, HE> Hypergraph<V, HE>where V: VertexTrait, HE: HyperedgeTrait,

source

pub fn remove_vertex( &mut self, vertex_index: VertexIndex ) -> Result<(), HypergraphError<V, HE>>

Removes a vertex by index.

source§

impl<V, HE> Hypergraph<V, HE>where V: VertexTrait, HE: HyperedgeTrait,

source

pub fn update_vertex_weight( &mut self, vertex_index: VertexIndex, weight: V ) -> Result<(), HypergraphError<V, HE>>

Updates the weight of a vertex by index.

source§

impl<V, HE> Hypergraph<V, HE>where V: VertexTrait, HE: HyperedgeTrait,

Hypergraph implementations.

source

pub fn clear(&mut self)

Clears the hypergraph.

source

pub fn new() -> Self

Creates a new hypergraph with no allocation.

source

pub fn with_capacity(vertices: usize, hyperedges: usize) -> Self

Creates a new hypergraph with the specified capacity.

Trait Implementations§

source§

impl<V, HE> Debug for Hypergraph<V, HE>where V: Eq + Hash + Debug, HE: Debug,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<V, HE> Default for Hypergraph<V, HE>where V: VertexTrait, HE: HyperedgeTrait,

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<V, HE> IntoIterator for Hypergraph<V, HE>where V: VertexTrait, HE: HyperedgeTrait,

§

type Item = (HE, Vec<V, Global>)

The type of the elements being iterated over.
§

type IntoIter = HypergraphIterator<V, HE>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more

Auto Trait Implementations§

§

impl<V, HE> RefUnwindSafe for Hypergraph<V, HE>where HE: RefUnwindSafe, V: RefUnwindSafe,

§

impl<V, HE> Send for Hypergraph<V, HE>where HE: Send, V: Send,

§

impl<V, HE> Sync for Hypergraph<V, HE>where HE: Sync, V: Sync,

§

impl<V, HE> Unpin for Hypergraph<V, HE>where HE: Unpin, V: Unpin,

§

impl<V, HE> UnwindSafe for Hypergraph<V, HE>where HE: UnwindSafe, V: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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.

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

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

§

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 Twhere U: TryFrom<T>,

§

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.