Gudhi python library did not show the output for dimension 1

The following code is for “Homology Groups”. I used library for implementation purpose.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>import gudhi
# Create a simplicial complex
simplex_tree = gudhi.SimplexTree()
simplex_tree.insert([1, 2, 3])
simplex_tree.insert([2, 3, 4])
simplex_tree.insert([3, 4, 5])
# Compute homology
homology = simplex_tree.persistence()
print("Homology groups:")
for interval in homology:
dim, (birth, death) = interval
print(f"Dimension {dim}: birth = {birth}, death = {death}")
</code>
<code>import gudhi # Create a simplicial complex simplex_tree = gudhi.SimplexTree() simplex_tree.insert([1, 2, 3]) simplex_tree.insert([2, 3, 4]) simplex_tree.insert([3, 4, 5]) # Compute homology homology = simplex_tree.persistence() print("Homology groups:") for interval in homology: dim, (birth, death) = interval print(f"Dimension {dim}: birth = {birth}, death = {death}") </code>
import gudhi

# Create a simplicial complex
simplex_tree = gudhi.SimplexTree()
simplex_tree.insert([1, 2, 3])
simplex_tree.insert([2, 3, 4])
simplex_tree.insert([3, 4, 5])

# Compute homology
homology = simplex_tree.persistence()

print("Homology groups:")
for interval in homology:
    dim, (birth, death) = interval
    print(f"Dimension {dim}: birth = {birth}, death = {death}")

The output I get

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>Homology groups:
Dimension 0: birth = 0.0, death = inf
</code>
<code>Homology groups: Dimension 0: birth = 0.0, death = inf </code>
Homology groups:
Dimension 0: birth = 0.0, death = inf

Why I did not get the output for Dimension 1?

The reason is:

As defined in the code, there are no non-trivial 1-dimensional loops.
if there is no 1-d features that presist by homology

e.g.
a loop like 1>2>3>1 exists but it is filled by triangle so it does not contribute to the first homology group H1

I hope you will get the point, otherwise you can ask for further clarification and I will further explain
try these lines in your code as well to loop and print the H1 I hope it will work for you 🙂

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>print("Homology groups:")
for interval in
simplex_tree.persistence_intervals_in_dimension(0):
print(f"Dimension 0: birth = {interval[0]}, death =
{interval[1]}")
for interval in
simplex_tree.persistence_intervals_in_dimension(1):
print(f"Dimension 1: birth = {interval[0]}, death =
{interval[1]}")
</code>
<code>print("Homology groups:") for interval in simplex_tree.persistence_intervals_in_dimension(0): print(f"Dimension 0: birth = {interval[0]}, death = {interval[1]}") for interval in simplex_tree.persistence_intervals_in_dimension(1): print(f"Dimension 1: birth = {interval[0]}, death = {interval[1]}") </code>
print("Homology groups:")
for interval in 
 simplex_tree.persistence_intervals_in_dimension(0):
 print(f"Dimension 0: birth = {interval[0]}, death = 
 {interval[1]}")

for interval in 
 simplex_tree.persistence_intervals_in_dimension(1):
 print(f"Dimension 1: birth = {interval[0]}, death = 
 {interval[1]}")

2

Can you try this with 1 D cycle
import gudhi

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code># Create a simplicial complex with a 1D cycle
simplex_tree = gudhi.SimplexTree()
simplex_tree.insert([1, 2])
simplex_tree.insert([2, 3])
simplex_tree.insert([3, 4])
simplex_tree.insert([4, 1])
# Forms a 1D loop
# Compute homology
homology = simplex_tree.persistence()
print("Homology groups:")
for interval in homology:
dim, (birth, death) = interval
print(f"Dimension {dim}: birth = {birth}, death = {death}")
</code>
<code># Create a simplicial complex with a 1D cycle simplex_tree = gudhi.SimplexTree() simplex_tree.insert([1, 2]) simplex_tree.insert([2, 3]) simplex_tree.insert([3, 4]) simplex_tree.insert([4, 1]) # Forms a 1D loop # Compute homology homology = simplex_tree.persistence() print("Homology groups:") for interval in homology: dim, (birth, death) = interval print(f"Dimension {dim}: birth = {birth}, death = {death}") </code>
# Create a simplicial complex with a 1D cycle
simplex_tree = gudhi.SimplexTree()
simplex_tree.insert([1, 2])
simplex_tree.insert([2, 3])
simplex_tree.insert([3, 4])
simplex_tree.insert([4, 1])  
# Forms a 1D loop

# Compute homology
homology = simplex_tree.persistence()

print("Homology groups:")
for interval in homology:
dim, (birth, death) = interval
print(f"Dimension {dim}: birth = {birth}, death = {death}")

Homology groups:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>Dimension 0: birth = 0.0, death = inf
Dimension 1: birth = 0.0, death = inf
</code>
<code>Dimension 0: birth = 0.0, death = inf Dimension 1: birth = 0.0, death = inf </code>
Dimension 0: birth = 0.0, death = inf
Dimension 1: birth = 0.0, death = inf

Now its working for myself as I just change in your code and limited the dim to 1d Create a simplicial complex with a 1D cycle

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật