Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
05-29-2022 09:19 AM
I'm projecting a graph with the below code:
CALL gds.graph.project(
'entityGraph',
'Entity',
'TO_ENTITY'
)
When I use this projected graph in the call to GDS algorithm dijkstra it returns the desired result. However, when I use this graph in my custom pregel function, when I debug info of the given start node's degree, it says 0. I'm absolutely sure that my start node has TO_ENTITY relationships as I see them when I query that node.
My GDS version is 2.0.4
What might be the cause of the pregel displaying degree as zero?
Thanks.
Solved! Go to Solution.
06-04-2022 12:30 AM
🙂 As I wrote in my previous reply, I figured that you took that snippet from the examples. And it's also "wrong" there, so I'll add methods that allow the mapping and will also update the example.
05-30-2022 06:44 AM
Note, that the node ids that you see in Pregel (or in GDS in general) are not necessarily the same node ids as in the database. When we project the graph (via native or Cypher projection), we map the original node id space to an internal, consecutive node id space: [0, nodeCount)
.
For example, let's say you project the Neo4j nodes [42, 1337, 1984, 2001]
into the in-memory graph. In GDS, those could be mapped to {0 => 42, 1 => 1337, 2 => 1984, 3 => 2001}
.
I assume that you want to figure out if the context.nodeId()
is the same as some source node id that you passed in via the config?
05-31-2022 04:29 AM
Thanks for the explanation. My problem is actually with the degree(the number of relationships a node have). I'm sure that given node has relationships and I can see in the output of graph.create method that relationships have been created. Also, when I run core gds functions such as shortestpaths.dijkstra with the same graph, it returns the desired results. The problem is with the pregel. It somehow can't see the relationships of nodes.
05-31-2022 05:58 AM
Do you have the code available on GitHub so that I can take a look?
All procedures that take node ids as part of their configuration, including gds.shortestPath.dijkstra
translate the given node id to the internal node id. Pregel does not do this out of the box, that's why I thought that you end up looking at the wrong node (i.e. node 0 in Pregel is not node 0 in Neo4j). But best to share some code to verify. Pregel is also used for gds.pageRank
and works fine, so I assume it's an input problem.
05-31-2022 08:18 AM
You can see my code here : https://gitlab.com/cuneyttyler/dijkstra-multiple-inputs
Actually, I'm printing the degree for the start node and that's 0.
06-02-2022 01:04 AM
It seems I don't have access to the repo, getting a 404.
06-02-2022 07:17 AM
Seems I don't have access to the repo, getting a 404.
06-02-2022 07:24 AM
Sorry, I made it available now.
06-03-2022 12:16 AM
Thanks. I had a look and I think the problem is exactly what I described in my first reply. In https://gitlab.com/cuneyttyler/dijkstra-multiple-inputs/-/blob/master/src/main/java/com/semanticspac... you're checking the internal node id against the original node id (the user input). Those are not necessarily the same node entity, so the degree might differ. I suspect that if you run an algo test (using a GDLGraph) with that computation you'll see the correct degrees since the GDL Graph has (by default) the same internal and original id space.
However, I assume you took the Pregel examples as a template and there, we also show it in the same way. I'll will add methods to the ComputeContext which will allow you to map node ids between the id spaces.
06-03-2022 12:51 AM - edited 06-03-2022 12:54 AM
Thanks! I didn't realise that. So I was very new when I asked the question but now I also have a look at the GDS Api and saw tests there. Now I'll run a test and see what happens.
EDIT: But now I realize that in that line where I check for the nodeId == config.startNode() - I didn't write that code. I took it from the Pregel BFS example. So the example also checks if the processed node is the start node this way. Is there something wrong with the Pregel example as well?
06-04-2022 12:30 AM
🙂 As I wrote in my previous reply, I figured that you took that snippet from the examples. And it's also "wrong" there, so I'll add methods that allow the mapping and will also update the example.
06-04-2022 04:10 AM
PR is open on the interal repo. With a bit of luck it will be in the 2.1 release next week.
All the sessions of the conference are now available online