# Ignition Math

## API Reference

6.10.0
Edge< E > Class Template Referenceabstract

Generic edge class. An edge has two ends and some constraint between them. For example, a directed edge only allows traversing the edge in one direction. More...

#include <Edge.hh>

## Public Member Functions

Edge (const VertexId_P &_vertices, const E &_data, const double _weight, const EdgeId &_id=kNullId)
Constructor. More...

const E & Data () const
Get a non-mutable reference to the user data stored in the edge. More...

E & Data ()
Get a mutable reference to the user data stored in the edge. More...

virtual VertexId From (const VertexId &_from) const =0
Get the destination end that is reachable from a source end of an edge. More...

EdgeId Id () const
Get the edge Id. More...

void SetWeight (const double _newWeight)
Set the cost of the edge. More...

virtual VertexId To (const VertexId &_to) const =0
Get the source end that can reach the destination end of an edge. More...

bool Valid () const
An edge is considered valid when its id is not kNullId. More...

VertexId_P Vertices () const
Get the two vertices contained in the edge. More...

double Weight () const
The cost of traversing the _from end to the other end of the edge. More...

## Detailed Description

### template<typename E> class ignition::math::graph::Edge< E >

Generic edge class. An edge has two ends and some constraint between them. For example, a directed edge only allows traversing the edge in one direction.

## ◆ Edge()

 Edge ( const VertexId_P & _vertices, const E & _data, const double _weight, const EdgeId & _id = kNullId )
inlineexplicit

Constructor.

Parameters
 [in] _vertices The vertices of the edge. [in] _data The data stored in the edge. [in] _weight The weight (cost) of the edge. [in] _id Optional unique id.

## ◆ Data() [1/2]

 const E& Data ( ) const
inline

Get a non-mutable reference to the user data stored in the edge.

Returns
The non-mutable reference to the user data stored in the edge.

References EdgeInitializer< E >::data.

## ◆ Data() [2/2]

 E& Data ( )
inline

Get a mutable reference to the user data stored in the edge.

Returns
The mutable reference to the user data stored in the edge.

References EdgeInitializer< E >::data.

## ◆ From()

 virtual VertexId From ( const VertexId & _from ) const
pure virtual

Get the destination end that is reachable from a source end of an edge.

E.g.: Let's assume that we have an undirected edge (e1) with ends (v1) and (v2): (v1)–(v2). The operation e1.From(v1) returns (v2). The operation e1.From(v2) returns (v1).

E.g.: Let's assume that we have a directed edge (e2) with the tail end (v1) and the head end (v2): (v1)->(v2). The operation e2.From(v1) returns (v2). The operation e2.From(v2) returns kNullId.

Parameters
 [in] _from Source vertex.
Returns
The other vertex of the edge reachable from the "_from" vertex or kNullId otherwise.

Implemented in DirectedEdge< E >, and UndirectedEdge< E >.

## ◆ Id()

 EdgeId Id ( ) const
inline

Get the edge Id.

Returns
The edge Id.

## ◆ SetWeight()

 void SetWeight ( const double _newWeight )
inline

Set the cost of the edge.

Parameters
 [in] _newWeight The new cost.

References EdgeInitializer< E >::weight.

## ◆ To()

 virtual VertexId To ( const VertexId & _to ) const
pure virtual

Get the source end that can reach the destination end of an edge.

E.g.: Let's assume that we have an undirected edge (e1) with ends (v1) and (v2): (v1)–(v2). The operation e1.To(v1) returns (v2). The operation e1.To(v2) returns (v1).

E.g.: Let's assume that we have a directed edge (e2) with the tail end (v1) and the head end (v2): (v1)->(v2). The operation e2.To(v1) returns kNullId. The operation e2.To(v2) returns v1.

Parameters
 [in] _to Destination vertex.
Returns
The other vertex of the edge that can reach "_to" vertex or kNullId otherwise.

Implemented in DirectedEdge< E >, and UndirectedEdge< E >.

## ◆ Valid()

 bool Valid ( ) const
inline

An edge is considered valid when its id is not kNullId.

Returns
Whether the edge is valid or not.

## ◆ Vertices()

 VertexId_P Vertices ( ) const
inline

Get the two vertices contained in the edge.

Returns
The two vertices contained in the edge.

References ignition::math::graph::kNullId, and EdgeInitializer< E >::vertices.

## ◆ Weight()

 double Weight ( ) const
inline

The cost of traversing the _from end to the other end of the edge.

Returns
The cost.

References EdgeInitializer< E >::weight.

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