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 
29  Serializable(T value)
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 
61  ~DirectedGraph();
62 
63  DirectedGraph(const DirectedGraph& other);
64 
65  BaseGraph::Ptr copy() const;
66 
67  BaseGraph::Ptr newInstance() const;
68 
69  Vertex::Ptr getVertex(GraphElementId id) const;
70  Edge::Ptr getEdge(GraphElementId id) const;
71 
76  Vertex::Ptr getSourceVertex(const Edge::Ptr& e) const;
77 
82  Vertex::Ptr getTargetVertex(const Edge::Ptr& e) const;
83 
87  VertexIterator::Ptr getVertexIterator() const;
88 
92  graph_analysis::EdgeIterator::Ptr getEdgeIterator() const;
93 
94  graph_analysis::EdgeIterator::Ptr getEdgeIterator(const Vertex::Ptr& vertex) const;
95 
96  graph_analysis::EdgeIterator::Ptr getOutEdgeIterator(const Vertex::Ptr& vertex) const;
97 
98  graph_analysis::EdgeIterator::Ptr getInEdgeIterator(const Vertex::Ptr& vertex) const;
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
Serializable(T value)
Definition: DirectedGraph.hpp:29
Serializable()
Definition: DirectedGraph.hpp:26
uint32_t GraphElementId
Definition: GraphElement.hpp:21
Definition: TypedGraph.hpp:9
TNodeEdgeNet< Serializable< Vertex::Ptr >, Serializable< Edge::Ptr > > SnapDigraph
Definition: DirectedGraph.hpp:39
void Save(TSOut &SOut) const
Definition: DirectedGraph.hpp:33
shared_ptr< Edge > Ptr
Definition: Edge.hpp:21
T value
Definition: DirectedGraph.hpp:24
Directed graph implementation based on SNAP library.
Definition: DirectedGraph.hpp:46
shared_ptr< DirectedGraph > Ptr
Definition: DirectedGraph.hpp:49
Main namespace of the graph analysis library.
Definition: BFS.cpp:3
shared_ptr< Vertex > Ptr
Definition: Vertex.hpp:22
shared_ptr< EdgeIterator > Ptr
Definition: EdgeIterator.hpp:20
Definition: DirectedGraph.hpp:21
Definition: EdgeIterator.hpp:10
Definition: EdgeIterator.hpp:41
Definition: EdgeIterator.hpp:74
shared_ptr< SubGraph > Ptr
Definition: SubGraph.hpp:52
shared_ptr< VertexIterator > Ptr
Definition: VertexIterator.hpp:21
shared_ptr< BaseGraph > Ptr
Definition: BaseGraph.hpp:34
T value_t
Definition: DirectedGraph.hpp:23
Definition: NodeIterator.hpp:10