# How to port gds.graph.project to gds.graph.cypher.project, when adding an aggregation?

**URL:** <https://community.neo4j.com/t/how-to-port-gds-graph-project-to-gds-graph-cypher-project-when-adding-an-aggregation/74109>\
**Category:** Graph Data Science / Graph Analytics\
**Created:** [June 9, 2025, 5:25am UTC](https://community.neo4j.com/t/how-to-port-gds-graph-project-to-gds-graph-cypher-project-when-adding-an-aggregation/74109 "2025-06-09T05:25:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![alexismenanieves](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/alexismenanieves/32/33919_2.png) [@alexismenanieves](https://community.neo4j.com/u/alexismenanieves)\
**Post date:** [June 9, 2025, 5:25am UTC](https://community.neo4j.com/t/how-to-port-gds-graph-project-to-gds-graph-cypher-project-when-adding-an-aggregation/74109/1 "2025-06-09T05:25:10Z")

</div>

I have this code:

```auto
G, result = gds.graph.project(
    "communities", # Graph name
    " __Entity__", # Node projection
    {
        "_ALL_": {
            "type": "*",
            "orientation": "UNDIRECTED",
            "properties": {"weight": {"property": "*", "aggregation": "COUNT"}},
        }
    },
)

```

And I want to port this to gds.graph.cypher.project. So far I did this:

```auto
G, result = gds.graph.cypher.project(
    """
    MATCH (n: __Entity__ )--(m: __Entity__ ) 
    WHERE n.node_embedding IS NOT NULL 
    AND m.node_embedding IS NOT NULL 
    AND n.docID = $doc 
    AND m.docID = $doc 
    RETURN gds.graph.project($graph_name, n, m, 
    {
        sourceNodeLabels: $label,
        targetNodeLabels: $label,
        sourceNodeProperties: n { .weight },
        targetNodeProperties: m { .weight }
    }, 
    {
        undirectedRelationshipTypes: ['*']
    })
    """,
    database='neo4j',
    graph_name='communities',
    label=' __Entity__',
    doc='Gasification'
)

```

But I'm stuck since my nodes don't have the weight property. I'm not sure if in the initial code the weights are calculated temporarily so they are used for the aggregation. Any help will be greatly appreciated.

---

<div class="post-metadata">

**Author:** ![paul.horn](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/paul.horn/32/16032_2.png) [@paul.horn](https://community.neo4j.com/u/paul.horn)\
**Post date:** [June 16, 2025, 1:01pm UTC](https://community.neo4j.com/t/how-to-port-gds-graph-project-to-gds-graph-cypher-project-when-adding-an-aggregation/74109/2 "2025-06-16T13:01:37Z")

</div>

Hi,

relationship aggregations are no longer done by the Cypher projection itself, you would use plain Cypher aggregations before passing the values into the Cypher projection function (gds.graph.project).

This is documented as "parallel relationships": [Cypher projection - Neo4j Graph Data Science](https://neo4j.com/docs/graph-data-science/current/management-ops/graph-creation/graph-project-cypher-projection/#graph-project-cypher-projection-parallel-relationships)

In you example, it could look like (with annotations in code, though that is not correct syntax, just for explanation)

```cypher
G, result = gds.graph.cypher.project(
    """
    MATCH (n: __Entity__ )-[r]-(m: __Entity__ ) // give the relationship a name
    WHERE n.node_embedding IS NOT NULL 
    AND m.node_embedding IS NOT NULL 
    AND n.docID = $doc 
    AND m.docID = $doc
    WITH n, m, count(r) as weight // use the count aggregation in Cypher 
    RETURN gds.graph.project($graph_name, n, m, 
    {
        sourceNodeLabels: $label,
        targetNodeLabels: $label,
        sourceNodeProperties: n { .weight },
        targetNodeProperties: m { .weight },
        relationshipProperties: { weight: weight } // pass the property to the projection
    }, 
    {
        undirectedRelationshipTypes: ['*']
    })
    """,
    database='neo4j',
    graph_name='communities',
    label=' __Entity__',
    doc='Gasification'
)

```
