summaryrefslogtreecommitdiff
path: root/src/cython/main.py
blob: a36b4fa80a9204b60d073b6d5ee11467fcf41af7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env python

import gudhi

st = gudhi.SimplexTree()

print("#######################################################################")
print("SimplexTree creation from insertion")
if st.insert([0,1]):
  print("Inserted !!")
else:
  print("Not inserted...")

if st.find([0,1]):
  print("Found !!")
else:
  print("Not found...")

if st.insert_with_subfaces([0,1,2], filtration=4.0):
  print("Inserted !!")
else:
  print("Not inserted...")

# FIXME: Remove this line
st.set_dimension(3)
print("dimension=", st.dimension())

st.set_filtration(4.0)
st.initialize_filtration()
print("filtration=", st.get_filtration())
print("filtration[1,2]=", st.filtration([1,2]))
print("filtration[4,2]=", st.filtration([4,2]))

print("num_simplices=", st.num_simplices())
print("num_vertices=", st.num_vertices())

print("skeleton_tree[2]=", st.get_skeleton_tree(2))
print("skeleton_tree[1]=", st.get_skeleton_tree(1))
print("skeleton_tree[0]=", st.get_skeleton_tree(0))

print("#######################################################################")
print("SimplexTree creation from graph expansion")
st_from_graph_expansion = gudhi.SimplexTree(points=[[0,0],[1,0],[0,1],[1,1]],max_dimension=1,max_edge_length=42)

print("filtered_tree=", st_from_graph_expansion.get_filtered_tree())
print("star([0])=", st_from_graph_expansion.get_star_tree([0]))
print("coface([0],1)=", st_from_graph_expansion.get_coface_tree([0], 1))


print("#######################################################################")
print("MiniSimplexTree creation from insertion")
triangle012 = [0, 1, 2]
edge03 = [0, 3]
mini_st = gudhi.MiniSimplexTree()
mini_st.insert_simplex_and_subfaces(triangle012)
mini_st.insert_simplex_and_subfaces(edge03)
# FIXME: Remove this line
mini_st.set_dimension(2);

edge02 = [0, 2]
if st.st.find(edge02):
  # Only coface is 012
  print("coface(edge02,1)=", st_from_graph_expansion.get_coface_tree(edge02, 1))