summaryrefslogtreecommitdiff
path: root/src/python/gudhi/weighted_rips_complex.py
diff options
context:
space:
mode:
authoryuichi-ike <yuichi.ike.1990@gmail.com>2020-04-06 16:25:27 +0900
committeryuichi-ike <yuichi.ike.1990@gmail.com>2020-04-06 16:25:27 +0900
commit5ce1ee8976ced78de839ef629522c95324b2fabd (patch)
tree9badc03378c8ed495ac1a256b3aa3836b9f75951 /src/python/gudhi/weighted_rips_complex.py
parent0a404547afec2e43dd5edf9410ff079d156d691a (diff)
weighted rips added
Diffstat (limited to 'src/python/gudhi/weighted_rips_complex.py')
-rw-r--r--src/python/gudhi/weighted_rips_complex.py41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/python/gudhi/weighted_rips_complex.py b/src/python/gudhi/weighted_rips_complex.py
new file mode 100644
index 00000000..34a627cb
--- /dev/null
+++ b/src/python/gudhi/weighted_rips_complex.py
@@ -0,0 +1,41 @@
+# 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): Raphaƫl Tinarrage and Yuichi Ike
+#
+# Copyright (C) 2020 Inria, Copyright (C) 2020 FUjitsu Laboratories Ltd.
+#
+# Modification(s):
+# - YYYY/MM Author: Description of the modification
+
+from gudhi import SimplexTree
+
+class WeightedRipsComplex:
+ """
+ class to generate a weighted Rips complex
+ from a distance matrix and filtration value
+ """
+ def __init__(self,
+ distance_matrix=None,
+ filtration_values=None,
+ max_filtration=float('inf'), sparse=None):
+ self.distance_matrix = distance_matrix
+ self.filtration_values = filtration_values
+ self.max_filtration = max_filtration
+
+ def create_simplex_tree(self, max_dimension):
+ dist = self.distance_matrix
+ F = self.filtration_values
+ num_pts = len(dist)
+
+ st = SimplexTree()
+
+ for i in range(num_pts):
+ if F[i] < self.max_filtration:
+ st.insert([i], F[i])
+ for i in range(num_pts):
+ for j in range(num_pts):
+ value = (dist[i][j] + F[i] + F[j]) / 2
+ if value < self.max_filtration:
+ st.insert([i,j], filtration=value)
+ return st
+