summaryrefslogtreecommitdiff
path: root/src/python/gudhi/weighted_rips_complex.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/python/gudhi/weighted_rips_complex.py')
-rw-r--r--src/python/gudhi/weighted_rips_complex.py18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/python/gudhi/weighted_rips_complex.py b/src/python/gudhi/weighted_rips_complex.py
index 83fa82c5..7401c428 100644
--- a/src/python/gudhi/weighted_rips_complex.py
+++ b/src/python/gudhi/weighted_rips_complex.py
@@ -11,23 +11,26 @@ from gudhi import SimplexTree
class WeightedRipsComplex:
"""
- Class to generate a weighted Rips complex from a distance matrix and weights on vertices.
+ Class to generate a weighted Rips complex from a distance matrix and weights on vertices,
+ in the way described in the paper 'DTM-based filtrations' https://arxiv.org/abs/1811.04757.
+ Remark that the filtration value of a vertex is twice of its weight for the consistency with
+ RipsComplex, which is different from the definition in the paper.
"""
def __init__(self,
distance_matrix,
- weights="diagonal",
+ weights=None,
max_filtration=float('inf')):
"""
Args:
- distance_matrix (list of list of float): distance matrix (full square or lower triangular).
- weights (list of float): (one half of) weight for each vertex.
+ distance_matrix (Sequence[Sequence[float]]): distance matrix (full square or lower triangular).
+ weights (Sequence[float]): (one half of) weight for each vertex.
max_filtration (float): specifies the maximal filtration value to be considered.
"""
self.distance_matrix = distance_matrix
- if weights == "diagonal":
- self.weights = [distance_matrix[i][i] for i in range(len(distance_matrix))]
- else:
+ if weights is not None:
self.weights = weights
+ else:
+ self.weights = [0] * len(distance_matrix)
self.max_filtration = max_filtration
def create_simplex_tree(self, max_dimension):
@@ -47,6 +50,7 @@ class WeightedRipsComplex:
for i in range(num_pts):
for j in range(i):
value = max(2*F[i], 2*F[j], dist[i][j] + F[i] + F[j])
+ # max is needed when F is not 1-Lipschitz
if value <= self.max_filtration:
st.insert([i,j], filtration=value)