Gudhi  1.2.0
 All Classes Functions Variables Typedefs Friends Groups Pages
Skeleton_blocker_simple_traits.h
1 /* This file is part of the Gudhi Library. The Gudhi library
2  * (Geometric Understanding in Higher Dimensions) is a generic C++
3  * library for computational topology.
4  *
5  * Author(s): David Salinas
6  *
7  * Copyright (C) 2014 INRIA Sophia Antipolis-Mediterranee (France)
8  *
9  * This program is free software: you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation, either version 3 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program. If not, see <http://www.gnu.org/licenses/>.
21  */
22 #ifndef SKELETON_BLOCKER_SKELETON_BLOCKER_SIMPLE_TRAITS_H_
23 #define SKELETON_BLOCKER_SKELETON_BLOCKER_SIMPLE_TRAITS_H_
24 
25 #include <gudhi/Skeleton_blocker/Skeleton_blocker_simplex.h>
26 
27 #include <string>
28 #include <sstream>
29 
30 namespace Gudhi {
31 
32 namespace skbl {
33 
50  typedef int boost_vertex_handle;
51  explicit Root_vertex_handle(boost_vertex_handle val = -1)
52  : vertex(val) {
53  }
54  boost_vertex_handle vertex;
55 
56  bool operator!=(const Root_vertex_handle& other) const {
57  return !(this->vertex == other.vertex);
58  }
59 
60  bool operator==(const Root_vertex_handle& other) const {
61  return this->vertex == other.vertex;
62  }
63 
64  bool operator<(const Root_vertex_handle& other) const {
65  return this->vertex < other.vertex;
66  }
67 
68  friend std::ostream& operator <<(std::ostream& o,
69  const Root_vertex_handle & v) {
70  o << v.vertex;
71  return o;
72  }
73  };
74 
75  struct Vertex_handle {
76  typedef int boost_vertex_handle;
77  explicit Vertex_handle(boost_vertex_handle val = -1)
78  : vertex(val) {
79  }
80 
81  operator int() const { return static_cast<int>(vertex); }
82 
83  boost_vertex_handle vertex;
84 
85  bool operator==(const Vertex_handle& other) const {
86  return this->vertex == other.vertex;
87  }
88 
89  bool operator!=(const Vertex_handle& other) const {
90  return this->vertex != other.vertex;
91  }
92 
93  bool operator<(const Vertex_handle& other) const {
94  return this->vertex < other.vertex;
95  }
96 
97  friend std::ostream& operator <<(std::ostream& o, const Vertex_handle & v) {
98  o << v.vertex;
99  return o;
100  }
101  };
102 
103  class Graph_vertex {
104  bool is_active_;
105  Root_vertex_handle id_;
106 
107  public:
108  virtual ~Graph_vertex() {
109  }
110 
111  void activate() {
112  is_active_ = true;
113  }
114  void deactivate() {
115  is_active_ = false;
116  }
117  bool is_active() const {
118  return is_active_;
119  }
120  void set_id(Root_vertex_handle i) {
121  id_ = i;
122  }
123  Root_vertex_handle get_id() const {
124  return id_;
125  }
126 
127  virtual std::string to_string() const {
128  std::ostringstream res;
129  res << id_;
130  return res.str();
131  }
132 
133  friend std::ostream& operator <<(std::ostream& o, const Graph_vertex & v) {
134  o << v.to_string();
135  return o;
136  }
137  };
138 
139  class Graph_edge {
142  int index_;
143 
144  public:
145  Graph_edge()
146  : a_(-1),
147  b_(-1),
148  index_(-1) {
149  }
150 
151  int& index() {
152  return index_;
153  }
154  int index() const {
155  return index_;
156  }
157 
158  void setId(Root_vertex_handle a, Root_vertex_handle b) {
159  a_ = a;
160  b_ = b;
161  }
162 
163  Root_vertex_handle first() const {
164  return a_;
165  }
166 
167  Root_vertex_handle second() const {
168  return b_;
169  }
170 
171  friend std::ostream& operator <<(std::ostream& o, const Graph_edge & v) {
172  o << "(" << v.a_ << "," << v.b_ << " - id = " << v.index();
173  return o;
174  }
175  };
176 };
177 
178 } // namespace skbl
179 
180 } // namespace Gudhi
181 
182 #endif // SKELETON_BLOCKER_SKELETON_BLOCKER_SIMPLE_TRAITS_H_
int boost_vertex_handle
index that allows to find the vertex in the boost graph
Definition: SkeletonBlockerDS.h:30
Global and local handle similar to boost subgraphs. Vertices are stored in a vector. For the root simplicial complex, the local and global descriptors are the same. For a subcomplex L and one of its vertices 'v', the local descriptor of 'v' is its position in the vertex vector of the subcomplex L whereas its global descriptor is the position of 'v' in the vertex vector of the root simplicial complex.
Definition: Skeleton_blocker_simple_traits.h:49
Simple traits that is a model of SkeletonBlockerDS and can be passed as a template argument to Skelet...
Definition: Skeleton_blocker_simple_traits.h:40
Root_vertex_handle and Vertex_handle are similar to global and local vertex descriptor used in boost ...
Definition: SkeletonBlockerDS.h:50