############################################################################# #Filtrations and persitence computation ############################################################################# #Currently, the function to assign a filtration value to a simplex that is # already in the filtration has not been included in the Python version of #Gudhi. It will be in the next release (but it is already existing in the C++ #library. A trick to overcome this issue is the following: st2 = gd.SimplexTree() #The new filtered complex L = st.get_filtration() for splx in L: #We assign to each simplex its dimension as filtration value st2.insert(splx[0],filtration=len(splx[0])-1.0) L = st2.get_filtration() for splx in L: print(splx) #To compute the persistence diagram of the filtered simplex st2.initialize_filtration() diag2=st2.persistence() print(diag2) #To plot a persistence diagram gd.plot_persistence_diagram(diag2) gd.plot_persistence_barcode(diag2) #To compute bottleneck distance between diagrams st3 = gd.SimplexTree() st3.insert([0,1],filtration=0.0) st3.insert([1,2],filtration=0.1) st3.insert([2,0],filtration=0.2) st3.insert([0,1,2],filtration=0.5) st3.set_dimension(2) st3.initialize_filtration() diag3 = st3.persistence() gd.plot_persistence_diagram(diag3) diag2_0 = st2.persistence_intervals_in_dimension(0) diag3_0 = st3.persistence_intervals_in_dimension(0) dB0 = gd.bottleneck_distance(diag2_0,diag3_0) diag2_1 = st2.persistence_intervals_in_dimension(1) diag3_1 = st3.persistence_intervals_in_dimension(1) dB1 = gd.bottleneck_distance(diag2_1,diag3_1)