我想找到使用OrientDB的两个节点之间的最短路径。我确实实现了如下:
String s = "select expand( ShortestPath(" + first_vertex.getId() +
", " + second_vertex.getId() + ", "+ direction +") ) ";
仅打印顶点
for (Vertex v : (Iterable<Vertex>) call_shortest_path.g.command(
new OCommandSQL(s)).execute()) {
System.out.println(v.getProperty("name").toString());
}
与neo4j相比,它的工作速度非常慢。有什么改进方法吗?
答案 0 :(得分:0)
尝试以这种方式修改查询:
String s = "select shortestPath(" + first_vertex.getId() + ", " + second_vertex.getId() + ", "+ direction +") unwind shortestPath";
修改强>
这对我有用,虽然我不确定它是否比你的更快:
String s = "select expand (shortestPath) from (select shortestPath(" + first_vertex.getId() + ", " + second_vertex.getId() + ", " + direction + ") unwind shortestPath)";