Fréchet View  1.6.0
A Tool for Exploring Fréchet Distance Algorithms
graph_boost.h
Go to the documentation of this file.
1 #ifndef GRAPH_H
2 #define GRAPH_H
3 
4 #include <structure.h>
5 #include <boost/graph/graph_traits.hpp>
6 #include <boost/graph/adjacency_list.hpp>
7 //#include <boost/graph/adjacency_matrix.hpp>
8 
9 
10 namespace frechet { namespace reach {
11 
12 class GraphModel;
13 
39 class Graph
40 {
41 private:
42  typedef boost::property <boost::vertex_name_t, int> Name;
43  typedef boost::property <boost::vertex_index_t, std::size_t, Name> Index;
44  typedef boost::adjacency_list < boost::setS, boost::listS, boost::directedS, Index > graph_t;
45  //typedef boost::adjacency_matrix <boost::directedS> graph_t;
46  typedef boost::graph_traits < graph_t >::vertex_descriptor vertex_t;
47 
48  // TODO Map Indexes to vertices. This a awkward and error-prone. There must be better ways with boost::graph !!
49  typedef boost::unordered_map<int,vertex_t> Index2VertexMap;
50  typedef boost::property_map<graph_t,boost::vertex_index_t>::type Vertex2IndexMap;
51 
54 
55  const GraphModel& model;
56 
57  Graph(const GraphModel& model, graph_t* ag);
58 public:
59  typedef boost::shared_ptr<Graph> ptr;
60 
61  Graph(const GraphModel& model);
62  Graph(const GraphModel& model, Structure& str, int i0);
63  Graph(const Graph&);
64  Graph(Graph&&);
65 
66  ~Graph();
67 
68  int vertices() const;
69  int edges() const;
70 
71  Graph& operator= (const Graph&);
73 
74  Graph& operator+= (const Graph&);
75 
78 
79  void add_edge(int i, int j);
80 
81  void clear();
82 
83 private:
84 
85  void copy(const Graph&);
86  void swap(Graph&);
87  vertex_t vertex(int i);
88 
89  // copy reachability info from Structure to Graph
90  void copy(const Structure& str, Pointer i1, Pointer i2);
91 };
92 
109 class GraphModel {
110 private:
111  // horizontal an vertical model (interval lists)
113  // entry points for columns (reachability graphs starting at a certain free-space column)
114  std::vector<Pointer> _column_entry;
115  // TODO do we need row entry points, too ?
116  // number of vertices
117  int _count;
118 public:
119  GraphModel();
120  GraphModel(Structure& prototype);
121 
122  void init(Structure& prototype);
123 
124  int count() const { return _count; }
125 
126  // refince (= adjust intervals to prototype = the "most refined" structure)
127  void refine(Structure& str, int i0) const;
128 
129  // (1) index Boundary Segments
130  // @deprecated should be already part of 'refine'
131  void indexify(Structure& str, int i0) const;
132 
133 private:
134  BoundaryList& list(Orientation ori) { return _model[ori]; }
135 
138 
139  const BoundaryList& horiz() const { return _model[HORIZONTAL]; }
140  const BoundaryList& vert() const { return _model[VERTICAL]; }
141 
142  void indexify(Structure& str, Orientation ori, const Pointer model) const;
143  void refine(Structure& str, Orientation ori, const Pointer model) const;
144 };
145 
146 } } // namespace frecht::reach
147 
148 #endif // GRAPH_H
Graph & operator+=(const Graph &)
Definition: graph_boost.cpp:77
BoundaryList _model[2]
Definition: graph_boost.h:112
Index2VertexMap i2v
Definition: graph_boost.h:53
boost::graph_traits< graph_t >::vertex_descriptor vertex_t
Definition: graph_boost.h:46
void copy(const Graph &)
Graph::ptr transitiveClosure() const
vertex_t vertex(int i)
model the mapping of free-space intervals to nodes in a frechet::reach::Graph.
Definition: graph_boost.h:109
global definitions for all algorithms.
boost::adjacency_list< boost::setS, boost::listS, boost::directedS, Index > graph_t
Definition: graph_boost.h:44
void indexify(Structure &str, int i0) const
boundary interval in the reachability structure. Represents an interval on the boundary of the FreeSp...
Definition: boundary.h:285
std::vector< Pointer > _column_entry
Definition: graph_boost.h:114
const BoundaryList & horiz() const
Definition: graph_boost.h:139
boost::property< boost::vertex_index_t, std::size_t, Name > Index
Definition: graph_boost.h:43
Orientation
Segment Orientation.
Definition: boundary.h:31
boost::shared_ptr< Graph > ptr
Definition: graph_boost.h:59
Graph(const GraphModel &model, graph_t *ag)
Definition: graph_boost.cpp:10
BoundaryList & list(Orientation ori)
Definition: graph_boost.h:134
Represents a Reachability Graph. Vertices correspond to intervals in the reachability structure,...
Definition: graph_boost.h:39
void init(Structure &prototype)
#define str(S)
void add_edge(int i, int j)
void refine(Structure &str, int i0) const
BoundaryList & vert()
Definition: graph_boost.h:137
const GraphModel & model
Definition: graph_boost.h:55
The Reachability Structure; maintains a list of intervals on the border of Free Space,...
Definition: structure.h:32
boost::property< boost::vertex_name_t, int > Name
Definition: graph_boost.h:42
boost::property_map< graph_t, boost::vertex_index_t >::type Vertex2IndexMap
Definition: graph_boost.h:50
const BoundaryList & vert() const
Definition: graph_boost.h:140
BoundaryList & horiz()
Definition: graph_boost.h:136
Graph & operator=(const Graph &)
Definition: graph_boost.cpp:64
boost::unordered_map< int, vertex_t > Index2VertexMap
Definition: graph_boost.h:49