summaryrefslogtreecommitdiff
path: root/src/cython/example/Simplex_tree_example.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/cython/example/Simplex_tree_example.py')
-rwxr-xr-xsrc/cython/example/Simplex_tree_example.py65
1 files changed, 65 insertions, 0 deletions
diff --git a/src/cython/example/Simplex_tree_example.py b/src/cython/example/Simplex_tree_example.py
new file mode 100755
index 00000000..e9459588
--- /dev/null
+++ b/src/cython/example/Simplex_tree_example.py
@@ -0,0 +1,65 @@
+#!/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([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 Rips")
+st_from_rips = gudhi.SimplexTree(points=[[0,0],[1,0],[0,1],[1,1]],max_dimension=1,max_edge_length=42)
+
+print("filtered_tree=", st_from_rips.get_filtered_tree())
+print("star([0])=", st_from_rips.get_star_tree([0]))
+print("coface([0],1)=", st_from_rips.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(triangle012)
+mini_st.insert(edge03)
+# FIXME: Remove this line
+mini_st.set_dimension(2);
+
+edge02 = [0, 2]
+if mini_st.find(edge02):
+ # Only coface is 012
+ print("coface(edge02,1)=", mini_st.get_coface_tree(edge02, 1))
+print("filtered_tree=", mini_st.get_filtered_tree())
+