[Python] How to form a projection while filtering some nodes in Neo4j

Discussão em 'Python' iniciado por Stack, Junho 9, 2025.

  1. Stack

    Stack Membro Participativo

    I have the following query in Neo4j using the Python library graphdatascience:

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


    And I try to run this for a filtered selection of nodes. So I used this:

    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 on how to relate the "properties": {"weight": {"property": "*", "aggregation": "COUNT"}} in the code. Any pointer will be highly appreciated.

    Continue reading...

Compartilhe esta Página