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

neighbor algorithm cannot find nodes over 2 hops #432

Open
reggiehsu111 opened this issue Dec 7, 2023 · 3 comments
Open

neighbor algorithm cannot find nodes over 2 hops #432

reggiehsu111 opened this issue Dec 7, 2023 · 3 comments
Labels
bug bug community community Effort - Low Effort - Low Frequency - Monthly Frequency - Monthly Priority - Later Priority - Later Reach - VeryFew Reach - VeryFew Severity - S3 Severity - S3

Comments

@reggiehsu111
Copy link

Memgraph version
2.12.1

Environment
memgraph running on docker

Describe the bug
I created a very simple graph that looks like this:
Screenshot 2023-12-07 at 6 38 58 PM
When running this query to find neighbors of Paper_id nodes:
"MATCH (p:Paper_id {id: "710.4637"})
CALL neighbors.at_hop(p, ["connected"], 1) YIELD nodes
RETURN nodes;"
I'm able to get the correct results.
Screenshot 2023-12-07 at 6 40 12 PM

However, when I try to get nodes that are 2 hops away, there was nothing returned.
If I use the results I found from the first hop, I'm able to get the results, this means that the edges are correctly created, yet I can't retrieve the results.

The "connected" relations are created using my csv files:
LOAD CSV FROM "/usr/work_space/data/csvs/author_edges.csv" WITH HEADER AS row
CREATE (n1:Paper_id {id: row.paper_id})-[:connected]->(n2:Author {id: row.author});

@antejavor
Copy link

antejavor commented Dec 8, 2023

Hi @reggiehsu111 thanks for opening the issue.

This is expected, so the at_hop returns the nodes that are at specific hop from the node. In this case there is no nodes at 2 hops. Related at_hop docs
From docs:

Returns nodes that are at a specific distance from a given node, considering only the relationships of a specified type

We have by_hop this should return all relationships up to 2 hops.
From docs:

Returns nodes that are at any or up to a specific distance from a given node, considering only the relationships of a specified type.

Please let me know if this helps 🚀

@reggiehsu111
Copy link
Author

reggiehsu111 commented Dec 8, 2023

Thanks for replying.
It doesn't work for both at_hop and by_hop.
Essentially I'm constructing a bipartite graph (Paper_id nodes <-> all other nodes). So when I start the algorithm from a single Paper_id node and set the hops to 2, I expect it to first hop on all other types of nodes, and then hop to a new group of Paper_id nodes that are 2 hops away from the original one. But currently it's returning nothing.

Both at_hop and by_hop only works with 1 hop on my data, and if I start from a node, and use it's direct neighbor as a starting point to run the 1-hop algorithm again, I'm still able to get another group of nodes which should be nodes that are 2 hops away from the original node. That means that I'm constructing the graph correctly, just somehow the algorithm couldn't find nodes that are more than 1 hop away.

@matea16
Copy link

matea16 commented Dec 13, 2023

Hi @reggiehsu111. I've tried testing out your issue and it seems to be working as expected. From the simple graph you provided, it's expected only to have nodes that are 1 hop away. Could you be able to provide us with the dataset of the bipartite graph you mentioned in order for me to try and replicate your issue?
One more thing, we've had some changes in the latest versions of Memgraph regarding the neighbors procedure, what version of Memgraph are you using?

@matea16 matea16 transferred this issue from memgraph/memgraph Dec 13, 2023
@katarinasupe katarinasupe added Importance - I3 Importance - I3 Severity - S3 Severity - S3 Effort - Unknown Effort - Unknown community community labels Dec 27, 2023
@imilinovic imilinovic added Effort - Low Effort - Low and removed Effort - Unknown Effort - Unknown labels Feb 22, 2024
@hal-eisen-MG hal-eisen-MG added the Priority - Later Priority - Later label Feb 22, 2024
@katarinasupe katarinasupe added Frequency - Monthly Frequency - Monthly Reach - VeryFew Reach - VeryFew and removed Importance - I3 Importance - I3 labels Feb 27, 2024
@gitbuda gitbuda removed their assignment Mar 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug bug community community Effort - Low Effort - Low Frequency - Monthly Frequency - Monthly Priority - Later Priority - Later Reach - VeryFew Reach - VeryFew Severity - S3 Severity - S3
Projects
Development

No branches or pull requests

7 participants