Skip to main content
// Create a node Person (Jane) - Edge (knows) - node Person (John)
CREATE (:Person {name: 'Jane'})-[:KNOWS]->(:Person {name: 'John'})

// Commit the changes
COMMIT
In the CREATE query above, the two nodes having label Person and the edge were created in the same query. You can also create nodes and queries one by one (less efficient).
// Create two nodes Person : Jane and John
CREATE (:Person {name: 'John'})
CREATE (:Person {name: 'Jane'})

// You need to commit the changes after node creation
COMMIT

// Match Jane and John nodes to create edge of label KNOWS between them
MATCH (n:Person {name: 'Jane'}), (m:Person {name: 'John'})
CREATE (n)-[e:KNOWS]->(m)

// Commit the changes
COMMIT
In the case you create the nodes then the edges, you need to commit your changes after node creation.