How can we check connectedness of a graph in Apache AGE?
If nodes are labeled as "vertex" and edges labeled as "distance," Then, Here's my Cypher query:
MATCH (start:vertex)
OPTIONAL MATCH path = (start)-[:distance*]-(end:vertex)
WHERE end IS NULL
RETURN CASE WHEN path IS NULL THEN 'Graph is not connected' ELSE 'Graph is connected' END AS result;
In this query, the MATCH clause matches the starting node labeled as "vertex" ((start:vertex)). The OPTIONAL MATCH clause then attempts to find a path (path = (start)-[:distance*]-(end:vertex)) from the starting vertex to any other vertex in the graph using the "distance" relationship.
Could anyone give me complete guidelines on implementation?