Struct hypergraph::Hypergraph [−][src]
pub struct Hypergraph<V, HE> {
pub vertices: IndexMap<V, IndexSet<usize>>,
pub hyperedges: IndexSet<HyperedgeKey<HE>>,
// some fields omitted
}Expand description
A directed hypergraph composed of generic vertices and hyperedges.
Fields
vertices: IndexMap<V, IndexSet<usize>>Vertices are stored as a map whose unique keys are the weights and the values are a set of the hyperedges indexes which include
hyperedges: IndexSet<HyperedgeKey<HE>>Hyperedges are stored as a set whose unique keys are a combination of vertices indexes and a weight. Two or more hyperedges can contain the exact same vertices (non-simple hypergraph).
Implementations
pub fn add_hyperedge(
&mut self,
vertices: Vec<VertexIndex>,
weight: HE
) -> Result<HyperedgeIndex, HypergraphError<V, HE>>
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.
Clears all the hyperedges from the hypergraph.
pub fn contract_hyperedge_vertices(
&mut self,
hyperedge_index: HyperedgeIndex,
vertices: Vec<VertexIndex>,
target: VertexIndex
) -> Result<Vec<VertexIndex>, HypergraphError<V, HE>>
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
Returns the number of hyperedges in the hypergraph.
pub fn get_hyperedge_vertices(
&self,
hyperedge_index: HyperedgeIndex
) -> Result<Vec<VertexIndex>, HypergraphError<V, HE>>
pub fn get_hyperedge_vertices(
&self,
hyperedge_index: HyperedgeIndex
) -> Result<Vec<VertexIndex>, HypergraphError<V, HE>>
Gets the vertices of a hyperedge.
pub fn get_hyperedge_weight(
&self,
hyperedge_index: HyperedgeIndex
) -> Result<HE, HypergraphError<V, HE>>
pub fn get_hyperedge_weight(
&self,
hyperedge_index: HyperedgeIndex
) -> Result<HE, HypergraphError<V, HE>>
Gets the weight of a hyperedge from its index.
pub fn get_hyperedges_connecting(
&self,
from: VertexIndex,
to: VertexIndex
) -> Result<Vec<HyperedgeIndex>, HypergraphError<V, HE>>
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.
pub fn get_hyperedges_intersections(
&self,
hyperedges: Vec<HyperedgeIndex>
) -> Result<Vec<VertexIndex>, HypergraphError<V, HE>>
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.
pub fn remove_hyperedge(
&mut self,
hyperedge_index: HyperedgeIndex
) -> Result<(), HypergraphError<V, HE>>
pub fn remove_hyperedge(
&mut self,
hyperedge_index: HyperedgeIndex
) -> Result<(), HypergraphError<V, HE>>
Removes a hyperedge by index.
pub fn reverse_hyperedge(
&mut self,
hyperedge_index: HyperedgeIndex
) -> Result<(), HypergraphError<V, HE>>
pub fn update_hyperedge_vertices(
&mut self,
hyperedge_index: HyperedgeIndex,
vertices: Vec<VertexIndex>
) -> Result<(), HypergraphError<V, HE>>
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.
pub fn update_hyperedge_weight(
&mut self,
hyperedge_index: HyperedgeIndex,
weight: HE
) -> Result<(), HypergraphError<V, HE>>
pub fn update_hyperedge_weight(
&mut self,
hyperedge_index: HyperedgeIndex,
weight: HE
) -> Result<(), HypergraphError<V, HE>>
Updates the weight of a hyperedge by index.
Adds a vertex with a custom weight to the hypergraph. Returns the index of the vertex.
Returns the number of vertices in the hypergraph.
pub fn get_adjacent_vertices_from(
&self,
from: VertexIndex
) -> Result<Vec<VertexIndex>, HypergraphError<V, HE>>
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.
pub fn get_adjacent_vertices_to(
&self,
to: VertexIndex
) -> Result<Vec<VertexIndex>, HypergraphError<V, HE>>
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.
pub fn get_dijkstra_connections(
&self,
from: VertexIndex,
to: VertexIndex
) -> Result<Vec<VertexIndex>, HypergraphError<V, HE>>
pub fn get_dijkstra_connections(
&self,
from: VertexIndex,
to: VertexIndex
) -> Result<Vec<VertexIndex>, HypergraphError<V, HE>>
Gets a list of the shortest path of vertices between two vertices. The implementation of the algorithm is based on https://doc.rust-lang.org/std/collections/binary_heap/#examples
pub fn get_full_vertex_hyperedges(
&self,
vertex_index: VertexIndex
) -> Result<Vec<Vec<VertexIndex>>, HypergraphError<V, HE>>
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.
Gets the in-degree of a vertex. https://en.wikipedia.org/wiki/Directed_graph#Indegree_and_outdegree
pub fn get_vertex_degree_out(
&self,
from: VertexIndex
) -> Result<usize, HypergraphError<V, HE>>
pub fn get_vertex_degree_out(
&self,
from: VertexIndex
) -> Result<usize, HypergraphError<V, HE>>
Gets the out-degree of a vertex. https://en.wikipedia.org/wiki/Directed_graph#Indegree_and_outdegree
pub fn get_vertex_hyperedges(
&self,
vertex_index: VertexIndex
) -> Result<Vec<HyperedgeIndex>, HypergraphError<V, HE>>
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.
pub fn get_vertex_weight(
&self,
vertex_index: VertexIndex
) -> Result<V, HypergraphError<V, HE>>
pub fn get_vertex_weight(
&self,
vertex_index: VertexIndex
) -> Result<V, HypergraphError<V, HE>>
Gets the weight of a vertex from its index.
pub fn remove_vertex(
&mut self,
vertex_index: VertexIndex
) -> Result<(), HypergraphError<V, HE>>
pub fn remove_vertex(
&mut self,
vertex_index: VertexIndex
) -> Result<(), HypergraphError<V, HE>>
Removes a vertex by index.
pub fn update_vertex_weight(
&mut self,
vertex_index: VertexIndex,
weight: V
) -> Result<(), HypergraphError<V, HE>>
pub fn update_vertex_weight(
&mut self,
vertex_index: VertexIndex,
weight: V
) -> Result<(), HypergraphError<V, HE>>
Updates the weight of a vertex by index.
Hypergraph implementations.