diff options
author | Hind <hind.montassif@gmail.com> | 2021-04-22 17:08:17 +0200 |
---|---|---|
committer | Hind <hind.montassif@gmail.com> | 2021-04-22 17:08:17 +0200 |
commit | 45917ecf17acacfede909994d7b3a78fc18355da (patch) | |
tree | 66f800f9ca2ad023f5c9ccd418aac6b8ab5d6dc5 /src/python/example | |
parent | 73fa5b763a53179444304ccbe0583b616403bb0a (diff) |
Add random points generator on sphere in python, with an example
Diffstat (limited to 'src/python/example')
-rw-r--r-- | src/python/example/alpha_complex_from_generated_points_example.py | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/python/example/alpha_complex_from_generated_points_example.py b/src/python/example/alpha_complex_from_generated_points_example.py new file mode 100644 index 00000000..7a07ed42 --- /dev/null +++ b/src/python/example/alpha_complex_from_generated_points_example.py @@ -0,0 +1,52 @@ +#!/usr/bin/env python + +from gudhi import random_point_generators +from gudhi import AlphaComplex, SimplexTree +from gudhi import plot_persistence_barcode, plot_persistence_diagram + +import matplotlib.pyplot as plt + + +""" 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): Hind Montassif + + Copyright (C) 2021 Inria + + Modification(s): + - YYYY/MM Author: Description of the modification +""" + +__author__ = "Hind Montassif" +__copyright__ = "Copyright (C) 2021 Inria" +__license__ = "MIT" + +print("#####################################################################") +print("AlphaComplex creation from generated points") + + +# Generate a circle: 50 points; dim 2; radius 1 +points = random_point_generators.generate_points_on_sphere_d(50, 2, 1) + +# Plot the generated points (to uncomment if wished) +#plt.scatter(points[:,0], points[:,1]) +#plt.show() + +# Create an alpha complex +alpha_complex = AlphaComplex(points=points) +simplex_tree = alpha_complex.create_simplex_tree() + +result_str = 'Alpha complex is of dimension ' + repr(simplex_tree.dimension()) + ' - ' + \ + repr(simplex_tree.num_simplices()) + ' simplices - ' + \ + repr(simplex_tree.num_vertices()) + ' vertices.' +print(result_str) + + +# Compute the persistence +diag = simplex_tree.persistence() + +# Plot the barcode and diagram (to uncomment if wished) +#plot_persistence_barcode(diag) +#plt.show() +#plot_persistence_diagram(diag) +#plt.show() |