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 #include <base-logging/Logging.hpp>
6 
7 #include "NWeighted.hpp"
8 #include "Edge.hpp"
9 #include "EdgeRegistration.hpp"
10 
11 namespace graph_analysis {
12 
17 template<typename T, size_t Dim = 2>
18 class NWeightedEdge : public NWeighted<T,Dim,Edge>
19 {
20 public:
21  typedef shared_ptr< NWeightedEdge > Ptr;
22 
23  NWeightedEdge(const T& weight)
24  : NWeighted<T,Dim,Edge>(weight)
25  {}
26 
27  NWeightedEdge(const std::vector<T>& weights = std::vector<T>(Dim))
28  : NWeighted<T,Dim,Edge>(weights)
29  {}
30 
31  NWeightedEdge(const Vertex::Ptr& source, const Vertex::Ptr& target, const T& weight)
32  : NWeighted<T,Dim,Edge>(weight)
33  {
34  Edge::setSourceVertex(source);
35  Edge::setTargetVertex(target);
36  }
37 
38  NWeightedEdge(const Vertex::Ptr& source, const Vertex::Ptr& target, const std::vector<T>& weights)
39  : NWeighted<T,Dim,Edge>(weights)
40  {
41  Edge::setSourceVertex(source);
42  Edge::setTargetVertex(target);
43  }
44 
45  virtual ~NWeightedEdge() {
46  if(!msRegistration.isRegistered())
47  {
48  LOG_WARN_S << "Registration of NWeightedEdge never happened";
49  }
50  }
51 
52  // Get class name
53  // \return class name
54  virtual std::string getClassName() const { return
55  "graph_analysis::NWeightedEdge_" + std::string(typeid(T).name()) + "_" + std::to_string(Dim); }
56 
57 protected:
58  virtual Edge* getClone() const { return new NWeightedEdge<T,Dim>(*this); }
59 
61 };
62 
63 template<typename T, size_t Dim>
65 NWeightedEdge<T,Dim>::msRegistration;// = EdgeRegistration< NWeightedEdge<T,Dim> >();
66 
67 } // end namespace graph_analysis
68 #endif // GRAPH_ANALYSIS_NWEIGHTED_EDGE_HPP
NWeightedEdge(const Vertex::Ptr &source, const Vertex::Ptr &target, const std::vector< T > &weights)
Definition: NWeightedEdge.hpp:38
static const EdgeRegistration< NWeightedEdge< T, Dim > > msRegistration
Definition: NWeightedEdge.hpp:60
shared_ptr< NWeightedEdge > Ptr
Definition: NWeightedEdge.hpp:21
virtual ~NWeightedEdge()
Definition: NWeightedEdge.hpp:45
NWeightedEdge is an Edge which can be associated with N-weights, i.e., a vector of weights...
Definition: NWeightedEdge.hpp:18
NWeightedEdge(const T &weight)
Definition: NWeightedEdge.hpp:23
virtual Edge * getClone() const
Definition: NWeightedEdge.hpp:58
NWeightedEdge(const Vertex::Ptr &source, const Vertex::Ptr &target, const T &weight)
Definition: NWeightedEdge.hpp:31
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:54
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
Definition: EdgeRegistration.hpp:9
NWeightedEdge(const std::vector< T > &weights=std::vector< T >(Dim))
Definition: NWeightedEdge.hpp:27
void setTargetVertex(const Vertex::Ptr &target)
Definition: Edge.hpp:72
void setSourceVertex(const Vertex::Ptr &source)
Definition: Edge.hpp:67