import numpy as np import gudhi as gd import random as rd import matplotlib.pyplot as plt st = gd.SimplexTree() #Create a simplex tree #Simplices can be inserted one by one #Vertices are indexed by integers if st.insert([0,1]): print("first simplex inserted!") st.insert([1,2]) st.insert([2,3]) st.insert([3,0]) st.insert([0,2]) st.insert([3,1]) L = st.get_filtration() #Get a list with all the simplices #Notice that inserting an edge automatically insert its vertices (if they were #not already in the complex) for splx in L: print(splx) #insert the 2-skeleton giving some filtration values to the faces st.insert([0,1,2],filtration=0.1) st.insert([1,2,3],filtration=0.2) st.insert([0,2,3],filtration=0.3) st.insert([0,1,3],filtration=0.4) #if you add a new simplex with a given filtration values, all its faces that #were not in the complex before are added with the same filtration value st.insert([2,3,4],filtration=0.7) L = st.get_filtration() for splx in L: print(splx) ############################################################################# #Many operations that can be done on simplicial complexes (see also the Gudhi #documentation and examples): ############################################################################# st.set_dimension(2) #Warning! For the moment, the dimension of the simplicial #complex has to be set manually print("dimension=", st.dimension()) 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[2]=", st.get_skeleton(2)) print("skeleton[1]=", st.get_skeleton(1)) print("skeleton[0]=", st.get_skeleton(0))