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

HashEL doesn't need UnsrtEL backend? #549

Open
krivit opened this issue Jan 5, 2024 · 0 comments
Open

HashEL doesn't need UnsrtEL backend? #549

krivit opened this issue Jan 5, 2024 · 0 comments

Comments

@krivit
Copy link
Member

krivit commented Jan 5, 2024

As far as I can tell, the only place where the edgelist is actually needed is when making a random draw from it. But it should be possible to make random draws from the key array by:

  1. Select a random index from 0 to table capacity.
  2. If that cell is occupied, return the corresponding key.
  3. If unoccupied, either repeat from 1, or probe around the table in some quasi-random way until an occupied cell is found.

This will save quite a bit of memory: you don't need a value array, and you don't need the unsorted edgelist. It will also save the costs of updating the edgelist.

On the other hand, the expected number of draws/probes required is 1/(load factor), where load factor is the proportion of table's cells that is occupied. This means that if the table is too sparsely populated---which can happen if the network starts out dense and then becomes sparse---it can become very inefficient. khash does support shrinking tables, but automatic shrinking is not implemented at this time.

@chad-klumb , what do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant