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

add point store and candidate set #9

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

cangfengzhs
Copy link
Owner

No description provided.

create tag point(vector string);
create edge e();

insert vertex point(vector) VALUES 0:(""))
Copy link
Collaborator

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
Copy link
Collaborator

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(
Copy link
Collaborator

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])
Copy link
Collaborator

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))
Copy link
Collaborator

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:
Copy link
Collaborator

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)
Copy link
Collaborator

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
Copy link
Collaborator

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?

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

Successfully merging this pull request may close these issues.

2 participants