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
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 
23 #ifndef SKELETON_BLOCKER_SKELETON_BLOCKER_SIMPLE_TRAITS_H_
24 #define SKELETON_BLOCKER_SKELETON_BLOCKER_SIMPLE_TRAITS_H_
25 
26 #include <gudhi/Skeleton_blocker/Skeleton_blocker_simplex.h>
27 
28 #include <string>
29 #include <sstream>
30 
31 namespace Gudhi {
32 
33 namespace skeleton_blocker {
34 
51  typedef int boost_vertex_handle;
52 
53  explicit Root_vertex_handle(boost_vertex_handle val = -1)
54  : vertex(val) { }
55  boost_vertex_handle vertex;
56 
57  bool operator!=(const Root_vertex_handle& other) const {
58  return !(this->vertex == other.vertex);
59  }
60 
61  bool operator==(const Root_vertex_handle& other) const {
62  return this->vertex == other.vertex;
63  }
64 
65  bool operator<(const Root_vertex_handle& other) const {
66  return this->vertex < other.vertex;
67  }
68 
69  friend std::ostream& operator<<(std::ostream& o,
70  const Root_vertex_handle & v) {
71  o << v.vertex;
72  return o;
73  }
74  };
75 
76  struct Vertex_handle {
77  typedef int boost_vertex_handle;
78 
79  explicit Vertex_handle(boost_vertex_handle val = -1)
80  : vertex(val) { }
81 
82  operator int() const {
83  return static_cast<int> (vertex);
84  }
85 
86  boost_vertex_handle vertex;
87 
88  bool operator==(const Vertex_handle& other) const {
89  return this->vertex == other.vertex;
90  }
91 
92  bool operator!=(const Vertex_handle& other) const {
93  return this->vertex != other.vertex;
94  }
95 
96  bool operator<(const Vertex_handle& other) const {
97  return this->vertex < other.vertex;
98  }
99 
100  friend std::ostream& operator<<(std::ostream& o, const Vertex_handle & v) {
101  o << v.vertex;
102  return o;
103  }
104  };
105 
106  class Graph_vertex {
107  bool is_active_;
108  Root_vertex_handle id_;
109 
110  public:
111  virtual ~Graph_vertex() { }
112 
113  void activate() {
114  is_active_ = true;
115  }
116 
117  void deactivate() {
118  is_active_ = false;
119  }
120 
121  bool is_active() const {
122  return is_active_;
123  }
124 
125  void set_id(Root_vertex_handle i) {
126  id_ = i;
127  }
128 
129  Root_vertex_handle get_id() const {
130  return id_;
131  }
132 
133  virtual std::string to_string() const {
134  std::ostringstream res;
135  res << id_;
136  return res.str();
137  }
138 
139  friend std::ostream& operator<<(std::ostream& o, const Graph_vertex & v) {
140  o << v.to_string();
141  return o;
142  }
143  };
144 
145  class Graph_edge {
148  int index_;
149 
150  public:
151  Graph_edge()
152  : a_(-1),
153  b_(-1),
154  index_(-1) { }
155 
156  int& index() {
157  return index_;
158  }
159 
160  int index() const {
161  return index_;
162  }
163 
164  void setId(Root_vertex_handle a, Root_vertex_handle b) {
165  a_ = a;
166  b_ = b;
167  }
168 
169  Root_vertex_handle first() const {
170  return a_;
171  }
172 
173  Root_vertex_handle second() const {
174  return b_;
175  }
176 
177  friend std::ostream& operator<<(std::ostream& o, const Graph_edge & v) {
178  o << "(" << v.a_ << "," << v.b_ << " - id = " << v.index();
179  return o;
180  }
181  };
182 };
183 
184 } // namespace skeleton_blocker
185 
186 namespace skbl = skeleton_blocker;
187 
188 } // namespace Gudhi
189 
190 #endif // SKELETON_BLOCKER_SKELETON_BLOCKER_SIMPLE_TRAITS_H_
Definition: SimplicialComplexForAlpha.h:26
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 &#39;v&#39;, the local descriptor of &#39;v&#39; is its position in the vertex vector of the subcomplex L whereas its global descriptor is the position of &#39;v&#39; in the vertex vector of the root simplicial complex.
Definition: Skeleton_blocker_simple_traits.h:50
Simple traits that is a model of SkeletonBlockerDS and can be passed as a template argument to Skelet...
Definition: Skeleton_blocker_simple_traits.h:41
GUDHI  Version 2.2.0  - C++ library for Topological Data Analysis (TDA) and Higher Dimensional Geometry Understanding.  - Copyright : GPL v3 Generated on Thu Jun 14 2018 15:00:55 for GUDHI by Doxygen 1.8.13