mardi 26 décembre 2017

neo4j get random path from known node

I have a big neo4j db with info about celebs, all of them have relations with many others, they are linked, dated, married to each other. So I need to get random path from one celeb with defined count of relations (5). I don't care who will be in this chain, the only condition I have I shouldn't have repeated celebs in chain.

To be more clear: I need to get "new" chain after each query, for example:

  • I try to get chain started with Rita Ora
  • She has relations with Drake, Jay Z and Justin Bieber
  • Query takes random from these guys, for example Jay Z
  • Then Query takes relations of Jay Z: Karrine Steffans, Rosario Dawson and Rita Ora
  • Query can't take Rita Ora cuz she is already in chain, so it takes random from others two, for example Rosario Dawson
  • ...
  • And at the end we should have a chain Rita Ora - Jay Z - Rosario Dawson - other celeb - other celeb 2

Is that possible to do it by query?




Aucun commentaire:

Enregistrer un commentaire