【问题标题】:OrientDB: Edges in shortestPathOrientDB:最短路径中的边
【发布时间】:2015-04-05 10:20:32
【问题描述】:

我的图表如下所示:

A --1--> B --2--> C --3--> D

|
4
|
V

E

我想获得从 A 到 D 的最短路径。但我不需要顶点,而是构成路径的边。

来自here 我最终得到:

 select expand(shortestPath) from (select shortestPath(A, D).outE())

但结果不仅包含正确的答案 1、2、3,还包含 4,因此构成路径的顶点的所有出边。

  • 我怎样才能只得到构成最短路径的边?
  • 如果有几条最短路径,我怎样才能获得所有路径?

如果我可以选择最短路径或 dijkstra 作为遍历策略,那就太酷了。国际海事组织这是他们所属的地方。

【问题讨论】:

    标签: graph-theory orientdb shortest-path


    【解决方案1】:

    OrientDB 已经有 dijkstra 功能。但是只过滤边缘:

    select from (select expand( shortestPath(A, D) ) ) where @this instanceof 'E'
    

    【讨论】:

    • 按照您的建议进行扩展会返回 0 条记录。像这样的扩展有效:select from (select expand(shortestPath) from (select shortestPath(#13:0, #13:2))) where @this instanceof 'E' 但是使用 where 子句它返回 0 条记录。我正在使用orientdb-community-2.0-rc1,但这不重要吗?!
    • 使用 2.1.7-SNAPSHOT,select expand(shortestpath(...)) 只返回顶点。
    • @pat 是对的,A 和 D 应该替换为节点 ID,如 pat 回复。 tnx
    猜你喜欢
    • 1970-01-01
    • 2011-07-19
    • 1970-01-01
    • 1970-01-01
    • 2012-12-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-06-24
    相关资源
    最近更新 更多