cypher - neo4j shortest with connector node and multiple options -


i have cities, roads , transporters in database. road connected , relationship 2 (different) cities. each road has property distance (in kilometers). multiple transporters have relationship roads. every transporter has price (per kilometer).

now question. want cheapest option packet city b. there direct road or else have go via other cities , transporters. , want explicitly use dijkstra algorithm this.

can query done in cypher? , if not, how can done using neo4j java api?

based on sample dataset, think there modelisation problem makes maybe things difficult, matching on directed relationships.

however how can find lowest cost path :

match (a:city { name:'citya' }),(d:city { name:'cityd' }) match p=(a)-[*]-(d) p, filter(x in nodes(p)                 'road' in labels(x)) roads p, reduce(dist = 0, x in roads | dist + x.distance) totaldistance return p, totaldistance order totaldistance limit 5 

Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -