2
votes

I've used neo4j-mazerunner to analyze strongly_connected_components relationship on my graph. The process has ended and now I got the strongly_connected_components property on my nodes.

I have used the following query to get rows of nodes distinct nodes:

MATCH (n) WHERE has(n.strongly_connected_components)
RETURN DISTINCT "node" as element, n.strongly_connected_components
AS strongly_connected_components
LIMIT 25 UNION ALL MATCH ()-[r]-()
WHERE has(r.strongly_connected_components)
RETURN DISTINCT "relationship" AS element, r.strongly_connected_components 
AS strongly_connected_components LIMIT 25

I'm not sure how to cypher query the graph in order to visualize the generated clusters.

Any help would be appericiated.

3
You have a few problems in your query, aside from it not doing what you are asking about. RETURN DISTINCT "node" as element, ... will always return the string "node" as the value of the element column in your results -- this is probably not what you intended. Also, the sub-query after the UNION clause should never match anything, since mazerunner only adds the strongly_connected_components property to nodes.cybersam

3 Answers

2
votes

This query should return 25 clusters, and you should be able to visualize each cluster in the browser as strongly connected nodes. The query assumes that FOO was the relationship specified to neo4j-mazerunner when asking it to generate the strongly_connected_components values.

NOTE: Turn OFF the browser's AUTO-COMPLETE feature (in the lower right-hand corner of the result pane) to only see the FOO relationships between the nodes in each cluster:

MATCH p=(n1)-[:FOO]->()
RETURN n1.strongly_connected_components AS clusterId, COLLECT(p) AS paths
LIMIT 25;

Since neo4j-mazerunner assigns the same strongly_connected_components value to all the nodes in the same cluster, this query simply aggregates all the paths with the same strongly_connected_components value (identified as clusterId).

1
votes

you can query a specific id using:

match (n2 {strongly_connected_components:NODE_ID_HERE})-[r:NEXT]->(n) return n,n2 LIMIT 50
0
votes

I'm probably misunderstanding the problem here, but this will give you the bigger picture of your strongly connected nodes:

MATCH (n) WHERE has(n.strongly_connected_components) MATCH (n)-[*]-() RETURN n