Class hgl::hyperedge_descriptor
template <traits::c_properties Properties, traits::c_id_type IdType>
ClassList > hgl > hyperedge_descriptor
A lightweight wrapper representing a hypergraph edge with optional properties. More...
#include <hgl/hypergraph_elements.hpp>
Public Types
| Type | Name |
|---|---|
| typedef hyperedge_descriptor< Properties > | type Self type alias. |
| typedef IdType | id_type The underlying integer type used for the hyperedge identifier. |
| typedef Properties | properties_type The type of property data attached to the hyperedge. |
Public Functions
| Type | Name |
|---|---|
| hyperedge_descriptor () Default constructor creating an invalid hyperedge descriptor. |
|
| hyperedge_descriptor (const id_type id) Constructs a property-less hyperedge descriptor from a raw ID. |
|
| hyperedge_descriptor (const id_type id, properties_type & properties) Constructs a hyperedge descriptor binding an ID to its properties. |
|
| hyperedge_descriptor (const hyperedge_descriptor &) = default Default copy constructor. |
|
| hyperedge_descriptor & | operator= (const hyperedge_descriptor &) = default Default copy assignment operator. |
| hyperedge_descriptor (hyperedge_descriptor &&) noexcept Default move constructor. |
|
| hyperedge_descriptor & | operator= (hyperedge_descriptor &&) noexcept Default move assignment operator. |
| ~hyperedge_descriptor () = default Default destructor. |
|
| bool | operator== (const hyperedge_descriptor & other) noexcept const Compares two hyperedge descriptors for equality. |
| operator bool () noexcept const Contextually converts the descriptor to a boolean. |
|
| std::strong_ordering | operator<=> (const hyperedge_descriptor & other) noexcept const Compares two hyperedge descriptors to establish a strict ordering based on their IDs. |
| bool | is_valid () noexcept const Checks if the descriptor represents a valid hyperedge. |
| id_type | id () noexcept const Retrieves the raw underlying ID of the hyperedge. |
| properties_type & | properties () const Retrieves a reference to the property payload attached to the hyperedge. |
| properties_type * | operator-> () const Arrow operator providing direct access to the hyperedge's properties. |
| properties_type & | operator* () const Dereference operator providing direct access to the hyperedge's properties. |
Public Static Functions
| Type | Name |
|---|---|
| hyperedge_descriptor | invalid () noexcept Returns a special descriptor representing an invalid or uninitialized property-less hyperedge. |
| hyperedge_descriptor | invalid () noexcept Returns a special descriptor representing an invalid or uninitialized hyperedge with properties. |
Detailed Description
The hyperedge_descriptor class provides a type-safe and efficient way to represent hyperedges in hypergraph structures. It acts as a lightweight wrapper that encapsulates the unique identifier of the hyperedge and its optional property data, ensuring safe access and comparison operations.
This class is not intended to be instantiated directly.
Instead, hyperedge_descriptor objects should be retrieved from the hgl::hypergraph class instance that owns the given hyperedge.
Example Usage
std::cout << gl::io::verbose << gl::io::with_hyperedge_properties; // (1)!
for (const auto& hyperedge : hypergraph.hyperedges()) {
const auto size = hypergraph.hyperedge_size(hyperedge); // (2)!
hyperedge->weight = static_cast<double>(size) * 1.5; // (3)!
std::cout << "Hyperedge details: " << hyperedge << '\n';
}
- Stream manipulators like
with_hyperedge_propertiesapply persistently tostd::cout. - Use the owning hypergraph to query topological information about the hyperedge.
- Update the payload properties through the overloaded
->operator (assuming the hyperedge properties type contains aweightmember).
Template Parameters
| Parameter | Description | Default | Constraint |
|---|---|---|---|
| Properties | The type of property data attached to the hyperedge. | empty_properties | c_properties |
| IdType | The underlying integer type used for the IDs. | default_id_type | c_id_type |
See Also
- vertex_descriptor for the corresponding vertex wrapper class.
- hypergraph for the owning hypergraph class that manages hyperedge descriptors.
Public Types Documentation
typedef type
Self type alias.
typedef id_type
The underlying integer type used for the hyperedge identifier.
typedef properties_type
The type of property data attached to the hyperedge.
Public Functions Documentation
function hyperedge_descriptor [1/5]
Default constructor creating an invalid hyperedge descriptor.
function hyperedge_descriptor [2/5]
Constructs a property-less hyperedge descriptor from a raw ID.
Parameters:
idThe raw identifier of the hyperedge.
function hyperedge_descriptor [3/5]
Constructs a hyperedge descriptor binding an ID to its properties.
inline explicit hgl::hyperedge_descriptor::hyperedge_descriptor (
const id_type id,
properties_type & properties
)
Parameters:
idThe raw identifier of the hyperedge.propertiesA reference to the underlying properties payload.
function hyperedge_descriptor [4/5]
Default copy constructor.
function operator=
Default copy assignment operator.
hyperedge_descriptor & hgl::hyperedge_descriptor::operator= (
const hyperedge_descriptor &
) = default
function hyperedge_descriptor [5/5]
Default move constructor.
function operator=
Default move assignment operator.
function ~hyperedge_descriptor
Default destructor.
function operator==
Compares two hyperedge descriptors for equality.
inline bool hgl::hyperedge_descriptor::operator== (
const hyperedge_descriptor & other
) noexcept const
Parameters:
otherThe descriptor to compare against.
Returns:
true if both descriptors hold the same ID, false otherwise.
function operator bool
Contextually converts the descriptor to a boolean.
Returns:
true if the descriptor is valid, false otherwise.
function operator<=>
Compares two hyperedge descriptors to establish a strict ordering based on their IDs.
inline std::strong_ordering hgl::hyperedge_descriptor::operator<=> (
const hyperedge_descriptor & other
) noexcept const
Parameters:
otherThe descriptor to compare against.
Returns:
The result of the three-way comparison between the underlying IDs.
function is_valid
Checks if the descriptor represents a valid hyperedge.
Returns:
true if the underlying ID is not the invalid ID constant, false otherwise.
function id
Retrieves the raw underlying ID of the hyperedge.
Returns:
The hyperedge's integer ID.
function properties
Retrieves a reference to the property payload attached to the hyperedge.
Returns:
A mutable reference to the underlying properties.
Exception:
std::logic_errorIf the descriptor is invalid.
function operator->
Arrow operator providing direct access to the hyperedge's properties.
Returns:
A pointer to the underlying properties.
Exception:
std::logic_errorIf the descriptor is invalid.
function operator*
Dereference operator providing direct access to the hyperedge's properties.
Returns:
A reference to the underlying properties.
Exception:
std::logic_errorIf the descriptor is invalid.
Public Static Functions Documentation
function invalid [1/2]
Returns a special descriptor representing an invalid or uninitialized property-less hyperedge.
Returns:
An invalid hyperedge_descriptor.
function invalid [2/2]
Returns a special descriptor representing an invalid or uninitialized hyperedge with properties.
Returns:
An invalid hyperedge_descriptor.
Friends Documentation
friend operator<<
Serializes the hyperedge descriptor to an output stream.
inline std::ostream & hgl::hyperedge_descriptor::operator<< (
std::ostream & os,
const hyperedge_descriptor & hyperedge
)
Depending on active stream flags, this outputs the descriptor in verbose or concise formats.
Parameters:
osThe target output stream.hyperedgeThe hyperedge descriptor to format.
Returns:
The stream reference for chaining.
The documentation for this class was generated from the following file include/hgl/hypergraph_elements.hpp