d维圆环的实现

问题描述

我需要创建一个称为 d 维环面的拓扑对象,d >= 2。例如,对边相等的正方形是一个二维环面。对于维度 3,立方体的对角和对面都是等效的。我请求帮助能够表示 d 维环面,以便使用 GUDHI 包计算同源性。谢谢!

解决方法

取自“持久同源性练习”部分中的 this tutorial 的另一个解决方案:

import gudhi as gd
#Here is our triangulation:
#   0-----3-----4-----0
#   | \   | \   | \   | \   |
#   |   \ |   \ |    \|   \ | 
#   1-----8-----7-----1
#   | \   | \   | \   | \   |
#   |   \ |   \ |   \ |   \ |
#   2-----5-----6-----2
#   | \   | \   | \   | \   |
#   |   \ |   \ |   \ |   \ |
#   0-----3-----4-----0
st = gd.SimplexTree()
st.insert([0,1,8])
st.insert([0,3,8])
st.insert([3,7,4,7])
st.insert([1,7])
st.insert([0,4])
st.insert([1,2,5])
st.insert([1,5,8])
st.insert([5,6,8])
st.insert([6,8])
st.insert([2,3])
st.insert([2,5])
st.insert([3,5])
st.insert([4,6])
st.insert([0,6])
# Compute persistence,then Betti numbers
st.persistence(persistence_dim_max=True)
st.betti_numbers()
# Returns [1,1]