#NEWLINE# def delaunay_graph( shape , return_pointgraph = True ) : #NEWLINE# #INDENT# '\n    Returns a graph with the edges being generated by Delaunay triangulation.\n\n    Parameters\n    ----------\n    shape : :map:`PointCloud` or :map:`LandmarkGroup` or subclass\n        The shape instance that defines the landmarks configuration based on\n        which the graph will be created.\n    return_pointgraph : `bool`, optional\n        If ``True``, then a :map:`PointUndirectedGraph` instance will be\n        returned. If ``False``, then an :map:`UndirectedGraph` instance will be\n        returned.\n\n    Returns\n    -------\n    graph : :map:`UndirectedGraph` or :map:`PointUndirectedGraph`\n        The generated graph.\n    ' #NEWLINE# if isinstance ( shape , LandmarkGroup ) : #NEWLINE# #INDENT# trimesh = TriMesh ( shape . lms . points ) #NEWLINE# n_vertices = shape . n_landmarks #NEWLINE# points = shape . lms . points #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( shape , PointCloud ) : #NEWLINE# #INDENT# trimesh = TriMesh ( shape . points ) #NEWLINE# n_vertices = shape . n_points #NEWLINE# points = return_pointgraph . points #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise ValueError ( 'shape must be either a LandmarkGroup or a PointCloud instance.' ) #NEWLINE# #UNINDENT# #UNINDENT# edges = trimesh . edge_indices ( ) #NEWLINE# if return_pointgraph : #NEWLINE# #INDENT# return PointUndirectedGraph . init_from_edges ( points = points , edges = edges , skip_checks = True ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return UndirectedGraph . init_from_edges ( edges = edges , n_vertices = n_vertices , skip_checks = True )