Loading...
Searching...
No Matches
simple_toplex_map.cpp

Collapse

/* This file is part of the Gudhi Library - https://gudhi.inria.fr/ - which is released under MIT.
* See file LICENSE or go to https://gudhi.inria.fr/licensing/ for full license details.
* Author(s): Vincent Rouvreau
*
* Copyright (C) 2018
*
* Modification(s):
* - YYYY/MM Author: Description of the modification
*/
#include <gudhi/Toplex_map.h>
#include <iostream>
#include <utility> // for pair
#include <vector>
#include <cassert>
int main(int argc, char* const argv[]) {
using Simplex = Gudhi::Toplex_map::Simplex;
Simplex sigma1 = {1, 2, 3};
Simplex sigma2 = {2, 3, 4, 5};
tm.insert_simplex(sigma1);
tm.insert_simplex(sigma2);
/* Simplex is: */
/* 2 4 */
/* o---o */
/* /X\5/ */
/* o---o */
/* 1 3 */
std::clog << "num max simplices = " << tm.num_maximal_simplices() << " - num vertices = " << tm.num_vertices()
<< std::endl;
// Browse maximal cofaces
Simplex sigma3 = {2, 3};
std::clog << "Maximal cofaces of {2, 3} are :" << std::endl;
for (auto simplex_ptr : tm.maximal_cofaces(sigma3, 2)) {
for (auto v : *simplex_ptr) {
std::clog << v << ", ";
}
std::clog << std::endl;
}
// Browse maximal simplices
std::clog << "Maximal simplices are :" << std::endl;
for (auto simplex_ptr : tm.maximal_simplices()) {
for (auto v : *simplex_ptr) {
std::clog << v << ", ";
}
std::clog << std::endl;
}
Simplex sigma4 = {1, 3};
assert(tm.membership(sigma4));
std::clog << "After contraction(1, 3) - " << v << std::endl;
/* Simplex is: */
/* 2 4 */
/* o---o */
/* \5/ */
/* o */
/* 3 */
std::clog << "num max simplices = " << tm.num_maximal_simplices() << " - num vertices = " << tm.num_vertices()
<< std::endl;
// Browse maximal simplices
std::clog << "Maximal simplices are :" << std::endl;
for (auto simplex_ptr : tm.maximal_simplices()) {
for (auto v : *simplex_ptr) {
std::clog << v << ", ";
}
std::clog << std::endl;
}
Simplex sigma5 = {3, 4};
assert(tm.membership(sigma5));
v = tm.contraction(3, 4);
std::clog << "After contraction(3, 4) - " << v << std::endl;
/* Simplex is: */
/* 2 4 */
/* o---o */
/* \X/ */
/* o */
/* 5 */
std::clog << "num max simplices = " << tm.num_maximal_simplices() << " - num vertices = " << tm.num_vertices()
<< std::endl;
// Browse maximal simplices
std::clog << "Maximal simplices are :" << std::endl;
for (auto simplex_ptr : tm.maximal_simplices()) {
for (auto v : *simplex_ptr) {
std::clog << v << ", ";
}
std::clog << std::endl;
}
tm.insert_simplex(sigma1);
tm.insert_simplex(sigma2);
/* Simplex is: */
/* 2 4 */
/* o---o */
/* /X\5/ */
/* o---o */
/* 1 3 */
tm.remove_simplex(sigma1);
std::clog << "After remove_simplex(1, 2, 3)" << std::endl;
/* Simplex is: */
/* 2 4 */
/* o---o */
/* / \5/ */
/* o---o */
/* 1 3 */
std::clog << "num max simplices = " << tm.num_maximal_simplices() << " - num vertices = " << tm.num_vertices()
<< std::endl;
// Browse maximal simplices
std::clog << "Maximal simplices are :" << std::endl;
for (auto simplex_ptr : tm.maximal_simplices()) {
for (auto v : *simplex_ptr) {
std::clog << v << ", ";
}
std::clog << std::endl;
}
std::clog << "After remove_vertex(1)" << std::endl;
/* Simplex is: */
/* 2 4 */
/* o---o */
/* \5/ */
/* o */
/* 3 */
std::clog << "num max simplices = " << tm.num_maximal_simplices() << " - num vertices = " << tm.num_vertices()
<< std::endl;
// Browse maximal simplices
std::clog << "Maximal simplices are :" << std::endl;
for (auto simplex_ptr : tm.maximal_simplices()) {
for (auto v : *simplex_ptr) {
std::clog << v << ", ";
}
std::clog << std::endl;
}
return 0;
}
Toplex map data structure for representing unfiltered simplicial complexes.
Definition: Toplex_map.h:29
Toplex_map::Simplex_ptr_set maximal_cofaces(const Input_vertex_range &vertex_range, const std::size_t max_number=0) const
Definition: Toplex_map.h:187
void remove_vertex(const Vertex x)
Definition: Toplex_map.h:253
Toplex_map::Simplex_ptr_set maximal_simplices(const std::size_t max_number=0) const
Definition: Toplex_map.h:78
std::size_t num_vertices() const
Number of vertices.
Definition: Toplex_map.h:94
std::size_t num_maximal_simplices() const
Number of maximal simplices.
Definition: Toplex_map.h:91
bool membership(const Input_vertex_range &vertex_range) const
Definition: Toplex_map.h:169
Vertex contraction(const Vertex x, const Vertex y)
Definition: Toplex_map.h:211
void remove_simplex(const Input_vertex_range &vertex_range)
Removes the given simplex and its cofaces from the complex. Its faces are kept inside.
Definition: Toplex_map.h:151
std::set< Vertex > Simplex
Definition: Toplex_map.h:35
std::size_t Vertex
Definition: Toplex_map.h:32
void insert_simplex(const Input_vertex_range &vertex_range)
Adds the given simplex to the complex. Nothing happens if the simplex is already in the complex (i....
Definition: Toplex_map.h:130