简体   繁体   中英

Neo4j - Graph Data Science library - How to cypher-query against a named graph in Graph Catalog?

Creating a named graph from the main Neo4j Graph is documented . Beside, one also knows how to list, drop, check if a named graph already exists, eg CALL gds.graph.exists('my-store-graph') YIELD exists;

However, I wonder if there is any method for cypher-query against the just created named graph ?

One workaround is to push this named graph into an offline/empty Neo4j Graph, ie CALL gds.beta.graph.export('my-graph', { dbName: 'mydatabase' }) . However, this method is less convenient because we often want to check if the named graph is projected correcly before applying, eg PageRank on it. And the projection can be a trial-and-error cycle.

There is currently no other way of querying the named graph other than the workaround you already found.

However, there are additional functions, eg gds.util.nodeProperty that allow you to access a node property in the named graph without writing it back to Neo4j. An example for querying a score property could look like this:

CALL gds.graph.create('my-graph', 'User', 'LINK');
CALL gds.pageRank.mutate('my-graph', { mutateProperty: 'score' });
MATCH (user:User)
WHERE user.name = 'Alice'
RETURN
    user.name AS name,
    gds.util.nodeProperty('my-graph', id(user), 'score') AS score

Could you maybe elaborate why your projections are "trial-and-error" cycles. Maybe an option is to run your validation queries on the subgraph you want to project?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM