# GDS graph catalog function to get all loaded node Ids

**URL:** <https://community.neo4j.com/t/gds-graph-catalog-function-to-get-all-loaded-node-ids/36850>\
**Category:** Graph Data Science / Graph Analytics\
**Created:** [April 14, 2021, 9:26am UTC](https://community.neo4j.com/t/gds-graph-catalog-function-to-get-all-loaded-node-ids/36850 "2021-04-14T09:26:02Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![naveh](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/naveh/32/4404_2.png) [@naveh](https://community.neo4j.com/u/naveh)\
**Post date:** [April 14, 2021, 9:26am UTC](https://community.neo4j.com/t/gds-graph-catalog-function-to-get-all-loaded-node-ids/36850/1 "2021-04-14T09:26:02Z")

</div>

Hi,  
I'm trying to iterate over all nodes in a named virtual graph (created by gds.graph.create), and I can't seem to find a function that streams/returns all nodeIds back without doing any additional computation.  
For example:

```auto
CALL gds.pageRank.stream('myGraph')
YIELD nodeId, score

```

will return what I need, but will perform additional work (computing the score for each node).  
I only need to get the nodeIds from the graph.  
Am I missing something or do I need to fork gds and write my own algorithm for this?

Thanks!  
Naveh.

---

<div class="post-metadata">

**Author:** ![Cobra](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/cobra/32/35243_2.png) [@Cobra](https://community.neo4j.com/u/Cobra)\
**Post date:** [April 14, 2021, 11:16am UTC](https://community.neo4j.com/t/gds-graph-catalog-function-to-get-all-loaded-node-ids/36850/2 "2021-04-14T11:16:14Z")

</div>

Hello @naveh 🙂

Maybe i misunderstood but you don't need GDS to get node id, if you only want internal Neo4j id of nodes, there is the function [id()](https://neo4j.com/docs/cypher-manual/current/functions/scalar/#functions-id).

Regards,  
Cobra

---

<div class="post-metadata">

**Author:** ![alicia\_frame1](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/alicia_frame1/32/6998_2.png) [@alicia\_frame1](https://community.neo4j.com/u/alicia_frame1)\
**Post date:** [April 14, 2021, 1:31pm UTC](https://community.neo4j.com/t/gds-graph-catalog-function-to-get-all-loaded-node-ids/36850/3 "2021-04-14T13:31:43Z")

</div>

If you don't need to use GDS for something else, then @Cobra's suggestion of using `id()` will work for you.

If you _do_ need a list of IDs in your analytics graph, you can use `gds.graph.streamNodeProperties`[(docs)](https://neo4j.com/docs/graph-data-science/current/management-ops/graph-catalog-ops/#catalog-graph-stream-node-properties) and specify `nodeId`

---

<div class="post-metadata">

**Author:** ![naveh](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/naveh/32/4404_2.png) [@naveh](https://community.neo4j.com/u/naveh)\
**Post date:** [April 18, 2021, 6:19am UTC](https://community.neo4j.com/t/gds-graph-catalog-function-to-get-all-loaded-node-ids/36850/4 "2021-04-18T06:19:23Z")

</div>

Thanks for your replies!  
Unfortunately I do need the graph for other GDS functions later on.  
When I use **gds.graph.streamNodeProperty** or **gds.graph.streamNodeProperties** I get this error:

`Failed to invoke procedure `gds.graph.streamNodeProperty`: Caused by: java.lang.IllegalArgumentException: No node projection with property key(s) ['nodeId'] found.`

 ![image](https://us1.discourse-cdn.com/flex021/uploads/neo4jcommunity/original/3X/7/1/717c80266212feeebca0066545dab4eb99ca38b4.png)

For testing purposes, the graph is created with all nodes, and all relationship of a certain type, like this:  
CALL gds.graph.create('myGraph', '\*', 'RELATIONSHIP\_TYPE', {})

---

<div class="post-metadata">

**Author:** ![JDRomano2](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/jdromano2/32/18418_2.png) [@JDRomano2](https://community.neo4j.com/u/JDRomano2)\
**Post date:** [May 25, 2021, 6:04pm UTC](https://community.neo4j.com/t/gds-graph-catalog-function-to-get-all-loaded-node-ids/36850/5 "2021-05-25T18:04:07Z")

</div>

I'm also looking for an answer to this. I think this rewording might be good for clarification:

How do we create a GDS graph (e.g., using a native projection) and then simply retrieve the nodes and relationships in that graph _without applying a specific graph algorithm_?

`gds.graph.streamNodeProperty` only works once you apply an algorithm to the named graph, but I need to instead retrieve the contents of the graph for use in an external graph machine learning framework.

`gds.graph.export` and `gds.beta.graph.export.csv` are unfortunately not suitable due to the client/server configuration of our Neo4j database.

---

<div class="post-metadata">

**Author:** ![alicia\_frame1](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/alicia_frame1/32/6998_2.png) [@alicia\_frame1](https://community.neo4j.com/u/alicia_frame1)\
**Post date:** [May 27, 2021, 8:41pm UTC](https://community.neo4j.com/t/gds-graph-catalog-function-to-get-all-loaded-node-ids/36850/6 "2021-05-27T20:41:41Z")

</div>

If you're not running any GDS procedures or algorithms, do you need to use the in-memory graph? Or is it simpler just to use the cypher `id()` function to retrieve the data?

---

<div class="post-metadata">

**Author:** ![JDRomano2](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/jdromano2/32/18418_2.png) [@JDRomano2](https://community.neo4j.com/u/JDRomano2)\
**Post date:** [July 8, 2021, 4:21am UTC](https://community.neo4j.com/t/gds-graph-catalog-function-to-get-all-loaded-node-ids/36850/7 "2021-07-08T04:21:25Z")

</div>

Sorry, I totally missed this reply!

I'm not sure how the `id()` function would solve my use case. The database I'm working with contains in the order of 1M nodes and 2M relationships, and I need a way to rapidly stream native projections of that database (containing, for example, 700k nodes and 1.2M relationships) into an external machine learning model implemented in Python.

The only way I can see the `id()` function helping is if I were to tediously build Cypher queries that identified a spanning tree of each of the nodes in my native projection, but that seems both computationally infeasible and inflexible.

To make it a little more concrete, the database I'm working with has nodes corresponding to different types of biological entities (chemicals, genes, metabolic pathways, diseases, etc) and I'm trying to extract the subgraph containing 3 specific node types ("Chemical", "Gene", and "Assay") and all of the relationships linking those nodes.
