Find possible paths in a graph using neo4j -


disclaimer: i'm beginner graph data modeling, help, tips or guidance appreciated. forgive lack of knowledge.

10 thousand feat idea able translate texts 1 language in quality level.

i have following domain models:

  • an activity (aka. activity)
  • a source language (aka. language_from)
  • a destination language (aka. language_to)
  • a quality level (aka. level)

i have modeled following graph allow user ask translation x y quality level z.

enter image description here

now let's user wants translate en-us de-de. there no links between 2 nodes because business not allow path domain reasons.

however possible achieve such translation going through en-us->fr-fr fr-fr->de-de.

my questions are:

  1. is above graph model appropriate such query?
  2. what query using neo4j cyphers?

any tips me on right track appreciated.

i think can model data in more straight-forward way.

you use language nodes directly connected translate relationships level property on relationship. it's simpler, directly maps domain problem , don't need other nodes query.

(language {name: 'de-de'})-[:translate {level: 7}]->(language {name: 'fr-fr'}) 

a variable length query finds translations through mulitple languages:

match path=(lang:languag {name: 'de-de'})-[:translate*1..3]-(other_lang:language {name: 'en-us'}) return nodes(path) 

here filter level:

match path=(lang:languag {name: 'de-de'})-[:translate*1..3]-(other_lang:language {name: 'en-us'}) all(x in relationships(path) x.level > 5) return nodes(path) 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -