summaryrefslogtreecommitdiff
path: root/src/Simplex_tree
diff options
context:
space:
mode:
authorvrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2014-12-10 14:04:18 +0000
committervrouvrea <vrouvrea@636b058d-ea47-450e-bf9e-a15bfbe3eedb>2014-12-10 14:04:18 +0000
commit429d4f06cede4d97144592eff91689fc1c707474 (patch)
tree10cbfc316b7445b887672b8b70a39b763d65fe9a /src/Simplex_tree
parente8cca67a337b9d4bdbd1a8558ad99862862145f3 (diff)
Add persistent unit test - warning fix - cpplint fix
git-svn-id: svn+ssh://scm.gforge.inria.fr/svnroot/gudhi/branches/cpplint_test@346 636b058d-ea47-450e-bf9e-a15bfbe3eedb Former-commit-id: 9ef774de762c68a449b2a9791085f58c39a0705e
Diffstat (limited to 'src/Simplex_tree')
-rw-r--r--src/Simplex_tree/include/gudhi/Simplex_tree.h63
-rw-r--r--src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_iterators.h15
-rw-r--r--src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_node_explicit_storage.h25
-rw-r--r--src/Simplex_tree/include/gudhi/Simplex_tree/indexing_tag.h7
-rw-r--r--src/Simplex_tree/test/CMakeLists.txt18
-rw-r--r--src/Simplex_tree/test/README2
-rw-r--r--src/Simplex_tree/test/simplex_tree_unit_test.cpp (renamed from src/Simplex_tree/test/UnitTestSimplexTree.cpp)0
7 files changed, 58 insertions, 72 deletions
diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree.h b/src/Simplex_tree/include/gudhi/Simplex_tree.h
index 6430c300..9b3de20a 100644
--- a/src/Simplex_tree/include/gudhi/Simplex_tree.h
+++ b/src/Simplex_tree/include/gudhi/Simplex_tree.h
@@ -20,20 +20,22 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef GUDHI_SIMPLEX_TREE_H
-#define GUDHI_SIMPLEX_TREE_H
+#ifndef SRC_SIMPLEX_TREE_INCLUDE_GUDHI_SIMPLEX_TREE_H_
+#define SRC_SIMPLEX_TREE_INCLUDE_GUDHI_SIMPLEX_TREE_H_
+
+#include <gudhi/Simplex_tree/Simplex_tree_node_explicit_storage.h>
+#include <gudhi/Simplex_tree/Simplex_tree_siblings.h>
+#include <gudhi/Simplex_tree/Simplex_tree_iterators.h>
+#include <gudhi/Simplex_tree/indexing_tag.h>
-#include <algorithm>
-#include <utility>
-#include <vector>
-#include "gudhi/Simplex_tree/Simplex_tree_node_explicit_storage.h"
-#include "gudhi/Simplex_tree/Simplex_tree_siblings.h"
-#include "gudhi/Simplex_tree/Simplex_tree_iterators.h"
-#include "gudhi/Simplex_tree/indexing_tag.h"
#include <boost/container/flat_map.hpp>
#include <boost/iterator/transform_iterator.hpp>
#include <boost/graph/adjacency_list.hpp>
+#include <algorithm>
+#include <utility>
+#include <vector>
+
namespace Gudhi {
/** \defgroup simplex_tree Filtered Complexes Package
@@ -107,18 +109,12 @@ class Simplex_tree {
/* Type of dictionary Vertex_handle -> Node for traversing the simplex tree. */
typedef typename boost::container::flat_map<Vertex_handle, Node> Dictionary;
- friend class Simplex_tree_node_explicit_storage<
- Simplex_tree<FiltrationValue, SimplexKey, VertexHandle> > ;
- friend class Simplex_tree_siblings<
- Simplex_tree<FiltrationValue, SimplexKey, VertexHandle>, Dictionary> ;
- friend class Simplex_tree_simplex_vertex_iterator<
- Simplex_tree<FiltrationValue, SimplexKey, VertexHandle> > ;
- friend class Simplex_tree_boundary_simplex_iterator<
- Simplex_tree<FiltrationValue, SimplexKey, VertexHandle> > ;
- friend class Simplex_tree_complex_simplex_iterator<
- Simplex_tree<FiltrationValue, SimplexKey, VertexHandle> > ;
- friend class Simplex_tree_skeleton_simplex_iterator<
- Simplex_tree<FiltrationValue, SimplexKey, VertexHandle> > ;
+ friend class Simplex_tree_node_explicit_storage< Simplex_tree<FiltrationValue, SimplexKey, VertexHandle> >;
+ friend class Simplex_tree_siblings< Simplex_tree<FiltrationValue, SimplexKey, VertexHandle>, Dictionary>;
+ friend class Simplex_tree_simplex_vertex_iterator< Simplex_tree<FiltrationValue, SimplexKey, VertexHandle> >;
+ friend class Simplex_tree_boundary_simplex_iterator< Simplex_tree<FiltrationValue, SimplexKey, VertexHandle> >;
+ friend class Simplex_tree_complex_simplex_iterator< Simplex_tree<FiltrationValue, SimplexKey, VertexHandle> >;
+ friend class Simplex_tree_skeleton_simplex_iterator< Simplex_tree<FiltrationValue, SimplexKey, VertexHandle> >;
template<class T1, class T2> friend class Persistent_cohomology;
/* \brief Set of nodes sharing a same parent in the simplex tree. */
@@ -400,7 +396,7 @@ class Simplex_tree {
* <CODE>Vertex_handle</CODE>.
*/
template<class RandomAccessVertexRange>
- Simplex_handle find(RandomAccessVertexRange & s) {
+ Simplex_handle find(const RandomAccessVertexRange & s) {
if (s.begin() == s.end())
std::cerr << "Empty simplex \n";
@@ -597,7 +593,7 @@ class Simplex_tree {
* Reverse lexicographic order has the property to always consider the subsimplex of a simplex
* to be smaller. The filtration function must be monotonic. */
struct is_before_in_filtration {
- is_before_in_filtration(Simplex_tree * st)
+ explicit is_before_in_filtration(Simplex_tree * st)
: st_(st) {
}
@@ -632,7 +628,7 @@ class Simplex_tree {
* boost::graph_traits<OneSkeletonGraph>::directed_category
* must be undirected_tag. */
template<class OneSkeletonGraph>
- void insert_graph(OneSkeletonGraph & skel_graph) {
+ void insert_graph(const OneSkeletonGraph& skel_graph) {
assert(num_simplices() == 0); // the simplex tree must be empty
if (boost::num_vertices(skel_graph) == 0) {
@@ -738,25 +734,22 @@ class Simplex_tree {
}
/** \brief Intersects Dictionary 1 [begin1;end1) with Dictionary 2 [begin2,end2)
* and assigns the maximal possible Filtration_value to the Nodes. */
- void intersection(std::vector<std::pair<Vertex_handle, Node> > & intersection,
+ void intersection(std::vector<std::pair<Vertex_handle, Node> >& intersection,
Dictionary_it begin1, Dictionary_it end1,
Dictionary_it begin2, Dictionary_it end2,
Filtration_value filtration) {
if (begin1 == end1 || begin2 == end2)
- return; // 0;
+ return; // ----->>
while (true) {
if (begin1->first == begin2->first) {
intersection.push_back(
std::pair<Vertex_handle, Node>(
begin1->first,
- Node(
- NULL,
- maximum(begin1->second.filtration(),
- begin2->second.filtration(), filtration))));
+ Node(NULL, maximum(begin1->second.filtration(), begin2->second.filtration(), filtration))));
++begin1;
++begin2;
if (begin1 == end1 || begin2 == end2)
- return;
+ return; // ----->>
} else {
if (begin1->first < begin2->first) {
++begin1;
@@ -765,7 +758,7 @@ class Simplex_tree {
} else {
++begin2;
if (begin2 == end2)
- return;
+ return; // ----->>
}
}
}
@@ -784,7 +777,7 @@ class Simplex_tree {
* dim idx_1 ... idx_k fil where dim is the dimension of the simplex,
* idx_1 ... idx_k are the row index (starting from 0) of the simplices of the boundary
* of the simplex, and fil is its filtration value. */
- void print_hasse(std::ostream & os) {
+ void print_hasse(std::ostream& os) {
os << num_simplices() << " " << std::endl;
for (auto sh : filtration_simplex_range(Indexing_tag())) {
os << dimension(sh) << " ";
@@ -832,7 +825,7 @@ std::istream& operator>>(std::istream & is, Simplex_tree<T1, T2, T3> & st) {
size_t num_simplices = 0;
while (read_simplex(is, simplex, fil)) { // read all simplices in the file as a list of vertices
++num_simplices;
- int dim = (int) simplex.size() - 1; // Warning : simplex_size needs to be casted in int - Can be 0
+ int dim = static_cast<int>(simplex.size() - 1); // Warning : simplex_size needs to be casted in int - Can be 0
if (max_dim < dim) {
max_dim = dim;
}
@@ -852,4 +845,4 @@ std::istream& operator>>(std::istream & is, Simplex_tree<T1, T2, T3> & st) {
/** @} */ // end defgroup simplex_tree
} // namespace Gudhi
-#endif // GUDHI_SIMPLEX_TREE_H
+#endif // SRC_SIMPLEX_TREE_INCLUDE_GUDHI_SIMPLEX_TREE_H_
diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_iterators.h b/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_iterators.h
index 54d4d296..06462c88 100644
--- a/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_iterators.h
+++ b/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_iterators.h
@@ -20,12 +20,13 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef SIMPLEX_TREE_ITERATORS_H
-#define SIMPLEX_TREE_ITERATORS_H
+#ifndef SRC_SIMPLEX_TREE_INCLUDE_GUDHI_SIMPLEX_TREE_SIMPLEX_TREE_ITERATORS_H_
+#define SRC_SIMPLEX_TREE_INCLUDE_GUDHI_SIMPLEX_TREE_SIMPLEX_TREE_ITERATORS_H_
-#include <vector>
#include <boost/iterator/iterator_facade.hpp>
+#include <vector>
+
namespace Gudhi {
/* \addtogroup simplex_tree
@@ -47,7 +48,7 @@ class Simplex_tree_simplex_vertex_iterator : public boost::iterator_facade<
typedef typename SimplexTree::Siblings Siblings;
typedef typename SimplexTree::Vertex_handle Vertex_handle;
- Simplex_tree_simplex_vertex_iterator(SimplexTree * st)
+ explicit Simplex_tree_simplex_vertex_iterator(SimplexTree * st)
: // any end() iterator
sib_(NULL),
v_(st->null_vertex()) {
@@ -93,7 +94,7 @@ class Simplex_tree_boundary_simplex_iterator : public boost::iterator_facade<
typedef typename SimplexTree::Siblings Siblings;
// any end() iterator
- Simplex_tree_boundary_simplex_iterator(SimplexTree * st)
+ explicit Simplex_tree_boundary_simplex_iterator(SimplexTree * st)
: last_(st->null_vertex()),
sib_(NULL) {
}
@@ -166,7 +167,7 @@ class Simplex_tree_complex_simplex_iterator : public boost::iterator_facade<
: st_(NULL) {
}
- Simplex_tree_complex_simplex_iterator(SimplexTree * st)
+ explicit Simplex_tree_complex_simplex_iterator(SimplexTree * st)
: st_(st) {
if (st == NULL || st->root() == NULL || st->root()->members().empty()) {
st_ = NULL;
@@ -302,4 +303,4 @@ class Simplex_tree_skeleton_simplex_iterator : public boost::iterator_facade<
/* @} */ // end addtogroup simplex_tree
} // namespace Gudhi
-#endif // SIMPLEX_TREE_ITERATORS_H
+#endif // SRC_SIMPLEX_TREE_INCLUDE_GUDHI_SIMPLEX_TREE_SIMPLEX_TREE_ITERATORS_H_
diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_node_explicit_storage.h b/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_node_explicit_storage.h
index 27120f00..1f1a34cc 100644
--- a/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_node_explicit_storage.h
+++ b/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_node_explicit_storage.h
@@ -20,11 +20,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef GUDHI_SIMPLEX_TREE_NODE_EXPLICIT_STORAGE_H
-#define GUDHI_SIMPLEX_TREE_NODE_EXPLICIT_STORAGE_H
+#ifndef SRC_SIMPLEX_TREE_INCLUDE_GUDHI_SIMPLEX_TREE_SIMPLEX_TREE_NODE_EXPLICIT_STORAGE_H_
+#define SRC_SIMPLEX_TREE_INCLUDE_GUDHI_SIMPLEX_TREE_SIMPLEX_TREE_NODE_EXPLICIT_STORAGE_H_
#include <vector>
-#include <iostream>
namespace Gudhi {
@@ -42,14 +41,10 @@ namespace Gudhi {
template<class SimplexTree>
class Simplex_tree_node_explicit_storage {
public:
-// friend SimplexTree;
-
typedef typename SimplexTree::Siblings Siblings;
typedef typename SimplexTree::Filtration_value Filtration_value;
typedef typename SimplexTree::Simplex_key Simplex_key;
- //private:
- //friend class Simplex_tree;
// Default constructor.
Simplex_tree_node_explicit_storage()
: children_(NULL),
@@ -69,13 +64,6 @@ class Simplex_tree_node_explicit_storage {
}
/*
- * Return true if the node has children,
- * false otherwise.
- */
- //bool has_children(Vertex label)
- //{ //if(children_ == NULL) return false; //for root simplices
- // return (children_->parent() == label);}
- /*
* Assign a children to the node
*/
void assign_children(Siblings * children) {
@@ -92,7 +80,7 @@ class Simplex_tree_node_explicit_storage {
return filtration_;
}
- /* Careful -> has_children() must be true*/
+ /* Careful -> children_ can be NULL*/
Siblings * children() {
return children_;
}
@@ -106,11 +94,10 @@ class Simplex_tree_node_explicit_storage {
// Data attached to simplex, explicit storage
Simplex_key simplex_key_;
- Filtration_value filtration_; //value in the filtration
-
+ Filtration_value filtration_; // value in the filtration
};
/* @} */ // end addtogroup simplex_tree
-}// namespace Gudhi
+} // namespace Gudhi
-#endif // GUDHI_SIMPLEX_TREE_NODE_EXPLICIT_STORAGE_H
+#endif // SRC_SIMPLEX_TREE_INCLUDE_GUDHI_SIMPLEX_TREE_SIMPLEX_TREE_NODE_EXPLICIT_STORAGE_H_
diff --git a/src/Simplex_tree/include/gudhi/Simplex_tree/indexing_tag.h b/src/Simplex_tree/include/gudhi/Simplex_tree/indexing_tag.h
index 680458a5..69ffa44b 100644
--- a/src/Simplex_tree/include/gudhi/Simplex_tree/indexing_tag.h
+++ b/src/Simplex_tree/include/gudhi/Simplex_tree/indexing_tag.h
@@ -20,6 +20,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#ifndef SRC_SIMPLEX_TREE_INCLUDE_GUDHI_SIMPLEX_TREE_INDEXING_TAG_H_
+#define SRC_SIMPLEX_TREE_INCLUDE_GUDHI_SIMPLEX_TREE_INDEXING_TAG_H_
+
namespace Gudhi {
/** \brief Tag for a linear ordering of simplices.
@@ -31,4 +34,6 @@ struct linear_indexing_tag {
/* \brief Tag for a zigzag ordering of simplices. */
// struct zigzag_indexing_tag {};
-}// namespace Gudhi
+} // namespace Gudhi
+
+#endif // SRC_SIMPLEX_TREE_INCLUDE_GUDHI_SIMPLEX_TREE_INDEXING_TAG_H_
diff --git a/src/Simplex_tree/test/CMakeLists.txt b/src/Simplex_tree/test/CMakeLists.txt
index eeb066d4..d7f968af 100644
--- a/src/Simplex_tree/test/CMakeLists.txt
+++ b/src/Simplex_tree/test/CMakeLists.txt
@@ -12,22 +12,22 @@ if(NOT MSVC)
endif()
include_directories(${Boost_INCLUDE_DIRS})
-add_executable ( TestSimplexTree UnitTestSimplexTree.cpp )
-target_link_libraries(TestSimplexTree ${Boost_LIBRARIES})
+add_executable ( simplex_tree_unit_test simplex_tree_unit_test.cpp )
+target_link_libraries(simplex_tree_unit_test ${Boost_LIBRARIES})
# Unitary tests
-add_test(TestSimplexTree ${CMAKE_CURRENT_BINARY_DIR}/TestSimplexTree)
+add_test(simplex_tree_unit_test ${CMAKE_CURRENT_BINARY_DIR}/simplex_tree_unit_test)
if (LCOV_PATH)
# Lcov code coverage of unitary test
- add_test(TestSimplexTreeCov ${CMAKE_SOURCE_DIR}/scripts/check_code_coverage.sh ${CMAKE_SOURCE_DIR}/src/Simplex_tree)
+ add_test(simplex_tree_unit_test_coverage.info ${CMAKE_SOURCE_DIR}/scripts/check_code_coverage.sh ${CMAKE_SOURCE_DIR}/src/Simplex_tree)
endif()
if (PYTHON_PATH)
# Cpplint tests on coding style
- add_test(CpplintSimplexTree ${CMAKE_SOURCE_DIR}/scripts/check_google_style.sh ${CMAKE_SOURCE_DIR}/src/Simplex_tree/include/gudhi/Simplex_tree.h)
- add_test(CpplintSimplexTreeIndexingTag ${CMAKE_SOURCE_DIR}/scripts/check_google_style.sh ${CMAKE_SOURCE_DIR}/src/Simplex_tree/include/gudhi/Simplex_tree/indexing_tag.h)
- add_test(CpplintSimplexTreeIterator ${CMAKE_SOURCE_DIR}/scripts/check_google_style.sh ${CMAKE_SOURCE_DIR}/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_iterators.h)
- add_test(CpplintSimplexTreeNode ${CMAKE_SOURCE_DIR}/scripts/check_google_style.sh ${CMAKE_SOURCE_DIR}/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_node_explicit_storage.h)
- add_test(CpplintSimplexTreeSiblings ${CMAKE_SOURCE_DIR}/scripts/check_google_style.sh ${CMAKE_SOURCE_DIR}/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_siblings.h)
+ add_test(Simplex_tree.h.cpplint ${CMAKE_SOURCE_DIR}/scripts/check_google_style.sh ${CMAKE_SOURCE_DIR}/src/Simplex_tree/include/gudhi/Simplex_tree.h)
+ add_test(indexing_tag.h.cpplint ${CMAKE_SOURCE_DIR}/scripts/check_google_style.sh ${CMAKE_SOURCE_DIR}/src/Simplex_tree/include/gudhi/Simplex_tree/indexing_tag.h)
+ add_test(Simplex_tree_iterators.h.cpplint ${CMAKE_SOURCE_DIR}/scripts/check_google_style.sh ${CMAKE_SOURCE_DIR}/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_iterators.h)
+ add_test(Simplex_tree_node_explicit_storage.h.cpplint ${CMAKE_SOURCE_DIR}/scripts/check_google_style.sh ${CMAKE_SOURCE_DIR}/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_node_explicit_storage.h)
+ add_test(Simplex_tree_siblings.h.cpplint ${CMAKE_SOURCE_DIR}/scripts/check_google_style.sh ${CMAKE_SOURCE_DIR}/src/Simplex_tree/include/gudhi/Simplex_tree/Simplex_tree_siblings.h)
endif() \ No newline at end of file
diff --git a/src/Simplex_tree/test/README b/src/Simplex_tree/test/README
index 3d6981ff..620bcd5f 100644
--- a/src/Simplex_tree/test/README
+++ b/src/Simplex_tree/test/README
@@ -7,6 +7,6 @@ make
To launch with details:
***********************
-./TestSimplexTree --report_level=detailed --log_level=all
+./simplex_tree_unit_test --report_level=detailed --log_level=all
==> echo $? returns 0 in case of success (non-zero otherwise)
diff --git a/src/Simplex_tree/test/UnitTestSimplexTree.cpp b/src/Simplex_tree/test/simplex_tree_unit_test.cpp
index a3671f56..a3671f56 100644
--- a/src/Simplex_tree/test/UnitTestSimplexTree.cpp
+++ b/src/Simplex_tree/test/simplex_tree_unit_test.cpp