summaryrefslogtreecommitdiff
path: root/concept/Skeleton_blocker/SkeletonBlockerDS.h
blob: 3c650f9981a7d9c3f8a79a14b75c4030c2912cae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/*
 * SkeletonBlockerDS.h
 *
 *  Created on: Feb 20, 2014 
 *      Author: David Salinas
 *  Copyright 2013 INRIA. All rights reserved
 */

#ifndef GUDHI_SKELETONBLOCKERDS_H_
#define GUDHI_SKELETONBLOCKERDS_H_


namespace Gudhi {

namespace skeleton_blocker {



/** \brief Concept for the template class passed for Skeleton_blocker_complex.
 * Most importantly, it contains the nodes for vertices and edges
 * (Graph_vertex and Graph_edge) that are stored in the simplicial 
 * complex. The user can redefine these classes to attach
 * additional information to vertices and edges.
 */
struct SkeletonBlockerDS
{
	/**
	 * @brief index that allows to find the vertex in the boost graph
	 */
	typedef int boost_vertex_handle;


	/**
	 * @brief Root_vertex_handle and Vertex_handle are similar to global and local vertex descriptor
	 * used in <a href="http://www.boost.org/doc/libs/1_38_0/libs/graph/doc/subgraph.html">boost subgraphs</a>
	 * and allow to localize a vertex of a subcomplex on its parent root complex.
	 *
	 * In gross, vertices are stored in a vector
	 * and the Root_vertex_handle and Vertex_handle store indices of a vertex in this vector.
	 *
	 * For the root simplicial complex, the Root_vertex_handle and Vertex_handle of a vertex
	 * are the same.
	 *
	 *
	 * For a subcomplex L of a simplicial complex K, the local descriptor, ie the Vertex_handle, of a
	 * vertex v (that belongs to L)  is its position in the vector of vertices
	 * of the subcomplex L whereas its Root_vertex_handle (global descriptor) is the position of v in the vector of the
	 * vertices of the root simplicial complex K.
	 */
	struct Root_vertex_handle{

		boost_vertex_handle vertex;

		friend ostream& operator << (ostream& o, const Root_vertex_handle & v);
	};

	/**
	 * A Vertex_handle must be Default Constructible, Assignable and Equality Comparable.
	 */
	struct Vertex_handle{
		boost_vertex_handle vertex;

		friend ostream& operator << (ostream& o, const Vertex_handle & v);
	};


	/**
	 * \brief The type of vertices that are stored the boost graph.
	 * A Vertex must be Default Constructible and Equality Comparable.
	 *
	 */
	struct Graph_vertex{
		/** \brief Used to deactivate a vertex for example when contracting an edge.
		 * It allows in some cases to remove the vertex at low cost.
		 */
		void deactivate();

		/** \brief Used to activate a vertex.
		 */
		void activate();

		/** \brief Tells if the vertex is active.
		 */
		bool is_active() const;

		void set_id(Root_vertex_handle i);
		Root_vertex_handle get_id() const;
		virtual string to_string() const ;
		friend ostream& operator << (ostream& o, const Graph_vertex & v);
	};


	/**
	 * \brief The type of edges that are stored the boost graph.
	 * An Edge must be Default Constructible and Equality Comparable.
	 */
	struct Graph_edge{
		/**
		 * @brief Allows to modify vertices of the edge.
		 */
		void setId(Root_vertex_handle a,Root_vertex_handle b);

		/**
		 * @brief Returns the first vertex of the edge.
		 */
		Root_vertex_handle first() const ;

		/**
		 * @brief Returns the second vertex of the edge.
		 */
		Root_vertex_handle second() const ;

		friend ostream& operator << (ostream& o, const Simple_edge & v);
	};


};



}  // namespace skeleton_blocker

namespace skbl = skeleton_blocker;

}  // namespace Gudhi


#endif /* GUDHI_SKELETONBLOCKERDS_H_ */