# How to stream nod labels from the graph projection?

**URL:** <https://community.neo4j.com/t/how-to-stream-nod-labels-from-the-graph-projection/61247>\
**Category:** Graph Data Science / Graph Analytics\
**Tags:** operations\
**Created:** [March 4, 2023, 12:33pm UTC](https://community.neo4j.com/t/how-to-stream-nod-labels-from-the-graph-projection/61247 "2023-03-04T12:33:55Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![mlnrt](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/mlnrt/32/27767_2.png) [@mlnrt](https://community.neo4j.com/u/mlnrt)\
**Post date:** [March 4, 2023, 12:33pm UTC](https://community.neo4j.com/t/how-to-stream-nod-labels-from-the-graph-projection/61247/1 "2023-03-04T12:33:55Z")

</div>

Hello,  
I am once more lost with something very trivial: How can I stream node labels from the graph projection?  
I see GDS procedures to mutate node label, but nothing to read what is written in the graph projection. I can write in the graph projection but node read. It feels I am missing something very obvious...  
The only dirty work around I can think of so far is to both mutate the graph and write these temporary node labels back into the main database and use the `gds.util.asNodes` procedure to read the nodes back from the main database which I really don't want to do. I shouldn't have to alter my main database to read temporary information.  
What I am missing? Any help will be appreciated.

Neo4j Desktop: 1.5.7  
Neo4j DBMS: 5.4.0  
APOC version: 5.4.1  
GDS version: 2.3.1  
Python Neo4j client: 5.4.0  
Python GDS client: 1.6

---

<div class="post-metadata">

**Author:** ![alison.cossette](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/alison.cossette/32/27383_2.png) [@alison.cossette](https://community.neo4j.com/u/alison.cossette)\
**Post date:** [March 8, 2023, 3:53pm UTC](https://community.neo4j.com/t/how-to-stream-nod-labels-from-the-graph-projection/61247/2 "2023-03-08T15:53:44Z")

</div>

Hi Minrt,

Another great question! You are correct that `mutate` writes the results of the algorithm to the projected graph and returns a single record of summary statistics.

What you are looking for is the `stream` functionality in gds. Stream will return the results of the algorithm as a stream of records without altering the database. If you have a large output and only want some values returned, you can always`ORDERBY` and `LIMIT` to see a portion of the results.

> **[Running algorithms - Neo4j Graph Data Science](https://neo4j.com/docs/graph-data-science/current/common-usage/running-algos/#running-algos-stream)**
>
> \[object Object\]

---

<div class="post-metadata">

**Author:** ![mlnrt](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/mlnrt/32/27767_2.png) [@mlnrt](https://community.neo4j.com/u/mlnrt)\
**Post date:** [March 8, 2023, 8:24pm UTC](https://community.neo4j.com/t/how-to-stream-nod-labels-from-the-graph-projection/61247/3 "2023-03-08T20:24:51Z")

</div>

@alison.cossette thank you for replying and trying to help. This is very much appreciated. But please note that the question is about node labels, not node properties. I know I can use the `stream` functionality in `gds` to read node values (like values computed by algorithms). But how do I read a label I wrote in the graph memory?  
When I read this documentation: [Node operations - Neo4j Graph Data Science](https://neo4j.com/docs/graph-data-science/current/graph-catalog-node-ops/) I see how to stream a node property, write or mutate a node lablel but nothing to stream a node label.

---

<div class="post-metadata">

**Author:** ![florentin\_dorre](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/florentin_dorre/32/18241_2.png) [@florentin\_dorre](https://community.neo4j.com/u/florentin_dorre)\
**Post date:** [March 23, 2023, 9:14am UTC](https://community.neo4j.com/t/how-to-stream-nod-labels-from-the-graph-projection/61247/4 "2023-03-23T09:14:01Z")

</div>

Hello again @mlnrt,  
catching up on your post.

For streaming node labels, I would suggest to stream the nodes for each nodeLabel explicitly.  
This way, you save streaming the label strings for each node.  
` gds.graph.nodeProperties.stream` has a `nodeLabels` parameter which can set to a single label in your case.  
You can get the labels of the projected graph through `CALL gds.graph.list('my_graph') YIELD schemaWithOrientation WITH labels AS keys(schemaWithOrientation['nodes'])`

From the general usage pov, why do you want to stream the node labels? Are you using `gds.alpha.graph.nodeLabel.mutate`? Otherwise the nodeLabels should be the same as in your input data.

---

<div class="post-metadata">

**Author:** ![mlnrt](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/mlnrt/32/27767_2.png) [@mlnrt](https://community.neo4j.com/u/mlnrt)\
**Post date:** [March 23, 2023, 2:51pm UTC](https://community.neo4j.com/t/how-to-stream-nod-labels-from-the-graph-projection/61247/5 "2023-03-23T14:51:50Z")

</div>

Hello @florentin_dorre  
Thank you for replying. Yes I do use the `gds.alpha.graph.nodeLabel.mutate` procedure and I just find it natural to be able read what was written in the graph.  
What I am trying to achieve is that in the database I have, amongst other things, people nodes. When I project these nodes into a graph projection to perform some analysis, I want to put them into different categories and I am using labels for that. And I don't want these temporary labels to be written in the database so I would like to just mutate the graph. Then later on, in my analysis the objective is to stratify per category (node labels) and for that I want to pull all the labels of each nodes. So using the `nodeLabels` parameter of the `gds.graph.nodeProperties.stream` procedure doesn't help me achieve that.

---

<div class="post-metadata">

**Author:** ![florentin\_dorre](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/florentin_dorre/32/18241_2.png) [@florentin\_dorre](https://community.neo4j.com/u/florentin_dorre)\
**Post date:** [March 29, 2023, 9:19am UTC](https://community.neo4j.com/t/how-to-stream-nod-labels-from-the-graph-projection/61247/6 "2023-03-29T09:19:30Z")

</div>

Okay, that totally makes sense.

My work around would look like the following:

```auto
CALL gds.graph.project('g2', ['A', 'B'], '*', {nodeProperties: ['score']})

```

```auto
CALL gds.alpha.graph.nodeLabel.mutate('g2', 'C', { nodeFilter: 'n.score > 1' })
YIELD graphName, nodeLabel, nodeLabelsWritten, nodeCount

```

```auto
WITH ['A', 'B', 'C'] AS labels
UNWIND labels as label
CALL gds.graph.nodeProperty.stream('g2', 'score', label)
YIELD nodeId, propertyValue
WITH nodeId, propertyValue, label
RETURN *

```

This result you should be able to use?

---

<div class="post-metadata">

**Author:** ![mlnrt](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/mlnrt/32/27767_2.png) [@mlnrt](https://community.neo4j.com/u/mlnrt)\
**Post date:** [March 30, 2023, 2:37pm UTC](https://community.neo4j.com/t/how-to-stream-nod-labels-from-the-graph-projection/61247/7 "2023-03-30T14:37:51Z")

</div>

I see. I did not thought about that. That would work I think. Thank you for taking the time to help and provide a solution. This is really much appreciated.
