graph_analysis
Edge.hpp
Go to the documentation of this file.
1 #ifndef GRAPH_ANALYSIS_EDGE_HPP
2 #define GRAPH_ANALYSIS_EDGE_HPP
3 
4 #include "Vertex.hpp"
5 #include <string>
6 
7 namespace graph_analysis
8 {
9 
10 class BaseGraph;
11 class EdgeTypeManager;
12 
18 class Edge : public GraphElement
19 {
20 public:
21  typedef shared_ptr< Edge > Ptr;
22  typedef shared_ptr< const Edge > ConstPtr;
23  typedef std::vector< Ptr > PtrList;
24  typedef std::set< Ptr > PtrSet;
25 
26  Edge(const std::string& label = std::string());
27 
28  Edge(const Vertex::Ptr& source, const Vertex::Ptr& target, const std::string& label = std::string());
29 
30  virtual ~Edge() {}
31 
36  Edge::Ptr clone() const;
37 
38  // Get class name
39  // \return class name
40  virtual std::string getClassName() const;
41 
46  virtual std::string toString() const;
47 
52  virtual std::string toString(uint32_t indent) const;
53 
57  Vertex::Ptr getSourceVertex() const { return mSourceVertex; }
58 
62  Vertex::Ptr getTargetVertex() const { return mTargetVertex; }
63 
67  void setSourceVertex(const Vertex::Ptr& source) { mSourceVertex = source; }
68 
72  void setTargetVertex(const Vertex::Ptr& target) { mTargetVertex = target; }
73 
78  static std::vector<Vertex::Ptr> getInvolvedVertices(const Edge::Ptr& e0, const Edge::Ptr& e1);
79 
84  static bool areMeeting(const Edge::Ptr& e0, const Edge::Ptr& e1);
85 
95  Edge::Ptr getSharedPointerFromGraph(const shared_ptr<BaseGraph> &pGraph) const;
96 
100  Edge::Ptr getPtr();
101 
106  Edge::ConstPtr getPtr() const;
107 
128  virtual void registerAttributes(EdgeTypeManager*) const {}
129 protected:
133  virtual Edge* getClone() const { return new Edge(*this); }
134 
135 private:
136  Vertex::Ptr mSourceVertex;
137  Vertex::Ptr mTargetVertex;
138 };
139 
140 } // end namespace graph_analysis
141 #endif // GRAPH_ANALYSIS_EDGE_HPP
GraphElement is the base class for all element in a graph, i.e. for edges and vertices.
Definition: GraphElement.hpp:34
Edge::Ptr getPtr()
Definition: Edge.cpp:81
virtual ~Edge()
Definition: Edge.hpp:30
Edge::Ptr clone() const
Definition: Edge.cpp:16
Factory for Edge subclasses.
Definition: EdgeTypeManager.hpp:30
shared_ptr< Edge > Ptr
Definition: Edge.hpp:21
Edge(const std::string &label=std::string())
Definition: Edge.cpp:6
Main namespace of the graph analysis library.
Definition: BFS.cpp:3
shared_ptr< Vertex > Ptr
Definition: Vertex.hpp:22
virtual std::string toString() const
Definition: Edge.cpp:28
static std::vector< Vertex::Ptr > getInvolvedVertices(const Edge::Ptr &e0, const Edge::Ptr &e1)
Definition: Edge.cpp:46
static bool areMeeting(const Edge::Ptr &e0, const Edge::Ptr &e1)
Definition: Edge.cpp:71
An Edge represents the link between two vertices.
Definition: Edge.hpp:18
Edge::Ptr getSharedPointerFromGraph(const shared_ptr< BaseGraph > &pGraph) const
Definition: Edge.cpp:76
virtual Edge * getClone() const
Definition: Edge.hpp:133
Vertex::Ptr getSourceVertex() const
Definition: Edge.hpp:57
virtual void registerAttributes(EdgeTypeManager *) const
Definition: Edge.hpp:128
shared_ptr< const Edge > ConstPtr
Definition: Edge.hpp:22
virtual std::string getClassName() const
Definition: Edge.cpp:23
std::set< Ptr > PtrSet
Definition: Edge.hpp:24
Vertex::Ptr getTargetVertex() const
Definition: Edge.hpp:62
std::vector< Ptr > PtrList
Definition: Edge.hpp:23
void setTargetVertex(const Vertex::Ptr &target)
Definition: Edge.hpp:72
void setSourceVertex(const Vertex::Ptr &source)
Definition: Edge.hpp:67