// MATCH (n) DETACH DELETE n
MERGE (a: User { id: 0 })
MERGE (b: User { id: 1 })
CREATE (a)-[r1:FOLLOW ]->(b)
CREATE (b)-[r2:FOLLOW]->(a)
SET r2 = r1
WITH r1 DELETE r1
// RETURN a,b
//
MATCH (n) DETACH DELETE n
//
MATCH (n) RETURN n
CREATE (a: User { id: 0 })
CREATE (b: User { id: 1 })
CREATE (a)-[r:FOLLOW ]-(b)
RETURN a,b,r
CREATE (a: User { id: 0 })
CREATE (b: User { id: 1 })
CREATE (a)-[ab:FOLLOW ]->(b)-[ba:FOLLOW]->(a)
RETURN a,b,ab,ba
CREATE (a: User { id: 0 })
CREATE (b: User { id: 1 })
CREATE UNIQUE (a)-[ab:FOLLOW ]->(b)-[ba:FOLLOW]->(a)
RETURN a,b,ab,ba
//
// http://www.remwebdevelopment.com/blog/sql/some-basic-and-useful-cypher-queries-for-neo4j-201.html
//
// a. Find the unique labels that appear in the database:
match (n)
return distinct labels(n)
// b. Find the unique relationships that appear in the database:
match (n)-[r]-()
return distinct type(r)
// combine a and b
match (n)-[r]-()
return distinct labels(n), type(r)
// Find nodes that don't have any relationships:
start n=node(*)
optional match (n)-[r]-()
where r is null
return n
// Find all nodes that have a specific property:
start n=node(*)
match (n)
where exists(n.id)
return n
// Find all nodes that have a specific relationship (regardless of the direction of the relationship):
start n=node(*)
match (n)-[:FOLLOW]-()
return distinct n
// Show the nodes and a count of the number of relationships that they have:
start n=node(*)
match (n)-[r]-()
return n, count(r) as rel_count
order by rel_count desc
// Get a count of all nodes in your graph:
start n=node(*)
match (n)
return count(n)
// To delete all nodes in a databse (first you have to delete all relationships)
start n=node(*)
match (n)-[r]-()
delete r
WITH r
start n=node(*)
match (n)
delete n
// A simple query to get nodes of a certain category that match a certain property
match (n:Person) where n.name="Tim" return n