-
Hi, I would like to obtain the free pairs of a complex. In Boissonat's paper, it is written (section 2.2.2) that getting free pairs is easy with the simplex tree. However, the only way I am currently able to get free pairs with Gudhi is by doing the following import gudhi as gd
def findFreePairs(st: gd.simplex_tree.SimplexTree):
freepairs = list()
st_gen = st.get_simplices()
for (simplex, filtr) in st_gen:
cofaces = st.get_cofaces(simplex, 1)
if len(cofaces) == 1:
freepairs.append((simplex, cofaces[0][0]))
return freepairs Is there a better way? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
What they say in the paper is that it is easy to check if a simplex is the smaller one of a pair, by checking that it has only one coface.
To find cofaces more efficiently, you essentially have to maintain your own datastructure. For instance num_cofaces=defaultdict(int)
for s,_ in st.get_simplices():
for t,_ in st.get_boundaries(s):
num_cofaces[tuple(t)]+=1
[x for x,y in num_cofaces.items() if y==1] gives you the smaller simplex in each pair. Note that the pairs are not disjoint. The "best" way depends on what you want to do with those pairs. |
Beta Was this translation helpful? Give feedback.
-
Many thanks for your answer. Is there a plan to include (downward and upward) Hasse diagram of a complex in Gudhi in a future release? Such diagrams will be of great help for removing free pairs or other simplices, and doing similar operations on a complex. |
Beta Was this translation helpful? Give feedback.
What they say in the paper is that it is easy to check if a simplex is the smaller one of a pair, by checking that it has only one coface.