summaryrefslogtreecommitdiff
path: root/src/Simplex_tree/example/block.cpp
blob: 07ec39213d383b656255407de7277f6fd139de08 (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
/*    This file is part of the Gudhi Library. The Gudhi library
 *    (Geometric Understanding in Higher Dimensions) is a generic C++
 *    library for computational topology.
 *
 *    Author(s):       Vincent Rouvreau
 *
 *    Copyright (C) 2014
 *
 *    This program is free software: you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation, either version 3 of the License, or
 *    (at your option) any later version.
 *
 *    This program is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *
 *    You should have received a copy of the GNU General Public License
 *    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include <gudhi/graph_simplicial_complex.h>
#include <gudhi/Simplex_tree.h>

#include <iostream>
#include <utility>  // for pair
#include <vector>

using Simplex_tree = Gudhi::Simplex_tree<>;
using Vertex_handle = Simplex_tree::Vertex_handle;
using Filtration_value = Simplex_tree::Filtration_value;
using typeVectorVertex = std::vector< Vertex_handle >;
using typePairSimplexBool = std::pair< Simplex_tree::Simplex_handle, bool >;

int main(int argc, char * const argv[]) {

  // Construct the Simplex Tree
  Simplex_tree simplexTree;

  simplexTree.insert_simplex({0, 1});
  simplexTree.insert_simplex({0, 2});
  simplexTree.insert_simplex({0, 3});
  simplexTree.insert_simplex({1, 2});
  simplexTree.insert_simplex({1, 3});
  simplexTree.insert_simplex({2, 3});
  simplexTree.insert_simplex({2, 4});
  simplexTree.insert_simplex({3, 6});
  simplexTree.insert_simplex({4, 5});
  simplexTree.insert_simplex({4, 6});
  simplexTree.insert_simplex({5, 6});
  simplexTree.insert_simplex({6});

  std::cout << "********************************************************************\n";
  // Display the Simplex_tree - Can not be done in the middle of 2 inserts
  std::cout << "* The complex contains " << simplexTree.num_simplices() << " simplices\n";
  std::cout << "   - dimension " << simplexTree.dimension() << "   - filtration " << simplexTree.filtration() << "\n";
  std::cout << "* Iterator on Simplices in the filtration, with [filtration value]:\n";
  for (auto f_simplex : simplexTree.filtration_simplex_range()) {
    std::cout << "   " << "[" << simplexTree.filtration(f_simplex) << "] ";
    for (auto vertex : simplexTree.simplex_vertex_range(f_simplex))
      std::cout << "(" << vertex << ")";
    std::cout << std::endl;
  }

  simplexTree.expansion_with_blockers(3, [](){return true;});

  simplexTree.initialize_filtration();
  std::cout << "********************************************************************\n";
  // Display the Simplex_tree - Can not be done in the middle of 2 inserts
  std::cout << "* The complex contains " << simplexTree.num_simplices() << " simplices\n";
  std::cout << "   - dimension " << simplexTree.dimension() << "   - filtration " << simplexTree.filtration() << "\n";
  std::cout << "* Iterator on Simplices in the filtration, with [filtration value]:\n";
  for (auto f_simplex : simplexTree.filtration_simplex_range()) {
    std::cout << "   " << "[" << simplexTree.filtration(f_simplex) << "] ";
    for (auto vertex : simplexTree.simplex_vertex_range(f_simplex))
      std::cout << "(" << vertex << ")";
    std::cout << std::endl;
  }

  return 0;
}