Expand description
A map-based implementation of a hypergraph providing efficient storage and manipulation of hypernodes and hyperedges.
§Overview
This implementation focuses on providing a flexible and efficient representation of a
hypergraph. The HyperMap
is parameterized by the following types:
N
: the type of weight associated with a hypernodeE
: the type of weight associated with a hyperedgeA
: the attributes of the graph are implementors of the [GraphProps
] traitA::Kind
: the kind of hypergraph, eitherDirected
orUndirected
A::Ix
: the type of indices used by the instance; bounded by the [RawIndex
trait
S
: the type of [BuildHasher
] used for the underling stores
This is done to maximize compatibility and flexibility, allowing users to define their own hypergraphs with custom node and edge types, as well as different index types and hashers.
§Backend
The underlying storage mechanics are based on the hashbrown
crate, which is a Rust implementation of Google’s SwissTable
algorithm. This is largely done to benfit from the additional feature set natively
available within the crate versus the standard HashMap
implementation. That being said, it is important to note that for any applications where
security it a concerin it is highly recommended to use the RandomState
as the default hasher in lieu of the [DefaultHashBuilder
] from foldhash
as it fails to prevent against attacks such as Hash-DoS
. See the hashbrown
for more information on the security implications of using a custom hasher.
§Features
The HyperMap
supports various features to enhance its functionality:
algo
: enables the algorithmic operators from thershyper_algo
craterayon
: enables parallel processing capabilities using therayon
crateserde
: enables serialization and deserialization of hypergraphs using theserde
crate
§Examples
For more detailed examples, please refer to the examples directory.
§Example #1: Basic Usage
use rshyper_core::Weight;
use rshyper_hmap::HyperMap;
// initialize a ne, undirected hypergraph
let mut graph = HyperMap::<i32, i32>::undirected();
// insert some nodes with and without weights
let v0 = graph.add_vertex().expect("failed to add vertex");
let v1 = graph.add_node(Weight(42)).expect("failed to add the node");
let v2 = graph.add_node(Weight(100)).expect("failed to add the node");
// insert an edge between the two nodes
let e0 = graph.add_edge([v0, v1, v2], Weight(100)).expect("failed to add edge");
// verify the size of the graph; (number of edges)
assert_eq!(graph.size(), 1);
// verify the order of the graph; (number of nodes)
assert_eq!(graph.order(), 3);
Modules§
Structs§
- Hyper
Map - The
HyperMap
is a map-based implementation of a hypergraph that provides a flexible and efficient way to store and manipulate hypergraphs. It is designed to be generic over the types of nodes N, edges E, attributes A, and the hasher S used for hashing the nodes and edges. This design allows for a wide range of applications, from simple hypergraphs to more complex structures with custom attributes and hashing strategies.
Type Aliases§
- DiHyper
Map - a type alias for a directed
HyperMap
- Edge
Entry - a type alias for a
Entry
that whose key is anEdgeId
and value is a [HashSurface
] - EdgeMap
- a type alias for a
HashMap
that mapsEdgeId
to a [HashFacet
] - Node
Entry - a type alias for a
Entry
that whose key is aVertexId
and value is aNode
- NodeMap
- a type alias for a
HashMap
that mapsVertexId
to aNode
- UnHyper
Map - a type alias for an undirected
HyperMap