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  void registerAttributes(EdgeTypeManager* eManager) const override
45  {
46  eManager->registerAttribute(getClassName(), "weights",
50  }
51 
52  virtual ~NWeightedEdge() {}
53 
54  // Get class name
55  // \return class name
56  virtual std::string getClassName() const { return
57  "graph_analysis::NWeightedEdge_" + std::string(typeid(T).name()) + "_" + std::to_string(Dim); }
58 
59 protected:
60  virtual Edge* getClone() const { return new NWeightedEdge<T,Dim>(*this); }
61 
63 };
64 
65 template<typename T, size_t Dim>
66 const EdgeRegistration< NWeightedEdge<T,Dim> > NWeightedEdge<T,Dim>::msRegistration;
67 
68 } // end namespace graph_analysis
69 #endif // GRAPH_ANALYSIS_NWEIGHTED_EDGE_HPP
graph_analysis::io::AttributeSerializationCallbacks::print_func_t
std::string(graph_analysis::GraphElement::* print_func_t)()
Definition: Serialization.hpp:34
graph_analysis::Edge::setTargetVertex
void setTargetVertex(const Vertex::Ptr &target)
Definition: Edge.hpp:72
graph_analysis::EdgeRegistration
Definition: EdgeRegistration.hpp:14
graph_analysis::NWeightedEdge::NWeightedEdge
NWeightedEdge(const Vertex::Ptr &source, const Vertex::Ptr &target, const T &weight)
Definition: NWeightedEdge.hpp:30
graph_analysis::NWeighted< T, 2, Edge >::serializeWeights
std::string serializeWeights()
Definition: NWeighted.hpp:126
graph_analysis::NWeightedEdge::getClassName
virtual std::string getClassName() const
Definition: NWeightedEdge.hpp:56
graph_analysis::io::AttributeSerializationCallbacks::deserialize_func_t
void(graph_analysis::GraphElement::* deserialize_func_t)(const std::string &)
Definition: Serialization.hpp:33
graph_analysis::NWeightedEdge::getClone
virtual Edge * getClone() const
Definition: NWeightedEdge.hpp:60
graph_analysis::NWeighted< T, 2, Edge >::deserializeWeights
void deserializeWeights(const std::string &s)
Definition: NWeighted.hpp:134
graph_analysis::NWeightedEdge::__attribute__
static const EdgeRegistration< NWeightedEdge< T, Dim > > __attribute__((used)) msRegistration
graph_analysis::EdgeTypeManager
Factory for Edge subclasses.
Definition: EdgeTypeManager.hpp:30
graph_analysis
Main namespace of the graph analysis library.
Definition: BFS.cpp:3
NWeighted.hpp
graph_analysis::AttributeManager::registerAttribute
void registerAttribute(const std::string &typeName, const std::string &attributeName, io::AttributeSerializationCallbacks::serialize_func_t sF, io::AttributeSerializationCallbacks::deserialize_func_t dF, io::AttributeSerializationCallbacks::print_func_t pF)
register a new attribute for serialization and deserialization
Definition: AttributeManager.cpp:5
Edge.hpp
graph_analysis::Edge
An Edge represents the link between two vertices.
Definition: Edge.hpp:18
graph_analysis::algorithms::msRegistration
const VertexRegistration< MultiCommodityVertex > msRegistration
Definition: MultiCommodityVertex.cpp:13
graph_analysis::NWeightedEdge::NWeightedEdge
NWeightedEdge(const std::vector< T > &weights=std::vector< T >(Dim))
Definition: NWeightedEdge.hpp:26
graph_analysis::Vertex::Ptr
shared_ptr< Vertex > Ptr
Definition: Vertex.hpp:22
graph_analysis::NWeighted< T, 2, Edge >::stringifyWeights
std::string stringifyWeights() const
Definition: NWeighted.hpp:142
graph_analysis::NWeightedEdge::Ptr
shared_ptr< NWeightedEdge > Ptr
Definition: NWeightedEdge.hpp:20
graph_analysis::NWeighted
NWeighted is a template to associate N-weights with either a vertex or an edge, i....
Definition: NWeighted.hpp:26
graph_analysis::NWeightedEdge::NWeightedEdge
NWeightedEdge(const Vertex::Ptr &source, const Vertex::Ptr &target, const std::vector< T > &weights)
Definition: NWeightedEdge.hpp:37
graph_analysis::NWeightedEdge::NWeightedEdge
NWeightedEdge(const T &weight)
Definition: NWeightedEdge.hpp:22
graph_analysis::NWeightedEdge::registerAttributes
void registerAttributes(EdgeTypeManager *eManager) const override
Definition: NWeightedEdge.hpp:44
graph_analysis::io::AttributeSerializationCallbacks::serialize_func_t
std::string(graph_analysis::GraphElement::* serialize_func_t)()
Definition: Serialization.hpp:32
EdgeRegistration.hpp
graph_analysis::NWeightedEdge::~NWeightedEdge
virtual ~NWeightedEdge()
Definition: NWeightedEdge.hpp:52
graph_analysis::Edge::setSourceVertex
void setSourceVertex(const Vertex::Ptr &source)
Definition: Edge.hpp:67
graph_analysis::NWeightedEdge
NWeightedEdge is an Edge which can be associated with N-weights, i.e., a vector of weights.
Definition: NWeightedEdge.hpp:17