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

gds.degree.stream not respecting orientation? #181

Closed
bSharpCyclist opened this issue Sep 20, 2022 · 4 comments
Closed

gds.degree.stream not respecting orientation? #181

bSharpCyclist opened this issue Sep 20, 2022 · 4 comments

Comments

@bSharpCyclist
Copy link

Describe the bug
I'm trying to reproduce a similar result that I would get in GDS.

To Reproduce
Cypher code:

call gds.graph.project('xdc-test-search', ['Event','Search'], { HAS_SEARCH:{orientation:'REVERSE'}})
call gds.degree.stream('xdc-test-search')
YIELD nodeId, score
return gds.util.asNode(nodeId).search_name_1 as SearchTerm, score As NumberOfSearches
Order by NumberOfSearches Descending, SearchTerm Limit 10;

The above returns the Search nodes.

Python code:

node_projection = ["Event","Search"]
relationship_projection = {"HAS_SEARCH": {"orientation": "REVERSE"}}
G, _ = gds.graph.project("xdc-test-search", node_projection, relationship_projection)
degree_stream = gds.degree.stream(G)

degree.stream above is returning the node ids of the Event nodes (other side of direction), even if I were to use G = gds.graph.get("xdc-test-search") and use the projection created with cypher.

I'm sure it's something I'm doing on my end :)

graphdatascience library version: 1.3
GDS plugin version: 2.1.7
Python version: 3.9.12
Neo4j version: 4.4.10
Operating system: macOS 12.6

The image below is what I would expect from the python approach.
image

@adamnsch
Copy link
Contributor

Hi @bSharpCyclist,

The Python code gds.degree.stream(G) is really just calling call gds.degree.stream('xdc-test-search') and unpacking the result into a dataframe under the hood, so I'm surprised there's a difference.

What's the code for parsing the result of the Python call to gds.degree.stream? How do you know what you see are "Event" nodes?

Adam

@bSharpCyclist
Copy link
Author

Hi @adamnsch

Thanks for the response. In the dataframe that is returned from gds.degree.stream there is a column of nodeIds, and a score column of all zeros, which what I would suspect for that direction of the relationship. Events are unique and will only point to one Search configuration node, but a Search node can have many edges coming into it. After using gds.util.asNode(nodeId) on one of the nodeIds and taking a look at that result, I can see that the node is an Event node.

@adamnsch
Copy link
Contributor

adamnsch commented Sep 21, 2022

Hi @adamnsch

Thanks for the response. In the dataframe that is returned from gds.degree.stream there is a column of nodeIds, and a score column of all zeros, which what I would suspect for that direction of the relationship. Events are unique and will only point to one Search configuration node, but a Search node can have many edges coming into it. After using gds.util.asNode(nodeId) on one of the nodeIds and taking a look at that result, I can see that the node is an Event node.

Ok, thanks for your reply.

When calling gds.degree.stream (either through Cypher or the Python client) you will get a list of all nodes, that is, both "Event" and "Search" nodes will show up in the results. It's therefore certainly possible that gds.util.asNode(nodeId) on one of the nodes will resolve to an "Event" node, using either method. You say the "score" column is all zeroes, but did you check every row?
In your Cypher query you order things so that "Event" nodes are likely at the bottom? "score" or "NumberOfSearches" are perhaps null for "Event" nodes? And since you limit how many results you see you thus don't see them at all?

Adam

@bSharpCyclist
Copy link
Author

OMG facepalm, I just assumed they were all event nodes. That's exactly it 😊 Thanks!!

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

2 participants