From ed21e00112cbed91a2db6b8225ce6fef24648cef Mon Sep 17 00:00:00 2001 From: Gard Spreemann Date: Fri, 6 May 2016 11:35:08 +0200 Subject: Version 0.0.5. --- phstuff/simplicial.py | 22 ++++++++++++++++------ 1 file 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 -- cgit v1.2.3