GraphLib
Bearbeitung der Aufgabe Mini Graph Library für OOP WiSe 2023/24
Loading...
Searching...
No Matches
GraphLib::Internal::WeightedEdge< I, W > Struct Template Reference

Represents a weighted edge to a node identified by an ID, with an associated weight. More...

#include <edge.h>

Inheritance diagram for GraphLib::Internal::WeightedEdge< I, W >:
GraphLib::Internal::Edge< I >

Public Types

using weight_type = W
 Alias for the weight type.
Public Types inherited from GraphLib::Internal::Edge< I >
using id_type = I
 Alias for the node ID type.

Public Member Functions

bool operator< (const WeightedEdge &right) const
 Less-than operator comparing node IDs and weights.
bool operator== (const WeightedEdge &other) const
 Equality operator comparing both node IDs and weights.
template<typename D>
requires GraphLib::Internal::is_printable<D> && GraphLib::Internal::valid_data_type<D>
void print_with_data (std::ostream &os, D value) const
 Prints an weighted Edge with its data instead of ID.
Public Member Functions inherited from GraphLib::Internal::Edge< I >
bool operator< (const Edge &right) const
 Less-than operator comparing node IDs.
bool operator== (const Edge &other) const
 Equality operator comparing node IDs.
template<typename D>
requires GraphLib::Internal::is_printable<D> && GraphLib::Internal::valid_data_type<D>
void print_with_data (std::ostream &os, D value) const
 Prints an unweighted Edge with its data instead of ID.

Public Attributes

weight_type weight {}
 The weight associated with this edge.
Public Attributes inherited from GraphLib::Internal::Edge< I >
id_type node_id {}
 The ID of the node this edge points to.

Detailed Description

template<valid_id_type I, valid_weight_type W>
struct GraphLib::Internal::WeightedEdge< I, W >

Represents a weighted edge to a node identified by an ID, with an associated weight.

Template Parameters
IType of the node ID; must satisfy the valid_id_type concept.
WType of the edge weight; must satisfy the valid_weight_type concept.

Definition at line 97 of file edge.h.

Member Typedef Documentation

◆ weight_type

template<valid_id_type I, valid_weight_type W>
using GraphLib::Internal::WeightedEdge< I, W >::weight_type = W

Alias for the weight type.

Definition at line 99 of file edge.h.

Member Function Documentation

◆ operator<()

template<valid_id_type I, valid_weight_type W>
bool GraphLib::Internal::WeightedEdge< I, W >::operator< ( const WeightedEdge< I, W > & right) const
inline

Less-than operator comparing node IDs and weights.

Edges are first compared by their node IDs. If node IDs are equal, the weights are compared.

Parameters
rightThe other weighted edge to compare against.
Returns
true if this edge is considered less than right.

Definition at line 112 of file edge.h.

◆ operator==()

template<valid_id_type I, valid_weight_type W>
bool GraphLib::Internal::WeightedEdge< I, W >::operator== ( const WeightedEdge< I, W > & other) const
inline

Equality operator comparing both node IDs and weights.

Parameters
otherThe other weighted edge to compare against.
Returns
true if both node_id and weight are equal.

Definition at line 129 of file edge.h.

◆ print_with_data()

template<valid_id_type I, valid_weight_type W>
void GraphLib::Internal::WeightedEdge< I, W >::print_with_data ( std::ostream & os,
D value ) const
inline

Prints an weighted Edge with its data instead of ID.

Prints the node data and weight in the format "NODE_VALUE (WEIGHT)" to the output stream.

Template Parameters
Dthe Data Type
Parameters
osOutput stream.
valuethe Value behind the NodeID of this Edge.

Definition at line 145 of file edge.h.

Member Data Documentation

◆ weight

template<valid_id_type I, valid_weight_type W>
weight_type GraphLib::Internal::WeightedEdge< I, W >::weight {}

The weight associated with this edge.

Definition at line 101 of file edge.h.


The documentation for this struct was generated from the following files: