summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGard Spreemann <gard.spreemann@epfl.ch>2016-05-06 11:35:08 +0200
committerGard Spreemann <gard.spreemann@epfl.ch>2016-05-06 11:35:08 +0200
commited21e00112cbed91a2db6b8225ce6fef24648cef (patch)
treeba37d135100563be82493866b87d8db605e04a0f
parent3f8ae7cd1e031c3c8b801d891521f8954b6adac7 (diff)
Version 0.0.5.v0.0.5
-rw-r--r--phstuff/simplicial.py22
1 files changed, 16 insertions, 6 deletions
diff --git a/phstuff/simplicial.py b/phstuff/simplicial.py
index 6da6163..8ef96f2 100644
--- a/phstuff/simplicial.py
+++ b/phstuff/simplicial.py
@@ -130,10 +130,13 @@ class Complex:
parent = self.find(pre)
node = Node(last, None, weight, parent)
- self.__count += 1
- self.__top_dim = max(self.__top_dim, p)
- return parent.children.setdefault(last, node)
+ ret = parent.children.setdefault(last, node)
+ if ret == node:
+ self.__count += 1
+ self.__top_dim = max(self.__top_dim, p)
+
+ return ret
def __contains__(self, simplex):
return self.find(simplex) is not None
@@ -160,14 +163,21 @@ def naive_vr_tmp(graph, top_dim):
cplx.add([v], 0.0)
elif p == 1:
for simplex in to_add:
- cplx.add(simplex, graph[simplex[0], simplex[1]])
+ if not graph.mask[simplex[0], simplex[1]]:
+ cplx.add(simplex, graph[simplex[0], simplex[1]])
else:
for simplex in to_add:
codim1faces = itertools.combinations(simplex, p)
weight = 0.0
+ all_faces_in = True
for face in codim1faces:
- weight = max(cplx.find(face).w, weight)
- cplx.add(simplex, weight)
+ if face in cplx:
+ weight = max(cplx.find(face).w, weight)
+ else:
+ all_faces_in = False
+ break
+ if all_faces_in:
+ cplx.add(simplex, weight)
return cplx