-
Notifications
You must be signed in to change notification settings - Fork 2
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
add point store and candidate set #9
base: main
Are you sure you want to change the base?
Conversation
create tag point(vector string); | ||
create edge e(); | ||
|
||
insert vertex point(vector) VALUES 0:("")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
an extra bracket in the end?
points = self.executor.map(self.worker,id_list) | ||
for point in points: | ||
if point.id in self.visited: | ||
return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
continue?
@@ -43,7 +43,8 @@ def get_neighbors(self, vid) -> Tuple[str, Dict]: | |||
''' | |||
# todo: replace t1 as tag, col1 as property | |||
# todo: use int id? | |||
query = "FETCH PROP ON t1 \'{}\' YIELD properties(vertex).col1".format(vid) | |||
query = "FETCH PROP ON t1 \'{}\' YIELD properties(vertex).col1".format( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need slice to escape
|
||
if curr.distance(q) > furthest_res.distance(q): | ||
break | ||
visited = set([p.id for p in candidates]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's equal to {p.id for p in candidates}
return result.values | ||
|
||
def knn_search(self, q: Point, k: int, ef: int) -> List[Point]: | ||
points.sort(key=lambda x: x.distance(q)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
heap is better
def __select_neighbors_simple(self, q: Point, candidates: List[Point], m: int) -> List[Point]: | ||
candidate_set = CandidateSet( | ||
q, candidates, candidate_count, self.point_store) | ||
while True: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
simple BFS may be slower than the method in the paper
return max(self._points_pair)[1] | ||
if self.id ==0 or other.id == 0: | ||
return float('inf') | ||
return np.linalg.norm(self.vector - other.vector) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could cache some distance here in id granularity.
self.max_degree = 10 | ||
self.layer_factor = 4 | ||
self.max_layer = 5 | ||
self.candidate_set_size = 100 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all this config should calculate according with the data size?
No description provided.