简体   繁体   中英

Shortest path with ArangoDB & Java

I read in the documentation that ArangoDB is migrating functions from AQL to native. I was trying the shortest path example :

ArangoDB arangoDB = new ArangoDB.Builder().build();
ArangoGraph g = arangoDB.db().graph("routeplanner");

Can I continue implementing without using AQL like in the shell example? How can I do?

PS: Are edges bidirectional? Can I go from Cologne to Hamburg ?

The graph functions are only accessible over the arango shell or foxx services. They aren't provided by the HTTP API which is used by the Java driver.

When using the Java driver (or any other driver) you have to use AQL for shortest path or other graph functionality from the docs .

Edges in ArangoDB are always directional (an edge document always has the fields "_from", "_to") but you can define the direction edges are followed in the query within it (see docs ).

FOR v, e
  IN ANY SHORTEST_PATH
  'germanCity/Cologne' TO 'germanCity/Hamburg'
  GRAPH 'routeplanner'
  OPTIONS {weightAttribute:'distance'}
  RETURN [v._key, e._key]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM