From 77168756034e48d97101498a8b4c2df1afbebcae Mon Sep 17 00:00:00 2001 From: Eric Zhu Date: Thu, 14 Sep 2023 21:52:33 -0700 Subject: [PATCH] remove unused --- .gitignore | 6 ++++++ datasketch/hnsw.py | 27 +++------------------------ 2 files changed, 9 insertions(+), 24 deletions(-) diff --git a/.gitignore b/.gitignore index 803bb448..c3818686 100644 --- a/.gitignore +++ b/.gitignore @@ -79,3 +79,9 @@ benchmark/**/*.pdf # Virtual env .venv + +# IDE +.vscode + +# MacOS +.DS_Store \ No newline at end of file diff --git a/datasketch/hnsw.py b/datasketch/hnsw.py index 5ab0ba3b..04ce2382 100644 --- a/datasketch/hnsw.py +++ b/datasketch/hnsw.py @@ -170,6 +170,9 @@ class HNSW(MutableMapping): the 0th level. If None, defaults to 2 * m. seed (Optional[int]): The random seed to use for the random number generator. + reverse_edges (bool): Whether to maintain reverse edges in the graph. + This speeds up hard remove (:meth:`remove`) but increases memory + usage and slows down :meth:`insert`. Examples: @@ -1048,27 +1051,3 @@ def merge(self, other: HNSW) -> HNSW: new_index = self.copy() new_index.update(other) return new_index - - def get_non_reachable_keys(self, ef: Optional[int] = None) -> List[Hashable]: - """Return a list of keys of points that are not reachable from the entry - point using the given ``ef`` value. - - Args: - ef (Optional[int]): The number of neighbors to consider during - search. If None, use the construction ef. - - Returns: - List[Hashable]: A list of keys of points that are not reachable. - """ - if ef is None: - ef = self._ef_construction - non_reachable = [] - if self._entry_point is None: - return non_reachable - for key, node in self._nodes.items(): - if node.is_deleted: - continue - neighbors = self.query(node.point, ef=ef) - if key not in [k for k, _ in neighbors]: - non_reachable.append(key) - return non_reachable