# HNSW

> **Class** in `langchain_azure_postgresql`

📖 [View in docs](https://reference.langchain.com/python/langchain-azure-postgresql/common/_shared/HNSW)

HNSW algorithm settings.

Provides build-time and (via :class:`HNSWSearchParams`) search-time
parameters for HNSW vector indexes.

:param m: The maximum number of connections per layer for HNSW index building.
:type m: PositiveInt | None
:param ef_construction: The size of the dynamic candidate list for constructing
                        the HNSW graph.
:type ef_construction: PositiveInt | None

Notes:
-----
If ``ef_construction`` is not at least twice the value of ``m``, a
``ValueError`` will be raised during validation.

## Signature

```python
HNSW()
```

## Extends

- `Algorithm[HNSWSearchParams]`

## Properties

- `m`
- `ef_construction`

## Methods

- [`sanity_check()`](https://reference.langchain.com/python/langchain-azure-postgresql/common/_shared/HNSW/sanity_check)
- [`build_settings()`](https://reference.langchain.com/python/langchain-azure-postgresql/common/_shared/HNSW/build_settings)
- [`default_search_params()`](https://reference.langchain.com/python/langchain-azure-postgresql/common/_shared/HNSW/default_search_params)

---

[View source on GitHub](https://github.com/langchain-ai/langchain-azure/blob/607b649e909f217be20d7a50804ca11534c08eea/libs/azure-postgresql/src/langchain_azure_postgresql/common/_shared.py#L455)