Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
03-22-2022 10:32 AM
Hello Everyone,
I want to apply Closeness centrality algorithm on the graph obtained by the following Cypher query.
WITH [uri1, uri2, uri3] AS StopUris
MATCH(n:label1)-[:abc|pqr|xyz*0..2]->(m)-[:uvw*0..1]-(o)
WHERE n.uri = uri4 and not m.uri IN StopUris and not o.uri IN StopUris
RETURN n,m,o
union all
WITH [uri1, uri2, uri3] AS StopUris
MATCH(n:label1)-[:abc|pqr|xyz*0..2]->(m)-[:uvw*0..1]-(o)
WHERE n.uri = uri5 and not m.uri IN StopUris and not o.uri IN StopUris
RETURN n,m,o
Is there any way to store the Cypher result in a graph so that the algorithm can be applied? Thanks in advance.
03-23-2022 06:25 AM
I believe you're looking for this piece of the documentation - https://neo4j.com/docs/graph-data-science/current/graph-create-cypher/.
What you basically do is create an in-memory named graph projection, using a node- and relationship-projection that you define in Cypher. In your example that means the node-projection has to produce nodes n, m and o, and the relationship-projection has to include relationships abc, pqr, xyz.
After naming the graph, you can then call the closeness centrality algorithm as in the examples.
03-29-2022 07:38 AM
Thank you for your suggestion @ChakaBrah . I am using Cypher projection now and it's exactly what I wanted..
03-29-2022 09:30 AM
Good to hear! Cheers
All the sessions of the conference are now available online