How to use the gudhi.CubicalComplex function in gudhi

To help you get started, we’ve selected a few gudhi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github GUDHI / gudhi-devel / src / python / example / random_cubical_complex_persistence_example.py View on Github external
description="Random cubical complex.",
    epilog="Example: "
    "./random_cubical_complex_persistence_example.py"
    " 10 10 10 - Constructs a random cubical "
    "complex in a dimension [10, 10, 10] (aka. "
    "1000 random top dimensional cells).",
)
parser.add_argument("dimension", type=int, nargs="*", help="Cubical complex dimensions")

args = parser.parse_args()
dimension_multiplication = reduce(operator.mul, args.dimension, 1)

if dimension_multiplication > 1:
    print("#####################################################################")
    print("CubicalComplex creation")
    cubical_complex = gudhi.CubicalComplex(
        dimensions=args.dimension,
        top_dimensional_cells=numpy.random.rand(dimension_multiplication),
    )

    print("persistence(homology_coeff_field=2, min_persistence=0)=")
    print(cubical_complex.persistence(homology_coeff_field=2, min_persistence=0))

    print("betti_numbers()=")
    print(cubical_complex.betti_numbers())