# Pregel node degree is 0 even if it has relationships

**URL:** <https://community.neo4j.com/t/pregel-node-degree-is-0-even-if-it-has-relationships/60225>\
**Category:** Neo4j Graph Platform\
**Tags:** migrated\
**Created:** [May 29, 2022, 4:19pm UTC](https://community.neo4j.com/t/pregel-node-degree-is-0-even-if-it-has-relationships/60225 "2022-05-29T16:19:45Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![cuneyttyler](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/cuneyttyler/32/27531_2.png) [@cuneyttyler](https://community.neo4j.com/u/cuneyttyler)\
**Post date:** [May 29, 2022, 4:19pm UTC](https://community.neo4j.com/t/pregel-node-degree-is-0-even-if-it-has-relationships/60225/1 "2022-05-29T16:19:45Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![martin\_junghann](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/martin_junghann/32/13763_2.png) [@martin\_junghann](https://community.neo4j.com/u/martin_junghann)\
**Post date:** [June 2, 2022, 2:17pm UTC](https://community.neo4j.com/t/pregel-node-degree-is-0-even-if-it-has-relationships/60225/2 "2022-06-02T14:17:29Z")

</div>

Seems I don't have access to the repo, getting a 404.

---

<div class="post-metadata">

**Author:** ![martin\_junghann](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/martin_junghann/32/13763_2.png) [@martin\_junghann](https://community.neo4j.com/u/martin_junghann)\
**Post date:** [June 2, 2022, 8:04am UTC](https://community.neo4j.com/t/pregel-node-degree-is-0-even-if-it-has-relationships/60225/3 "2022-06-02T08:04:27Z")

</div>

It seems I don't have access to the repo, getting a 404.

---

<div class="post-metadata">

**Author:** ![cuneyttyler](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/cuneyttyler/32/27531_2.png) [@cuneyttyler](https://community.neo4j.com/u/cuneyttyler)\
**Post date:** [June 2, 2022, 2:24pm UTC](https://community.neo4j.com/t/pregel-node-degree-is-0-even-if-it-has-relationships/60225/4 "2022-06-02T14:24:16Z")

</div>

Sorry, I made it available now.

---

<div class="post-metadata">

**Author:** ![martin\_junghann](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/martin_junghann/32/13763_2.png) [@martin\_junghann](https://community.neo4j.com/u/martin_junghann)\
**Post date:** [June 3, 2022, 7:16am UTC](https://community.neo4j.com/t/pregel-node-degree-is-0-even-if-it-has-relationships/60225/5 "2022-06-03T07:16:15Z")

</div>

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/semanticspace/neo4j/DijkstraMultipleInputs.java#L45](https://gitlab.com/cuneyttyler/dijkstra-multiple-inputs/-/blob/master/src/main/java/com/semanticspace/neo4j/DijkstraMultipleInputs.java#L45) 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.

---

<div class="post-metadata">

**Author:** ![cuneyttyler](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/cuneyttyler/32/27531_2.png) [@cuneyttyler](https://community.neo4j.com/u/cuneyttyler)\
**Post date:** [June 3, 2022, 7:51am UTC](https://community.neo4j.com/t/pregel-node-degree-is-0-even-if-it-has-relationships/60225/6 "2022-06-03T07:51:05Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![martin\_junghann](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/martin_junghann/32/13763_2.png) [@martin\_junghann](https://community.neo4j.com/u/martin_junghann)\
**Post date:** [June 4, 2022, 11:10am UTC](https://community.neo4j.com/t/pregel-node-degree-is-0-even-if-it-has-relationships/60225/7 "2022-06-04T11:10:36Z")

</div>

PR is open on the interal repo. With a bit of luck it will be in the 2.1 release next week.

---

<div class="post-metadata">

**Author:** ![martin\_junghann](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/martin_junghann/32/13763_2.png) [@martin\_junghann](https://community.neo4j.com/u/martin_junghann)\
**Post date:** [June 4, 2022, 7:30am UTC](https://community.neo4j.com/t/pregel-node-degree-is-0-even-if-it-has-relationships/60225/8 "2022-06-04T07:30:51Z")

</div>

🙂 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.

* * *
