Template Numerical Library: TNL::Graphs::Edge< Real, Index > Struct Template Reference

Template Numerical Library version\ main:c7077e4fd

Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Attributes | List of all members
TNL::Graphs::Edge< Real, Index > Struct Template Reference

Represents a weighted edge in a graph. More...

`#include <TNL/Graphs/Edge.h>`

## Public Types
using | IndexType = Index
using | RealType = Real

## Public Member Functions
| Edge ()=default
| Default constructor. Initializes source, target, and weight to zero.
| Edge (const Edge &)=default
| Copy constructor.
| Edge (Edge &&)=default
| Move constructor.
| Edge (Index source, Index target, Real weight)
| Constructs an edge with specified source, target, and weight.
| ~Edge ()=default
| Destructor.
Index & | getSource ()
| Returns the source vertex index (modifiable version).
const Index & | getSource () const
| Returns the source vertex index (const version).
Index & | getTarget ()
| Returns the target vertex index (modifiable version).
const Index & | getTarget () const
| Returns the target vertex index (const version).
Real & | getWeight ()
| Returns the edge weight (modifiable version).
const Real & | getWeight () const
| Returns the edge weight (const version).
bool | operator!= (const Edge &other) const
| Inequality comparison.
bool | operator< (const Edge &other) const
| Less-than comparison based on edge weight.
bool | operator<= (const Edge &other) const
| Less-than-or-equal comparison based on edge weight.
Edge & | operator= (const Edge &)=default
| Copy assignment operator.
Edge & | operator= (Edge &&)=default
| Move assignment operator.
bool | operator== (const Edge &other) const
| Equality comparison.
bool | operator> (const Edge &other) const
| Greater-than comparison based on edge weight.
bool | operator>= (const Edge &other) const
| Greater-than-or-equal comparison based on edge weight.

## Protected Attributes
Index | source = 0
| Index of the source vertex.
Index | target = 0
| Index of the target vertex.
Real | weight = 0.0
| Weight of the edge.

## Detailed Description

template<typename Real = double, typename Index = int>
struct TNL::Graphs::Edge< Real, Index >

Represents a weighted edge in a graph.

The Edge structure stores information about a single edge in a graph, including the source vertex, target vertex, and edge weight. It provides comparison operators based on edge weights and accessor methods for all edge attributes.

Template Parameters

  Real | Type for the edge weight.
  Index | Type for vertex indices.

## Constructor & Destructor Documentation

## ◆ Edge()

template<typename Real = double, typename Index = int>

TNL::Graphs::Edge< Real, Index >::Edge | ( | Index | source,
|  | Index | target,
|  | Real | weight )
| inline

Constructs an edge with specified source, target, and weight.

Parameters

  source | Index of the source vertex.
  target | Index of the target vertex.
  weight | Weight of the edge.

## Member Function Documentation

## ◆ getSource() [1/2]

template<typename Real = double, typename Index = int>

Index & TNL::Graphs::Edge< Real, Index >::getSource | ( |  | ) |
| inline

Returns the source vertex index (modifiable version).

Returns
  Reference to the source vertex index.

## ◆ getSource() [2/2]

template<typename Real = double, typename Index = int>

const Index & TNL::Graphs::Edge< Real, Index >::getSource | ( |  | ) | const
| inlinenodiscard

Returns the source vertex index (const version).

Returns
  Const reference to the source vertex index.

## ◆ getTarget() [1/2]

template<typename Real = double, typename Index = int>

Index & TNL::Graphs::Edge< Real, Index >::getTarget | ( |  | ) |
| inline

Returns the target vertex index (modifiable version).

Returns
  Reference to the target vertex index.

## ◆ getTarget() [2/2]

template<typename Real = double, typename Index = int>

const Index & TNL::Graphs::Edge< Real, Index >::getTarget | ( |  | ) | const
| inlinenodiscard

Returns the target vertex index (const version).

Returns
  Const reference to the target vertex index.

## ◆ getWeight() [1/2]

template<typename Real = double, typename Index = int>

Real & TNL::Graphs::Edge< Real, Index >::getWeight | ( |  | ) |
| inline

Returns the edge weight (modifiable version).

Returns
  Reference to the edge weight.

## ◆ getWeight() [2/2]

template<typename Real = double, typename Index = int>

const Real & TNL::Graphs::Edge< Real, Index >::getWeight | ( |  | ) | const
| inlinenodiscard

Returns the edge weight (const version).

Returns
  Const reference to the edge weight.

## ◆ operator!=()

template<typename Real = double, typename Index = int>

bool TNL::Graphs::Edge< Real, Index >::operator!= | ( | const Edge< Real, Index > & | other | ) | const
| inline

Inequality comparison.

Parameters

  other | The edge to compare with.

Returns
  True if edges differ in source, target, or weight.

## ◆ operator<()

template<typename Real = double, typename Index = int>

bool TNL::Graphs::Edge< Real, Index >::operator< | ( | const Edge< Real, Index > & | other | ) | const
| inline

Less-than comparison based on edge weight.

Parameters

  other | The edge to compare with.

Returns
  True if this edge's weight is less than the other edge's weight.

## ◆ operator<=()

template<typename Real = double, typename Index = int>

bool TNL::Graphs::Edge< Real, Index >::operator<= | ( | const Edge< Real, Index > & | other | ) | const
| inline

Less-than-or-equal comparison based on edge weight.

Parameters

  other | The edge to compare with.

Returns
  True if this edge's weight is less than or equal to the other edge's weight.

## ◆ operator==()

template<typename Real = double, typename Index = int>

bool TNL::Graphs::Edge< Real, Index >::operator== | ( | const Edge< Real, Index > & | other | ) | const
| inline

Equality comparison.

Parameters

  other | The edge to compare with.

Returns
  True if both edges have the same source, target, and weight.

## ◆ operator>()

template<typename Real = double, typename Index = int>

bool TNL::Graphs::Edge< Real, Index >::operator> | ( | const Edge< Real, Index > & | other | ) | const
| inline

Greater-than comparison based on edge weight.

Parameters

  other | The edge to compare with.

Returns
  True if this edge's weight is greater than the other edge's weight.

## ◆ operator>=()

template<typename Real = double, typename Index = int>

bool TNL::Graphs::Edge< Real, Index >::operator>= | ( | const Edge< Real, Index > & | other | ) | const
| inline

Greater-than-or-equal comparison based on edge weight.

Parameters

  other | The edge to compare with.

Returns
  True if this edge's weight is greater than or equal to the other edge's weight.

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

- src/TNL/Graphs/Edge.h