graph_analysis
DirectedGraph.hpp
Go to the documentation of this file.
1 #ifndef GRAPH_ANALYSIS_LEMON_DIRECTED_GRAPH_HPP
2 #define GRAPH_ANALYSIS_LEMON_DIRECTED_GRAPH_HPP
3 
4 #include <lemon/adaptors.h>
5 #include <lemon/lgf_writer.h>
6 #include <lemon/connectivity.h>
7 
8 #include "../BaseGraph.hpp"
9 #include "DirectedSubGraph.hpp"
10 
11 namespace graph_analysis {
12 namespace lemon {
13 
18 class DirectedGraph : public TypedGraph< ::lemon::ListDigraph, graph_analysis::BaseGraph >
19 {
20 public:
21  typedef shared_ptr<DirectedGraph> Ptr;
22 
26  DirectedGraph();
27 
29 
33  BaseGraph::Ptr copy() const;
34 
39 
40  typedef graph_t::ArcMap< Edge::Ptr > EdgeMap;
41  typedef graph_t::NodeMap< Vertex::Ptr > VertexMap;
42 
43  typedef graph_t::NodeMap<bool> VertexActivationMap;
44  typedef graph_t::ArcMap<bool> EdgeActivationMap;
45 
46  typedef graph_t::ArcMap< std::string > EdgeStringMap;
47  typedef graph_t::NodeMap< std::string > VertexStringMap;
48 
49  typedef graph_t::ArcMap< GraphElementId > EdgeIdMap;
50  typedef graph_t::NodeMap< GraphElementId > VertexIdMap;
51 
52  // Register the DirectedSubGraph as subgraph type
54 
55  friend class NodeIterator<DirectedGraph>;
56  friend class ArcIterator<DirectedGraph>;
59 
63  graph_t::Node getNode(const Vertex::Ptr& vertex) const;
64  graph_t::Arc getArc(const Edge::Ptr& edge) const;
65 
70  Vertex::Ptr getVertex(graph_t::Node node) const;
71 
76  Edge::Ptr getEdge(graph_t::Arc arc) const;
77 
80 
85  Vertex::Ptr getSourceVertex(const Edge::Ptr& e) const;
86 
91  Vertex::Ptr getTargetVertex(const Edge::Ptr& e) const;
92 
93  DirectedGraph(const DirectedGraph& other);
94 
99  DirectedGraph& operator=(const DirectedGraph& other);
100 
101  void write(std::ostream& ostream = std::cout) const;
102 
107 
112 
113  EdgeIterator::Ptr getEdgeIterator(const Vertex::Ptr& vertex) const;
114 
115  EdgeIterator::Ptr getOutEdgeIterator(const Vertex::Ptr& vertex) const;
116  EdgeIterator::Ptr getInEdgeIterator(const Vertex::Ptr& vertex) const;
117 
122 
126  bool isConnected() const override;
127 
128 protected:
133  virtual GraphElementId addVertexInternal(const Vertex::Ptr& vertex);
134 
138  virtual void removeVertexInternal(const Vertex::Ptr&);
139 
144  GraphElementId addEdgeInternal(const Edge::Ptr& edge, GraphElementId sourceVertexId, GraphElementId targetVertexId);
145 
150  virtual void removeEdgeInternal(const Edge::Ptr&);
151 
156  virtual SubGraph::Ptr createSubGraph(const BaseGraph::Ptr& graph) const;
157 
158  // Property maps to store data associated with vertices and edges
159  EdgeMap mEdgeMap;
160  VertexMap mVertexMap;
161 
162 };
163 
164 } // end namespace lemon
165 } // end namespace graph_analysis
166 #endif // GRAPH_ANALYSIS_LEMON_DIRECTED_GRAPH_HPP
EdgeIterator::Ptr getInEdgeIterator(const Vertex::Ptr &vertex) const
Definition: DirectedGraph.cpp:198
DirectedGraph & operator=(const DirectedGraph &other)
Direct usage off operator= is disallowed in lemon, thus need for explicit usage of copy functions...
Definition: DirectedGraph.cpp:111
~DirectedGraph()
Definition: DirectedGraph.cpp:23
uint32_t GraphElementId
Definition: GraphElement.hpp:21
Definition: TypedGraph.hpp:9
Definition: ArcIterator.hpp:11
Definition: DirectedSubGraph.hpp:22
EdgeIterator::Ptr getEdgeIterator() const
Definition: DirectedGraph.cpp:180
graph_t::ArcMap< Edge::Ptr > EdgeMap
Definition: DirectedGraph.hpp:40
virtual void removeVertexInternal(const Vertex::Ptr &)
Definition: DirectedGraph.cpp:36
graph_t::NodeMap< bool > VertexActivationMap
Definition: DirectedGraph.hpp:43
BaseGraph::Ptr copy() const
Definition: DirectedGraph.cpp:289
GraphElementId addEdgeInternal(const Edge::Ptr &edge, GraphElementId sourceVertexId, GraphElementId targetVertexId)
Add an edge.
Definition: DirectedGraph.cpp:43
graph_t::Node getNode(const Vertex::Ptr &vertex) const
Definition: DirectedGraph.cpp:63
Definition: ArcIterator.hpp:74
SubGraph::Ptr identifyConnectedComponents(const BaseGraph::Ptr &baseGraph) const
Definition: DirectedGraph.cpp:204
Vertex::Ptr getSourceVertex(const Edge::Ptr &e) const
Get the source vertex for this edge.
Definition: DirectedGraph.cpp:95
graph_t::NodeMap< std::string > VertexStringMap
Definition: DirectedGraph.hpp:47
shared_ptr< Edge > Ptr
Definition: Edge.hpp:21
virtual void removeEdgeInternal(const Edge::Ptr &)
Definition: DirectedGraph.cpp:56
DirectedSubGraph subgraph_t
Definition: DirectedGraph.hpp:53
graph_t::ArcMap< bool > EdgeActivationMap
Definition: DirectedGraph.hpp:44
virtual SubGraph::Ptr createSubGraph(const BaseGraph::Ptr &graph) const
Definition: DirectedGraph.cpp:272
graph_t::Arc getArc(const Edge::Ptr &edge) const
Definition: DirectedGraph.cpp:68
Main namespace of the graph analysis library.
Definition: BFS.cpp:3
Definition: NodeIterator.hpp:11
shared_ptr< Vertex > Ptr
Definition: Vertex.hpp:22
shared_ptr< EdgeIterator > Ptr
Definition: EdgeIterator.hpp:20
graph_t::NodeMap< GraphElementId > VertexIdMap
Definition: DirectedGraph.hpp:50
BaseGraph::Ptr newInstance() const
Definition: DirectedGraph.cpp:294
Definition: ArcIterator.hpp:42
bool isConnected() const override
Definition: DirectedGraph.cpp:267
VertexIterator::Ptr getVertexIterator() const
Definition: DirectedGraph.cpp:174
Vertex::Ptr getVertex(graph_t::Node node) const
shared_ptr< DirectedGraph > Ptr
Definition: DirectedGraph.hpp:21
virtual GraphElementId addVertexInternal(const Vertex::Ptr &vertex)
Add a vertex.
Definition: DirectedGraph.cpp:26
shared_ptr< SubGraph > Ptr
Definition: SubGraph.hpp:52
graph_t::ArcMap< std::string > EdgeStringMap
Definition: DirectedGraph.hpp:46
VertexMap mVertexMap
Definition: DirectedGraph.hpp:160
shared_ptr< VertexIterator > Ptr
Definition: VertexIterator.hpp:21
EdgeIterator::Ptr getOutEdgeIterator(const Vertex::Ptr &vertex) const
Definition: DirectedGraph.cpp:192
shared_ptr< BaseGraph > Ptr
Definition: BaseGraph.hpp:34
EdgeMap mEdgeMap
Definition: DirectedGraph.hpp:159
Edge::Ptr getEdge(graph_t::Arc arc) const
graph_t::ArcMap< GraphElementId > EdgeIdMap
Definition: DirectedGraph.hpp:49
DirectedGraph()
Default constructor of the graph.
Definition: DirectedGraph.cpp:9
Directed graph implementation based on lemon library.
Definition: DirectedGraph.hpp:18
Vertex::Ptr getTargetVertex(const Edge::Ptr &e) const
Get the target vertex for this edge.
Definition: DirectedGraph.cpp:101
void write(std::ostream &ostream=std::cout) const
Definition: DirectedGraph.cpp:133
graph_t::NodeMap< Vertex::Ptr > VertexMap
Definition: DirectedGraph.hpp:41