nlgm.searchspace Module#

nlgm.searchspace.adj_product_spaces(s1: list, s2: list) bool[source]#

Check whether two manifold signatures are adjacent product spaces.

Parameters:
s1list

First signature.

s2list

Second signature.

Returns:
bool

True if signatures are adjacent, otherwise False.

Notes

Adjacency allows a maximum edit-distance approximation corresponding to one manifold insertion/deletion or one replacement.

nlgm.searchspace.compute_weight(manifold1: ProductManifold, manifold2: ProductManifold)[source]#

Compute inverse Gromov-Hausdorff weight between product manifolds.

Parameters:
manifold1ProductManifold

First manifold.

manifold2ProductManifold

Second manifold.

Returns:
float

Inverse distance weight. Returns 0.0 when manifold dimensions differ.

Notes

This implementation uses a fixed lookup table between manifold type pairs.

nlgm.searchspace.construct_graph_search_space(n_p: int = 7, curvature_choices: list = [-1, 0, 1], connectivity: bool = False)[source]#

Construct graph search space over product-manifold signatures.

Parameters:
n_pint, default=7

Maximum number of model spaces in each product manifold.

curvature_choiceslist, default=[-1, 0, 1]

Allowed curvature values.

connectivitybool, default=False

If True, return unweighted connectivity only.

Returns:
numpy.ndarray

Adjacency or weighted-distance matrix.

list[tuple]

Signature list aligned with returned matrix indices.

nlgm.searchspace.get_color(weight: float) str[source]#

Map an edge weight to the plotting color used in search-space visualizations.

Parameters:
weightfloat

Edge weight.

Returns:
str

Matplotlib-compatible color name.

nlgm.searchspace.manifold_to_curvature(manifold: str)[source]#

Map a 2D manifold code to its representative curvature.

Parameters:
manifoldstr

Manifold code. Supported values are "E2", "S2", and "H2".

Returns:
int

Curvature representative for the manifold code.

nlgm.searchspace.manifold_type(manifold: BasicManifold)[source]#

Identify manifold code from curvature, assuming dimension 2.

Parameters:
manifoldBasicManifold

Manifold instance.

Returns:
str

One of "E2", "S2", or "H2".

Raises:
ValueError

If manifold.dimension is not 2.