graph_analysis
DirectedGraph.hpp
Go to the documentation of this file.
1 #ifndef GRAPH_ANALYSIS_SNAP_DIRECTED_GRAPH_HPP
2 #define GRAPH_ANALYSIS_SNAP_DIRECTED_GRAPH_HPP
3 
4 #include "../VertexIterator.hpp"
5 #include "../EdgeIterator.hpp"
6 #include "../TypedGraph.hpp"
7 
8 // FIXME: when not including "sstream" here, the snap header will fail due to
9 // some "min"/"max" defines. this looks like a bug in their headers?
10 #include <sstream>
11 
12 #include <snap/snap-core/Snap.h>
13 #include "DirectedSubGraph.hpp"
14 #include "NodeIterator.hpp"
15 #include "EdgeIterator.hpp"
16 
17 namespace graph_analysis {
18 namespace snap {
19 
20 template<typename T>
22 {
23  typedef T value_t;
24  T value;
25 
27  {}
28 
30  : value(value)
31  {}
32 
33  void Save(TSOut& SOut) const {}
34 };
35 
36 // TNEGraph is a DirectedGraph, but no data on nodes and edges
37 // PNEGraph is the Pointer to the TNEGraph
38 // TNodeEdgeNet is the equivalent to TNEGraph, but with data on nodes and edges
39 typedef TNodeEdgeNet< Serializable<Vertex::Ptr>, Serializable<Edge::Ptr> > SnapDigraph;
40 
46 class DirectedGraph : public graph_analysis::TypedGraph<SnapDigraph, BaseGraph>
47 {
48 public:
49  typedef shared_ptr<DirectedGraph> Ptr;
50 
51  friend class NodeIterator<DirectedGraph>;
52  friend class EdgeIterator<DirectedGraph>;
55 
59  DirectedGraph();
60 
62 
63  DirectedGraph(const DirectedGraph& other);
64 
65  BaseGraph::Ptr copy() const;
66 
68 
71 
76  Vertex::Ptr getSourceVertex(const Edge::Ptr& e) const;
77 
82  Vertex::Ptr getTargetVertex(const Edge::Ptr& e) const;
83 
88 
93 
95 
97 
99 
100 protected:
105  virtual GraphElementId addVertexInternal(const Vertex::Ptr& vertex);
106 
110  virtual void removeVertexInternal(const Vertex::Ptr& vertex);
111 
116  virtual GraphElementId addEdgeInternal(const Edge::Ptr& edge, GraphElementId sourceVertexId, GraphElementId targetVertexId);
117 
121  virtual void removeEdgeInternal(const Edge::Ptr& edge);
122 
123  virtual SubGraph::Ptr createSubGraph(const BaseGraph::Ptr& baseGraph) const;
124 };
125 
126 } // end namespace snap
127 } // end namespace graph_analysis
128 #endif // GRAPH_ANALYSIS_SNAP_DIRECTED_GRAPH_HPP
graph_analysis::snap::Serializable::value_t
T value_t
Definition: DirectedGraph.hpp:23
graph_analysis::snap::DirectedGraph::getOutEdgeIterator
graph_analysis::EdgeIterator::Ptr getOutEdgeIterator(const Vertex::Ptr &vertex) const
Definition: DirectedGraph.cpp:110
graph_analysis::snap::DirectedGraph::getTargetVertex
Vertex::Ptr getTargetVertex(const Edge::Ptr &e) const
Get the target vertex for this edge.
Definition: DirectedGraph.cpp:80
graph_analysis::snap::Serializable::Serializable
Serializable(T value)
Definition: DirectedGraph.hpp:29
graph_analysis::snap::DirectedGraph::addEdgeInternal
virtual GraphElementId addEdgeInternal(const Edge::Ptr &edge, GraphElementId sourceVertexId, GraphElementId targetVertexId)
Add an edge.
Definition: DirectedGraph.cpp:48
graph_analysis::snap::Serializable::Serializable
Serializable()
Definition: DirectedGraph.hpp:26
graph_analysis::snap::DirectedGraph::getVertex
Vertex::Ptr getVertex(GraphElementId id) const
Get the vertex by id.
Definition: DirectedGraph.cpp:63
graph_analysis::snap::DirectedGraph::newInstance
BaseGraph::Ptr newInstance() const
Definition: DirectedGraph.cpp:28
graph_analysis::snap::DirectedGraph::getEdge
Edge::Ptr getEdge(GraphElementId id) const
Get the edge by id.
Definition: DirectedGraph.cpp:68
graph_analysis::snap::DirectedGraph::Ptr
shared_ptr< DirectedGraph > Ptr
Definition: DirectedGraph.hpp:49
NodeIterator.hpp
graph_analysis::snap::Serializable
Definition: DirectedGraph.hpp:21
graph_analysis::snap::Serializable::Save
void Save(TSOut &SOut) const
Definition: DirectedGraph.hpp:33
graph_analysis::snap::Serializable::value
T value
Definition: DirectedGraph.hpp:24
graph_analysis::snap::DirectedGraph::~DirectedGraph
~DirectedGraph()
Definition: DirectedGraph.cpp:12
DirectedSubGraph.hpp
graph_analysis
Main namespace of the graph analysis library.
Definition: BFS.cpp:3
graph_analysis::BaseGraph::Ptr
shared_ptr< BaseGraph > Ptr
Definition: BaseGraph.hpp:34
graph_analysis::snap::DirectedGraph::getVertexIterator
VertexIterator::Ptr getVertexIterator() const
Definition: DirectedGraph.cpp:89
graph_analysis::Edge::Ptr
shared_ptr< Edge > Ptr
Definition: Edge.hpp:21
graph_analysis::snap::OutEdgeIterator
Definition: EdgeIterator.hpp:41
graph_analysis::snap::DirectedGraph::DirectedGraph
DirectedGraph()
Default constructor of the graph.
Definition: DirectedGraph.cpp:7
graph_analysis::snap::SnapDigraph
TNodeEdgeNet< Serializable< Vertex::Ptr >, Serializable< Edge::Ptr > > SnapDigraph
Definition: DirectedGraph.hpp:39
graph_analysis::GraphElementId
uint32_t GraphElementId
Definition: GraphElement.hpp:21
graph_analysis::snap::DirectedGraph::getSourceVertex
Vertex::Ptr getSourceVertex(const Edge::Ptr &e) const
Get the source vertex for this edge.
Definition: DirectedGraph.cpp:74
graph_analysis::snap::EdgeIterator
Definition: EdgeIterator.hpp:10
graph_analysis::snap::DirectedGraph::getInEdgeIterator
graph_analysis::EdgeIterator::Ptr getInEdgeIterator(const Vertex::Ptr &vertex) const
Definition: DirectedGraph.cpp:116
graph_analysis::Vertex::Ptr
shared_ptr< Vertex > Ptr
Definition: Vertex.hpp:22
graph_analysis::snap::DirectedGraph::addVertexInternal
virtual GraphElementId addVertexInternal(const Vertex::Ptr &vertex)
Add a vertex.
Definition: DirectedGraph.cpp:33
graph_analysis::snap::DirectedGraph
Directed graph implementation based on SNAP library.
Definition: DirectedGraph.hpp:46
graph_analysis::TypedGraph
Definition: TypedGraph.hpp:9
graph_analysis::SubGraph::Ptr
shared_ptr< SubGraph > Ptr
Definition: SubGraph.hpp:52
graph_analysis::snap::DirectedGraph::createSubGraph
virtual SubGraph::Ptr createSubGraph(const BaseGraph::Ptr &baseGraph) const
Definition: DirectedGraph.cpp:122
EdgeIterator.hpp
graph_analysis::EdgeIterator::Ptr
shared_ptr< EdgeIterator > Ptr
Definition: EdgeIterator.hpp:20
graph_analysis::snap::NodeIterator
Definition: NodeIterator.hpp:10
graph_analysis::snap::DirectedGraph::removeEdgeInternal
virtual void removeEdgeInternal(const Edge::Ptr &edge)
Definition: DirectedGraph.cpp:57
graph_analysis::snap::DirectedGraph::copy
BaseGraph::Ptr copy() const
Definition: DirectedGraph.cpp:15
graph_analysis::VertexIterator::Ptr
shared_ptr< VertexIterator > Ptr
Definition: VertexIterator.hpp:21
graph_analysis::snap::DirectedGraph::getEdgeIterator
graph_analysis::EdgeIterator::Ptr getEdgeIterator() const
Definition: DirectedGraph.cpp:98
graph_analysis::snap::DirectedGraph::removeVertexInternal
virtual void removeVertexInternal(const Vertex::Ptr &vertex)
Remove vertex from the graph.
Definition: DirectedGraph.cpp:42
graph_analysis::snap::InEdgeIterator
Definition: EdgeIterator.hpp:74