Skip to content

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';
}
  1. Stream manipulators like with_hyperedge_properties apply persistently to std::cout.
  2. Use the owning hypergraph to query topological information about the hyperedge.
  3. Update the payload properties through the overloaded -> operator (assuming the hyperedge properties type contains a weight member).

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.

using hgl::hyperedge_descriptor< Properties, IdType >::type =  hyperedge_descriptor<Properties>;


typedef id_type

The underlying integer type used for the hyperedge identifier.

using hgl::hyperedge_descriptor< Properties, IdType >::id_type =  IdType;


typedef properties_type

The type of property data attached to the hyperedge.

using hgl::hyperedge_descriptor< Properties, IdType >::properties_type =  Properties;


Public Functions Documentation

function hyperedge_descriptor [1/5]

Default constructor creating an invalid hyperedge descriptor.

inline hgl::hyperedge_descriptor::hyperedge_descriptor () 


function hyperedge_descriptor [2/5]

Constructs a property-less hyperedge descriptor from a raw ID.

inline explicit hgl::hyperedge_descriptor::hyperedge_descriptor (
    const  id_type id
) 

Parameters:

  • id The 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:

  • id The raw identifier of the hyperedge.
  • properties A reference to the underlying properties payload.

function hyperedge_descriptor [4/5]

Default copy constructor.

hgl::hyperedge_descriptor::hyperedge_descriptor (
    const  hyperedge_descriptor &
) = default


function operator=

Default copy assignment operator.

hyperedge_descriptor & hgl::hyperedge_descriptor::operator= (
    const  hyperedge_descriptor &
) = default


function hyperedge_descriptor [5/5]

Default move constructor.

hgl::hyperedge_descriptor::hyperedge_descriptor (
    hyperedge_descriptor &&
) noexcept


function operator=

Default move assignment operator.

hyperedge_descriptor & hgl::hyperedge_descriptor::operator= (
    hyperedge_descriptor &&
) noexcept


function ~hyperedge_descriptor

Default destructor.

hgl::hyperedge_descriptor::~hyperedge_descriptor () = default


function operator==

Compares two hyperedge descriptors for equality.

inline bool hgl::hyperedge_descriptor::operator== (
    const  hyperedge_descriptor & other
) noexcept const

Parameters:

  • other The 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.

inline hgl::hyperedge_descriptor::operator bool () noexcept const

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:

  • other The 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.

inline bool hgl::hyperedge_descriptor::is_valid () noexcept const

Returns:

true if the underlying ID is not the invalid ID constant, false otherwise.


function id

Retrieves the raw underlying ID of the hyperedge.

inline id_type hgl::hyperedge_descriptor::id () noexcept const

Returns:

The hyperedge's integer ID.


function properties

Retrieves a reference to the property payload attached to the hyperedge.

inline properties_type & hgl::hyperedge_descriptor::properties () const

Returns:

A mutable reference to the underlying properties.

Exception:

  • std::logic_error If the descriptor is invalid.

function operator->

Arrow operator providing direct access to the hyperedge's properties.

inline properties_type * hgl::hyperedge_descriptor::operator-> () const

Returns:

A pointer to the underlying properties.

Exception:

  • std::logic_error If the descriptor is invalid.

function operator*

Dereference operator providing direct access to the hyperedge's properties.

inline properties_type & hgl::hyperedge_descriptor::operator* () const

Returns:

A reference to the underlying properties.

Exception:

  • std::logic_error If the descriptor is invalid.

Public Static Functions Documentation

function invalid [1/2]

Returns a special descriptor representing an invalid or uninitialized property-less hyperedge.

static inline hyperedge_descriptor hgl::hyperedge_descriptor::invalid () noexcept

Returns:

An invalid hyperedge_descriptor.


function invalid [2/2]

Returns a special descriptor representing an invalid or uninitialized hyperedge with properties.

static inline hyperedge_descriptor hgl::hyperedge_descriptor::invalid () noexcept

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:

  • os The target output stream.
  • hyperedge The 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