Loading...
Searching...
No Matches
Skeleton_blocker_simple_traits.h
1/* This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT.
2 * See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details.
3 * Author(s): David Salinas
4 *
5 * Copyright (C) 2014 Inria
6 *
7 * Modification(s):
8 * - YYYY/MM Author: Description of the modification
9 */
10
11#ifndef SKELETON_BLOCKER_SKELETON_BLOCKER_SIMPLE_TRAITS_H_
12#define SKELETON_BLOCKER_SKELETON_BLOCKER_SIMPLE_TRAITS_H_
13
14#include <gudhi/Skeleton_blocker/Skeleton_blocker_simplex.h>
15
16#include <string>
17#include <sstream>
18
19namespace Gudhi {
20
21namespace skeleton_blocker {
22
39 typedef int boost_vertex_handle;
40
41 explicit Root_vertex_handle(boost_vertex_handle val = -1)
42 : vertex(val) { }
43 boost_vertex_handle vertex;
44
45 bool operator!=(const Root_vertex_handle& other) const {
46 return !(this->vertex == other.vertex);
47 }
48
49 bool operator==(const Root_vertex_handle& other) const {
50 return this->vertex == other.vertex;
51 }
52
53 bool operator<(const Root_vertex_handle& other) const {
54 return this->vertex < other.vertex;
55 }
56
57 friend std::ostream& operator<<(std::ostream& o,
58 const Root_vertex_handle & v) {
59 o << v.vertex;
60 return o;
61 }
62 };
63
64 struct Vertex_handle {
65 typedef int boost_vertex_handle;
66
67 explicit Vertex_handle(boost_vertex_handle val = -1)
68 : vertex(val) { }
69
70 operator int() const {
71 return static_cast<int> (vertex);
72 }
73
74 boost_vertex_handle vertex;
75
76 bool operator==(const Vertex_handle& other) const {
77 return this->vertex == other.vertex;
78 }
79
80 bool operator!=(const Vertex_handle& other) const {
81 return this->vertex != other.vertex;
82 }
83
84 bool operator<(const Vertex_handle& other) const {
85 return this->vertex < other.vertex;
86 }
87
88 friend std::ostream& operator<<(std::ostream& o, const Vertex_handle & v) {
89 o << v.vertex;
90 return o;
91 }
92 };
93
94 class Graph_vertex {
95 bool is_active_;
97
98 public:
99 virtual ~Graph_vertex() { }
100
101 void activate() {
102 is_active_ = true;
103 }
104
105 void deactivate() {
106 is_active_ = false;
107 }
108
109 bool is_active() const {
110 return is_active_;
111 }
112
113 void set_id(Root_vertex_handle i) {
114 id_ = i;
115 }
116
117 Root_vertex_handle get_id() const {
118 return id_;
119 }
120
121 virtual std::string to_string() const {
122 std::ostringstream res;
123 res << id_;
124 return res.str();
125 }
126
127 friend std::ostream& operator<<(std::ostream& o, const Graph_vertex & v) {
128 o << v.to_string();
129 return o;
130 }
131 };
132
133 class Graph_edge {
136 int index_;
137
138 public:
139 Graph_edge()
140 : a_(-1),
141 b_(-1),
142 index_(-1) { }
143
144 int& index() {
145 return index_;
146 }
147
148 int index() const {
149 return index_;
150 }
151
152 void setId(Root_vertex_handle a, Root_vertex_handle b) {
153 a_ = a;
154 b_ = b;
155 }
156
157 Root_vertex_handle first() const {
158 return a_;
159 }
160
161 Root_vertex_handle second() const {
162 return b_;
163 }
164
165 friend std::ostream& operator<<(std::ostream& o, const Graph_edge & v) {
166 o << "(" << v.a_ << "," << v.b_ << " - id = " << v.index();
167 return o;
168 }
169 };
170};
171
172} // namespace skeleton_blocker
173
174namespace skbl = skeleton_blocker;
175
176} // namespace Gudhi
177
178#endif // SKELETON_BLOCKER_SKELETON_BLOCKER_SIMPLE_TRAITS_H_
std::ostream & operator<<(std::ostream &os, const Permutahedral_representation< Vertex, OrderedSetPartition > &simplex)
Print a permutahedral representation to a stream.
Definition: Permutahedral_representation.h:173
Global and local handle similar to boost subgraphs. Vertices are stored in a vector....
Definition: Skeleton_blocker_simple_traits.h:38
Simple traits that is a model of SkeletonBlockerDS and can be passed as a template argument to Skelet...
Definition: Skeleton_blocker_simple_traits.h:29
Root_vertex_handle and Vertex_handle are similar to global and local vertex descriptor used in boost ...
Definition: SkeletonBlockerDS.h:47
int boost_vertex_handle
index that allows to find the vertex in the boost graph
Definition: SkeletonBlockerDS.h:28
Handle type for the vertices of a cell complex.
Definition: VertexHandle.h:15