diff options
-rw-r--r-- | README.md | 39 | ||||
-rw-r--r-- | phstuff/diphawrapper.py | 17 |
2 files changed, 52 insertions, 4 deletions
@@ -147,6 +147,45 @@ environment variables. bc.plot(ax, dipharunner.barcode[1], weights.min(), weights.max()) plt.show() +### PH of an arbitrary simplicial complex (EXPERIMENTAL) + +The code for arbitrary simplicial complexes, the `simplicial` module, +is dirty, fragile and inefficient. Its API and behavior may change at +any time. + + import phstuff.diphawrapper as dipha + import phstuff.barcode as bc + import matplotlib.pyplot as plt + import phstuff.simplicial as simpl + + cplx = simpl.Complex() + + cplx.add([0], 0) + cplx.add([1], 0) + cplx.add([2], 0) + cplx.add([3], 0) + cplx.add([4], 0) + cplx.add([0,1], 0) + cplx.add([0,2], 0) + cplx.add([2,4], 0) + cplx.add([3,4], 0) + cplx.add([1,3], 1) + cplx.add([0,3], 2) + cplx.add([2,3], 3) + cplx.add([0,2,3], 10) + cplx.add([0,1,3], 20) + + dipharunner = dipha.DiphaRunner(2) # Compute up to 2-simplices. + dipharunner.simplicial(cplx) + dipharunner.run() + + for interval in dipharunner.barcode[1]: + print(interval) + + fig = plt.figure() + ax = fig.add_subplot(1,1,1) + bc.plot(ax, dipharunner.barcode[1], 0.0, 20.0) + plt.show() ### PH of an alpha complex made with CGAL diff --git a/phstuff/diphawrapper.py b/phstuff/diphawrapper.py index b2c9444..4d1742e 100644 --- a/phstuff/diphawrapper.py +++ b/phstuff/diphawrapper.py @@ -187,6 +187,19 @@ def save_cubical(fname, array): f.write(struct.pack("<d", float(w))) def save_simplicial(fname, complex): + """*EXPERIMENTAL*. Save a filtered simplicial complex. + + Corresponds to DIPHA's "weighted boundary matrix". + + Parameters: + ----------- + + fname: Name of file to write. + + complex: Simplicial complex to save. + + """ + complex.order() assert(complex.is_ordered()) @@ -221,10 +234,6 @@ def save_simplicial(fname, complex): f.write(struct.pack("<q", bnode.i)) - - - - def load_barcode(fname, top_dim = None): """Load a barcode as written by DIPHA. |