Gudhi  1.1.0
 All Classes Functions 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 GUDHI_SKELETON_BLOCKERS_SIMPLE_TRAITS_H_
23 #define GUDHI_SKELETON_BLOCKERS_SIMPLE_TRAITS_H_
24 
25 #include <string>
26 #include <sstream>
27 #include "Skeleton_blocker_simplex.h"
28 
29 namespace Gudhi{
30 
31 namespace skbl {
32 
49  typedef int boost_vertex_handle;
50  explicit Root_vertex_handle(boost_vertex_handle val = -1 ):vertex(val){}
51  boost_vertex_handle vertex;
52 
53  bool operator!=( const Root_vertex_handle& other) const{
54  return ! (this->vertex == other.vertex);
55  }
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  friend std::ostream& operator << (std::ostream& o, const Root_vertex_handle & v)
66  {
67  o << v.vertex;
68  return o;
69  }
70  };
71 
72  struct Vertex_handle{
73  typedef int boost_vertex_handle;
74  Vertex_handle(boost_vertex_handle val=-1):vertex(val){}
75 
76  boost_vertex_handle vertex;
77 
78  bool operator==( const Vertex_handle& other) const{
79  return this->vertex == other.vertex;
80  }
81 
82  bool operator!=( const Vertex_handle& other) const{
83  return this->vertex != other.vertex;
84  }
85 
86  bool operator<(const Vertex_handle& other) const{
87  return this->vertex < other.vertex;
88  }
89 
90  friend std::ostream& operator << (std::ostream& o, const Vertex_handle & v)
91  {
92  o << v.vertex;
93  return o;
94  }
95  };
96 
97 
98 
99  class Graph_vertex {
100  bool is_active_;
101  Root_vertex_handle id_;
102  public:
103  virtual ~Graph_vertex(){}
104 
105  void activate(){is_active_=true;}
106  void deactivate(){is_active_=false;}
107  bool is_active() const{return is_active_;}
108  void set_id(Root_vertex_handle i){id_=i;}
109  Root_vertex_handle get_id() const{return id_;}
110 
111  virtual std::string to_string() const {
112  std::ostringstream res;
113  res<< id_;
114  return res.str();
115  }
116 
117  friend std::ostream& operator << (std::ostream& o, const Graph_vertex & v){
118  o << v.to_string();
119  return o;
120  }
121  };
122 
123  class Graph_edge {
126  int index_;
127  public:
128 
129  Graph_edge():a_(-1),b_(-1),index_(-1){}
130 
131  int& index(){return index_;}
132  int index() const {return index_;}
133 
134  void setId(Root_vertex_handle a,Root_vertex_handle b){
135  a_ = a;
136  b_ = b;
137  }
138 
139  Root_vertex_handle first() const {
140  return a_;
141  }
142 
143  Root_vertex_handle second() const {
144  return b_;
145  }
146 
147  friend std::ostream& operator << (std::ostream& o, const Graph_edge & v){
148  o << "("<<v.a_<<","<<v.b_<<" - id = "<<v.index();
149  return o;
150  }
151  };
152 
153 };
154 
155 }
156 
157 } // namespace GUDHI
158 
159 #endif /* GUDHI_SKELETON_BLOCKERS_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:48
Simple traits that is a model of SkeletonBlockerDS and can be passed as a template argument to Skelet...
Definition: Skeleton_blocker_simple_traits.h:39
Root_vertex_handle and Vertex_handle are similar to global and local vertex descriptor used in boost ...
Definition: SkeletonBlockerDS.h:50