graph_analysis
NWeightedEdge.hpp
Go to the documentation of this file.
1 #ifndef GRAPH_ANALYSIS_NWEIGHTED_EDGE_HPP
2 #define GRAPH_ANALYSIS_NWEIGHTED_EDGE_HPP
3 
4 #include <iostream>
5 
6 #include "NWeighted.hpp"
7 #include "Edge.hpp"
8 #include "EdgeRegistration.hpp"
9 
10 namespace graph_analysis {
11 
16 template<typename T, size_t Dim = 2>
17 class NWeightedEdge : public NWeighted<T,Dim,Edge>
18 {
19 public:
20  typedef shared_ptr< NWeightedEdge > Ptr;
21 
22  NWeightedEdge(const T& weight)
23  : NWeighted<T,Dim,Edge>(weight)
24  {}
25 
26  NWeightedEdge(const std::vector<T>& weights = std::vector<T>(Dim))
27  : NWeighted<T,Dim,Edge>(weights)
28  {}
29 
30  NWeightedEdge(const Vertex::Ptr& source, const Vertex::Ptr& target, const T& weight)
31  : NWeighted<T,Dim,Edge>(weight)
32  {
33  Edge::setSourceVertex(source);
34  Edge::setTargetVertex(target);
35  }
36 
37  NWeightedEdge(const Vertex::Ptr& source, const Vertex::Ptr& target, const std::vector<T>& weights)
38  : NWeighted<T,Dim,Edge>(weights)
39  {
40  Edge::setSourceVertex(source);
41  Edge::setTargetVertex(target);
42  }
43 
44  virtual ~NWeightedEdge() {}
45 
46  // Get class name
47  // \return class name
48  virtual std::string getClassName() const { return
49  "graph_analysis::NWeightedEdge_" + std::string(typeid(T).name()) + "_" + std::to_string(Dim); }
50 
51 protected:
52  virtual Edge* getClone() const { return new NWeightedEdge<T,Dim>(*this); }
53 
55 };
56 
57 } // end namespace graph_analysis
58 #endif // GRAPH_ANALYSIS_NWEIGHTED_EDGE_HPP
NWeightedEdge(const Vertex::Ptr &source, const Vertex::Ptr &target, const std::vector< T > &weights)
Definition: NWeightedEdge.hpp:37
shared_ptr< NWeightedEdge > Ptr
Definition: NWeightedEdge.hpp:20
virtual ~NWeightedEdge()
Definition: NWeightedEdge.hpp:44
NWeightedEdge is an Edge which can be associated with N-weights, i.e., a vector of weights...
Definition: NWeightedEdge.hpp:17
NWeightedEdge(const T &weight)
Definition: NWeightedEdge.hpp:22
virtual Edge * getClone() const
Definition: NWeightedEdge.hpp:52
const VertexRegistration< MultiCommodityVertex > msRegistration
Definition: MultiCommodityVertex.cpp:13
NWeightedEdge(const Vertex::Ptr &source, const Vertex::Ptr &target, const T &weight)
Definition: NWeightedEdge.hpp:30
Main namespace of the graph analysis library.
Definition: BFS.cpp:3
shared_ptr< Vertex > Ptr
Definition: Vertex.hpp:22
virtual std::string getClassName() const
Definition: NWeightedEdge.hpp:48
NWeighted is a template to associate N-weights with either a vertex or an edge, i.e., adds a vector of weights.
Definition: NWeighted.hpp:26
An Edge represents the link between two vertices.
Definition: Edge.hpp:18
static const EdgeRegistration< NWeightedEdge< T, Dim > > __attribute__((used)) msRegistration
Definition: EdgeRegistration.hpp:14
NWeightedEdge(const std::vector< T > &weights=std::vector< T >(Dim))
Definition: NWeightedEdge.hpp:26
void setTargetVertex(const Vertex::Ptr &target)
Definition: Edge.hpp:72
void setSourceVertex(const Vertex::Ptr &source)
Definition: Edge.hpp:67