Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A quick question about length of neighbors for one Element #547

Closed
xingtanzjr opened this issue May 8, 2024 · 1 comment
Closed

A quick question about length of neighbors for one Element #547

xingtanzjr opened this issue May 8, 2024 · 1 comment

Comments

@xingtanzjr
Copy link

See this code snippet,

/*
 * Load neighbors from page
 */
static void
LoadNeighborsFromPage(HnswElement element, Relation index, Page page, int m)
{
	char	   *base = NULL;

	HnswNeighborTuple ntup = (HnswNeighborTuple) PageGetItem(page, PageGetItemId(page, element->neighborOffno));
	int			neighborCount = (element->level + 2) * m;

	Assert(HnswIsNeighborTuple(ntup));

	HnswInitNeighbors(base, element, m, NULL);

Why is the neighborCount is (level + 2) * m rather than (level + 1) * m?

@ankane
Copy link
Member

ankane commented May 8, 2024

Layer 0 can have up to 2 * m connections, as recommended in the HNSW paper.

@ankane ankane closed this as completed May 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants