Loading [MathJax]/extensions/TeX/AMSsymbols.js
All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
graph_expansion_with_blocker.cpp
/* 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) 2014 Inria
*
* Modification(s):
* - YYYY/MM Author: Description of the modification
*/
#include <gudhi/Simplex_tree.h>
#include <iostream>
using Simplex_handle = Simplex_tree::Simplex_handle;
int main(int argc, char* const argv[]) {
// Construct the Simplex Tree with a 1-skeleton graph example
Simplex_tree stree;
stree.insert_simplex({0, 1}, 0.);
stree.insert_simplex({0, 2}, 1.);
stree.insert_simplex({0, 3}, 2.);
stree.insert_simplex({1, 2}, 3.);
stree.insert_simplex({1, 3}, 4.);
stree.insert_simplex({2, 3}, 5.);
stree.insert_simplex({2, 4}, 6.);
stree.insert_simplex({3, 6}, 7.);
stree.insert_simplex({4, 5}, 8.);
stree.insert_simplex({4, 6}, 9.);
stree.insert_simplex({5, 6}, 10.);
stree.insert_simplex({6}, 10.);
stree.expansion_with_blockers(3, [&](Simplex_handle sh) {
bool result = false;
std::clog << "Blocker on [";
// User can loop on the vertices from the given simplex_handle i.e.
for (auto vertex : stree.simplex_vertex_range(sh)) {
// We block the expansion, if the vertex '6' is in the given list of vertices
if (vertex == 6) result = true;
std::clog << vertex << ", ";
}
std::clog << "] ( " << stree.filtration(sh);
// User can re-assign a new filtration value directly in the blocker (default is the maximal value of boudaries)
stree.assign_filtration(sh, stree.filtration(sh) + 1.);
std::clog << " + 1. ) = " << result << std::endl;
return result;
});
std::clog << "********************************************************************\n";
std::clog << "* The complex contains " << stree.num_simplices() << " simplices";
std::clog << " - dimension " << stree.dimension() << "\n";
std::clog << "* Iterator on Simplices in the filtration, with [filtration value]:\n";
for (auto f_simplex : stree.filtration_simplex_range()) {
std::clog << " "
<< "[" << stree.filtration(f_simplex) << "] ";
for (auto vertex : stree.simplex_vertex_range(f_simplex)) std::clog << "(" << vertex << ")";
std::clog << std::endl;
}
return 0;
}
void assign_filtration(Simplex_handle sh, Filtration_value fv)
Sets the filtration value of a simplex.
Definition: Simplex_tree.h:520
Dictionary::iterator Simplex_handle
Handle type to a simplex contained in the simplicial complex represented by the simplex tree.
Definition: Simplex_tree.h:149
Filtration_simplex_range const & filtration_simplex_range(Indexing_tag=Indexing_tag())
Returns a range over the simplices of the simplicial complex, in the order of the filtration.
Definition: Simplex_tree.h:262
std::pair< Simplex_handle, bool > insert_simplex(const InputVertexRange &simplex, Filtration_value filtration=0)
Insert a simplex, represented by a range of Vertex_handles, in the simplicial complex.
Definition: Simplex_tree.h:752
Simplex_vertex_range simplex_vertex_range(Simplex_handle sh) const
Returns a range over the vertices of a simplex.
Definition: Simplex_tree.h:273
static Filtration_value filtration(Simplex_handle sh)
Returns the filtration value of a simplex.
Definition: Simplex_tree.h:509
void expansion_with_blockers(int max_dim, Blocker block_simplex)
Expands a simplex tree containing only a graph. Simplices corresponding to cliques in the graph are a...
Definition: Simplex_tree.h:1241
int dimension(Simplex_handle sh)
Returns the dimension of a simplex.
Definition: Simplex_tree.h:574
size_t num_simplices()
returns the number of simplices in the simplex_tree.
Definition: Simplex_tree.h:552
GUDHI  Version 3.5.0  - C++ library for Topological Data Analysis (TDA) and Higher Dimensional Geometry Understanding.  - Copyright : MIT Generated on Thu Jan 13 2022 08:34:27 for GUDHI by Doxygen 1.9.2