17#ifndef IGNITION_MATH_GRAPH_EDGE_HH_
18#define IGNITION_MATH_GRAPH_EDGE_HH_
27#include <ignition/math/config.hh>
34inline namespace IGNITION_MATH_VERSION_NAMESPACE
52 const double _weight = 1)
105 return this->vertices;
134 this->weight = _newWeight;
187 private:
double weight = 1.0;
197 template<
typename EdgeType>
198 using EdgeRef_M = std::map<EdgeId, std::reference_wrapper<const EdgeType>>;
216 const double _weight,
218 :
Edge<E>(_vertices, _data, _weight, _id)
231 if (this->
Vertices().first == _from)
240 return this->
From(_to);
252 _out <<
" " << vertices.first <<
" -- " << vertices.second
253 <<
" [label=" << _e.
Weight() <<
"];" << std::endl;
279 const double _weight,
281 :
Edge<E>(_vertices, _data, _weight, _id)
304 if (_from != this->
Tail())
313 if (_to != this->
Head())
327 _out <<
" " << _e.
Tail() <<
" -> " << _e.
Head()
328 <<
" [label=" << _e.
Weight() <<
"];" << std::endl;
A directed edge represents a connection between two vertices.
Definition Edge.hh:268
VertexId From(const VertexId &_from) const override
Get the destination end that is reachable from a source end of an edge.
Definition Edge.hh:302
DirectedEdge(const VertexId_P &_vertices, const E &_data, const double _weight, const EdgeId &_id=kNullId)
Constructor.
Definition Edge.hh:277
VertexId Tail() const
Get the Id of the tail vertex in this edge.
Definition Edge.hh:288
VertexId To(const VertexId &_to) const override
Get the source end that can reach the destination end of an edge.
Definition Edge.hh:311
static DirectedEdge< E > NullEdge
An invalid directed edge.
Definition Edge.hh:270
VertexId Head() const
Get the Id of the head vertex in this edge.
Definition Edge.hh:296
friend std::ostream & operator<<(std::ostream &_out, const DirectedEdge< E > &_e)
Stream insertion operator.
Definition Edge.hh:324
Generic edge class.
Definition Edge.hh:74
virtual VertexId To(const VertexId &_to) const =0
Get the source end that can reach the destination end of an edge.
bool Valid() const
An edge is considered valid when its id is not kNullId.
Definition Edge.hh:171
const E & Data() const
Get a non-mutable reference to the user data stored in the edge.
Definition Edge.hh:110
virtual VertexId From(const VertexId &_from) const =0
Get the destination end that is reachable from a source end of an edge.
Edge(const VertexId_P &_vertices, const E &_data, const double _weight, const EdgeId &_id=kNullId)
Constructor.
Definition Edge.hh:80
VertexId_P Vertices() const
Get the two vertices contained in the edge.
Definition Edge.hh:100
double Weight() const
The cost of traversing the _from end to the other end of the edge.
Definition Edge.hh:125
EdgeId Id() const
Get the edge Id.
Definition Edge.hh:93
void SetWeight(const double _newWeight)
Set the cost of the edge.
Definition Edge.hh:132
E & Data()
Get a mutable reference to the user data stored in the edge.
Definition Edge.hh:117
An undirected edge represents a connection between two vertices.
Definition Edge.hh:205
VertexId To(const VertexId &_to) const override
Get the source end that can reach the destination end of an edge.
Definition Edge.hh:238
VertexId From(const VertexId &_from) const override
Get the destination end that is reachable from a source end of an edge.
Definition Edge.hh:223
friend std::ostream & operator<<(std::ostream &_out, const UndirectedEdge< E > &_e)
Stream insertion operator.
Definition Edge.hh:248
UndirectedEdge(const VertexId_P &_vertices, const E &_data, const double _weight, const EdgeId &_id=kNullId)
Constructor.
Definition Edge.hh:214
static UndirectedEdge< E > NullEdge
An invalid undirected edge.
Definition Edge.hh:207
std::pair< VertexId, VertexId > VertexId_P
Definition Vertex.hh:45
std::map< EdgeId, std::reference_wrapper< const EdgeType > > EdgeRef_M
Definition Edge.hh:198
static const VertexId kNullId
Represents an invalid Id.
Definition Vertex.hh:48
uint64_t VertexId
Definition Vertex.hh:41
std::set< EdgeId > EdgeId_S
Definition Edge.hh:192
uint64_t EdgeId
Definition Edge.hh:40
Used in the Graph constructors for uniform initialization.
Definition Edge.hh:45
VertexId_P vertices
IDs of the vertices.
Definition Edge.hh:60
E data
User data.
Definition Edge.hh:63
EdgeInitializer(const VertexId_P &_vertices, const E &_data=E(), const double _weight=1)
Constructor.
Definition Edge.hh:50
double weight
The weight (cost) of the edge.
Definition Edge.hh:66