| 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 |
#include <gudhi/Skeleton_blocker.h> |
| 12 |
|
| 13 |
#include <stdio.h> |
| 14 |
#include <stdlib.h> |
| 15 |
#include <string> |
| 16 |
#include <fstream> |
| 17 |
#include <sstream> |
| 18 |
|
| 19 |
typedef Gudhi::skeleton_blocker::Skeleton_blocker_simple_traits Traits; |
| 20 |
typedef Gudhi::skeleton_blocker::Skeleton_blocker_complex<Traits> Complex; |
| 21 |
typedef Complex::Vertex_handle Vertex_handle; |
| 22 |
typedef Complex::Root_vertex_handle Root_vertex_handle; |
| 23 |
typedef Complex::Simplex Simplex; |
| 24 |
|
| 25 |
int main(int argc, char *argv[]) { |
| 26 |
// build a full complex with 4 vertices and 2^4-1 simplices |
| 27 |
|
| 28 |
// Create a complex with four vertices (0,1,2,3) |
| 29 |
Complex complex; |
| 30 |
|
| 31 |
// Add a tetrahedron to this complex |
| 32 |
Simplex tetrahedron(Vertex_handle(0), Vertex_handle(1), Vertex_handle(2), Vertex_handle(3)); |
| 33 |
complex.add_simplex(tetrahedron); |
| 34 |
|
| 35 |
std::clog << "complex:" << complex.to_string() << std::endl; |
| 36 |
|
| 37 |
// build the link of vertex 1, eg a triangle {0,2,3} |
| 38 |
auto link = complex.link(Vertex_handle(1)); |
| 39 |
std::clog << "link:" << link.to_string() << std::endl; |
| 40 |
|
| 41 |
// Internally link is a subcomplex of 'complex' and its vertices are stored in a vector. |
| 42 |
// They can be accessed via Vertex_handle(x) where x is an index of the vector. |
| 43 |
// In that example, link has three vertices and thus it contains only |
| 44 |
// Vertex_handle(0),Vertex_handle(1) and Vertex_handle(2) are). |
| 45 |
for (int i = 0; i < 5; ++i) |
| 46 |
std::clog << "link.contains_vertex(Vertex_handle(" << i << ")):" << link.contains_vertex(Vertex_handle(i)) << |
| 47 |
std::endl; |
| 48 |
std::clog << std::endl; |
| 49 |
|
| 50 |
// To access to the initial vertices eg (0,1,2,3,4), Root_vertex_handle must be used. |
| 51 |
// For instance, to test if the link contains the vertex that was labeled i: |
| 52 |
for (int i = 0; i < 5; ++i) |
| 53 |
std::clog << "link.contains_vertex(Root_vertex_handle(" << i << ")):" << |
| 54 |
link.contains_vertex(Root_vertex_handle(i)) << std::endl; |
| 55 |
|
| 56 |
return EXIT_SUCCESS; |
| 57 |
} |