How to use the gudhi.read_off 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 / euclidean_witness_complex_diagram_persistence_from_off_file_example.py View on Github external
parser.add_argument(
    "--no-diagram",
    default=False,
    action="store_true",
    help="Flag for not to display the diagrams",
)

args = parser.parse_args()

with open(args.file, "r") as f:
    first_line = f.readline()
    if (first_line == "OFF\n") or (first_line == "nOFF\n"):
        print("#####################################################################")
        print("EuclideanWitnessComplex creation from points read in a OFF file")

        witnesses = gudhi.read_off(off_file=args.file)
        landmarks = gudhi.pick_n_random_points(
            points=witnesses, nb_points=args.number_of_landmarks
        )

        message = (
            "EuclideanWitnessComplex with max_edge_length="
            + repr(args.max_alpha_square)
            + " - Number of landmarks="
            + repr(args.number_of_landmarks)
        )
        print(message)

        witness_complex = gudhi.EuclideanWitnessComplex(
            witnesses=witnesses, landmarks=landmarks
        )
        simplex_tree = witness_complex.create_simplex_tree(
github GUDHI / gudhi-devel / src / python / example / plot_rips_complex.py View on Github external
#!/usr/bin/env python

import numpy as np
import gudhi
points = np.array(gudhi.read_off('../../data/points/Kl.off'))
rc = gudhi.RipsComplex(points=points, max_edge_length=.2)
st = rc.create_simplex_tree(max_dimension=2)
# We are only going to plot the triangles
triangles = np.array([s[0] for s in st.get_skeleton(2) if len(s[0])==3])

# First possibility: plotly
import plotly.graph_objects as go
fig = go.Figure(data=[
    go.Mesh3d(
        # Use the first 3 coordinates, but we could as easily pick others
        x=points[:,0],
        y=points[:,1],
        z=points[:,2],
        i = triangles[:,0],
        j = triangles[:,1],
        k = triangles[:,2],
github GUDHI / gudhi-devel / src / python / example / rips_complex_diagram_persistence_from_off_file_example.py View on Github external
action="store_true",
    help="Flag for not to display the diagrams",
)

args = parser.parse_args()

with open(args.file, "r") as f:
    first_line = f.readline()
    if (first_line == "OFF\n") or (first_line == "nOFF\n"):
        print("#####################################################################")
        print("RipsComplex creation from points read in a OFF file")

        message = "RipsComplex with max_edge_length=" + repr(args.max_edge_length)
        print(message)

        point_cloud = gudhi.read_off(off_file=args.file)
        rips_complex = gudhi.RipsComplex(
            points=point_cloud, max_edge_length=args.max_edge_length
        )
        simplex_tree = rips_complex.create_simplex_tree(
            max_dimension=args.max_dimension
        )

        message = "Number of simplices=" + repr(simplex_tree.num_simplices())
        print(message)

        diag = simplex_tree.persistence()

        print("betti_numbers()=")
        print(simplex_tree.betti_numbers())

        if args.no_diagram == False:
github GUDHI / gudhi-devel / src / python / example / euclidean_strong_witness_complex_diagram_persistence_from_off_file_example.py View on Github external
parser.add_argument(
    "--no-diagram",
    default=False,
    action="store_true",
    help="Flag for not to display the diagrams",
)

args = parser.parse_args()

with open(args.file, "r") as f:
    first_line = f.readline()
    if (first_line == "OFF\n") or (first_line == "nOFF\n"):
        print("#####################################################################")
        print("EuclideanStrongWitnessComplex creation from points read in a OFF file")

        witnesses = gudhi.read_off(off_file=args.file)
        landmarks = gudhi.pick_n_random_points(
            points=witnesses, nb_points=args.number_of_landmarks
        )

        message = (
            "EuclideanStrongWitnessComplex with max_edge_length="
            + repr(args.max_alpha_square)
            + " - Number of landmarks="
            + repr(args.number_of_landmarks)
        )
        print(message)

        witness_complex = gudhi.EuclideanStrongWitnessComplex(
            witnesses=witnesses, landmarks=landmarks
        )
        simplex_tree = witness_complex.create_simplex_tree(
github GUDHI / gudhi-devel / src / cython / doc / pyplots / diagram_persistence.py View on Github external
import gudhi

point_cloud = gudhi.read_off(off_file=gudhi.__root_source_dir__ + \
    '/data/points/tore3D_1307.off')
rips_complex = gudhi.RipsComplex(points=point_cloud, max_edge_length=0.2)
simplex_tree = rips_complex.create_simplex_tree(max_dimension=3)
diag = simplex_tree.persistence()
plt = gudhi.plot_persistence_diagram(diag, band_boot=0.13)
plt.show()
github GUDHI / gudhi-devel / src / cython / example / alpha_rips_persistence_bottleneck_distance.py View on Github external
parser = argparse.ArgumentParser(description='AlphaComplex and RipsComplex '
                                 'persistence creation from points read in '
                                 'a OFF file. Bottleneck distance computation'
                                 ' on each dimension',
                                 epilog='Example: '
                                 'example/alpha_rips_persistence_bottleneck_distance.py '
                                 '-f ../data/points/tore3D_1307.off -t 0.15 -d 3')
parser.add_argument("-f", "--file", type=str, required=True)
parser.add_argument("-t", "--threshold", type=float, default=0.5)
parser.add_argument("-d", "--max_dimension", type=int, default=1)

args = parser.parse_args()
with open(args.file, 'r') as f:
    first_line = f.readline()
    if (first_line == 'OFF\n') or (first_line == 'nOFF\n'):
        point_cloud = gudhi.read_off(off_file=args.file)
        print("#####################################################################")
        print("RipsComplex creation from points read in a OFF file")

        message = "RipsComplex with max_edge_length=" + repr(args.threshold)
        print(message)

        rips_complex = gudhi.RipsComplex(points=point_cloud,
                                         max_edge_length=args.threshold)

        rips_stree = rips_complex.create_simplex_tree(max_dimension=args.max_dimension)

        message = "Number of simplices=" + repr(rips_stree.num_simplices())
        print(message)

        rips_diag = rips_stree.persistence()