mercredi 16 septembre 2015

Write a Cypher query to CREATE links between random nodes

To seed a database, I would like to create a small set of Person nodes...

WITH ["Amy","Bob","Cal","Dan","Eve"]
AS names
FOREACH (r IN range(0, size(names)-1) |
  CREATE (:Person {name: names[r]})
)

... and I would like to create a random connection for each Person. Is it possible to do this in a single query?

I imagine that I would need to add each new Person to a collection, and work with a variable created from FLOOR(RAND() * size(names)), but the official documentation does not give many clues as to how to do this.




Aucun commentaire:

Enregistrer un commentaire