geomfum.metric package#

Submodules#

geomfum.metric.mesh module#

Module containing metrics to calcualte distances on a mesh.

class geomfum.metric.mesh.FinitePointSetMetric(shape)[source]#

Bases: Metric, ABC

Metric on a finite set of indexed points.

abstract dist_from_source(source_point)[source]#

Distance from source point.

Parameters:

source_point (array-like, shape=[…]) – Index of source point.

Returns:

  • dist (array-like, shape=[…] or list-like[array-like]) – Distance.

  • target_point (array-like, shape=[n_targets] or list-like[array-like]) – Target index.

abstract dist_matrix()[source]#

Distance between all the points of a shape.

Returns:

dist_matrix (array-like, shape=[n_vertices, n_vertices]) – Distance matrix.

class geomfum.metric.mesh.GraphShortestPathMetric(shape, cutoff=None)[source]#

Bases: _NxDijkstraMixins, FinitePointSetMetric

Shortest path on edge graph of mesh with single source Dijkstra.

Parameters:
  • shape (Shape) – Shape.

  • cutoff (float) – Length (sum of edge weights) at which the search is stopped.

class geomfum.metric.mesh.HeatDistanceMetric(*args, **kwargs)[source]#

Bases: WhichRegistryMixins

Heat distance metric between vertices of a mesh.

References

[CWW2013]

Crane, K., Weischedel, C., Wardetzky, M., 2017. The heat method for distance computation. Commun. ACM 60, 90–99. https://doi.org/10.1145/3131280

class geomfum.metric.mesh.KClosestGraphShortestPathMetric(shape, k_closest=5)[source]#

Bases: _NxDijkstraMixins, FinitePointSetMetric

Shortest path on edge graph of mesh with Dijkstra.

Parameters:
  • shape (Shape) – Shape.

  • k_closest (int) – Number of nodes to find distances to (including the source itself).

class geomfum.metric.mesh.Metric(shape)[source]#

Bases: ABC

Metric.

Parameters:

shape (Shape) – Considered as a manifold.

abstract dist(point_a, point_b)[source]#

Distance between points.

Parameters:
  • point_a (array-like, shape=[…]) – Index Point.

  • point_b (array-like, shape=[…]) – Index Point.

Returns:

dist (array-like, shape=[…,]) – Distance.

class geomfum.metric.mesh.ScipyGraphShortestPathMetric(shape, cutoff=None)[source]#

Bases: _ScipyShortestPathMixins, FinitePointSetMetric

Shortest path on edge graph of mesh with Scipy shortest path solver.

Parameters:
  • shape (Shape) – Shape.

  • cutoff (float) – Length (sum of edge weights) at which the search is stopped.

class geomfum.metric.mesh.VertexEuclideanMetric(shape)[source]#

Bases: FinitePointSetMetric

Euclidean metric between vertices of a mesh.

dist(point_a, point_b)[source]#

Distance between mesh vertices.

Parameters:
  • point_a (array-like, shape=[…]) – Index of source point.

  • point_b (array-like, shape=[…]) – Index of target point.

Returns:

dist (array-like, shape=[…]) – Distance.

dist_from_source(source_point)[source]#

Distance from source point.

Parameters:

source_point (array-like, shape=[…]) – Index of source point.

Returns:

  • dist (array-like, shape=[…] or array-like[array-like]) – Distance.

  • target_point (array-like, shape=[n_targets] or array-like[array-like]) – Target index.

dist_matrix()[source]#

Distance between mesh vertices.

Returns:

dist_matrix (array-like, shape=[n_vertices, n_vertices]) – Distance matrix.

geomfum.metric.mesh.to_nx_edge_graph(shape)[source]#

Convert a shape to a networkx graph.

Parameters:

shape (Shape) – Shape.

Returns:

graph (networkx.Graph) – Graph.

Module contents#