# 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/56981>\
**Category:** Graph Data Science / Graph Analytics\
**Created:** [May 29, 2022, 4:19pm UTC](https://community.neo4j.com/t/pregel-node-degree-is-0-even-if-it-has-relationships/56981 "2022-05-29T16:19:45Z")\
**Posts on this page:** 5\
**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/56981/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:** [May 30, 2022, 1:44pm UTC](https://community.neo4j.com/t/pregel-node-degree-is-0-even-if-it-has-relationships/56981/2 "2022-05-30T13:44:42Z")

</div>

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?

---

<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 31, 2022, 11:29am UTC](https://community.neo4j.com/t/pregel-node-degree-is-0-even-if-it-has-relationships/56981/3 "2022-05-31T11:29:20Z")

</div>

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.

---

<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:** [May 31, 2022, 12:58pm UTC](https://community.neo4j.com/t/pregel-node-degree-is-0-even-if-it-has-relationships/56981/4 "2022-05-31T12:58:00Z")

</div>

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.

---

<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 31, 2022, 3:18pm UTC](https://community.neo4j.com/t/pregel-node-degree-is-0-even-if-it-has-relationships/56981/5 "2022-05-31T15:18:41Z")

</div>

You can see my code here : [Cüneyt Tyler / Dijkstra Multiple Inputs · GitLab](https://gitlab.com/cuneyttyler/dijkstra-multiple-inputs)

Actually, I'm printing the degree for the start node and that's 0.
