修改密码

请输入密码
请输入密码 请输入8-64长度密码 和 email 地址不相同 至少包括数字、大写字母、小写字母、半角符号中的 3 个
请输入密码
提交

修改昵称

当前昵称:
提交

申请证书

证书详情

Please complete this required field.

  • Ultipa Graph V4

Standalone

Please complete this required field.

Please complete this required field.

服务器的MAC地址

Please complete this required field.

Please complete this required field.

取消
申请
ID
产品
状态
核数
申请天数
审批时间
过期时间
MAC地址
申请理由
审核信息
关闭
基础信息
  • 用户昵称:
  • 手机号:
  • 公司名称:
  • 公司邮箱:
  • 地区:
  • 语言:
修改密码
申请证书

当前未申请证书.

申请证书
Certificate Issued at Valid until Serial No. File
Serial No. Valid until File

Not having one? Apply now! >>>

ProductName CreateTime ID Price File
ProductName CreateTime ID Price File

No Invoice

v5.0
搜索
    v5.0

      最短路径

      概述

      两点间的最短路径是两点间边数最少的路径。使用以下最短路径选择器可将路径模式匹配的结果限制为最短路径:

      选择器
      描述
      ALL SHORTEST 从每个分区中选择所有最短路径
      SHORTEST k 从每个分区中选择k[1]条最短路径;非确定性选择
      SHORTEST k GROUP[2] 根据路径长度对路径分组,升序排列结果,再从每个分区中选择前k个组中的所有路径;确定性选择

      [1] k为非负整数。若路径数少于k,将保留全部路径。若未设定k,取其默认值1。
      [2] 关键字GROUPGROUPS可以互换使用,不会影响结果。

      最短路径通常从图中两点间的所有可能路径中选择,路径有无长度限制均可。使用带量词的路径模式可以重复路径的某些部分,并指定重复次数的范围,从而探索更多潜在路径。

      GQL暂不支持选择“最低开销”路径(类似于“最短”路径,但最小化了路径的总成本,即边权重)。如需此功能,您可考虑使用UQL的命令ab()autonet()

      最短路径暂不支持子路径变量。

      示例图集

      以下示例根据该图集运行:

      在空图集中运行以下语句创建示例图集:

      INSERT (zenith:City {_id: "Zenith"}),
             (arcadia:City {_id: "Arcadia"}),
             (verona:City {_id: "Verona"}),
             (nebula:City {_id: "Nebula"}),
             (mirage:City {_id: "Mirage"}),
             (lunaria:City {_id: "Lunaria"}),
             (solara:City {_id: "Solara"}),
             (eldoria:City {_id: "Eldoria"}),
             (nexis:City {_id: "Nexis"}),
             (arcadia)-[:Links]->(zenith),
             (arcadia)-[:Links]->(verona),
             (arcadia)-[:Links]->(solara),
             (mirage)-[:Links]->(arcadia),
             (nebula)-[:Links]->(verona),
             (mirage)-[:Links]->(nebula),
             (verona)-[:Links]->(mirage),
             (mirage)-[:Links]->(eldoria),
             (solara)-[:Links]->(eldoria),
             (lunaria)-[:Links]->(solara)
      

      ALL SHORTEST

      使用选择器ALL SHORTEST获取全部最短路径。

      MATCH p = ALL SHORTEST (a)-{,10}(b)
      WHERE a._id = 'Arcadia' AND b._id = 'Eldoria'
      RETURN p
      

      结果:

      p
      (:City {_id: "Arcadia"})<-[:Links]-(:City {_id: "Mirage"})-[:Links]->(:City {_id: "Eldoria"})
      (:City {_id: "Arcadia"})-[:Links]->(:City {_id: "Solara"})-[:Links]->(:City {_id: "Eldoria"})

      SHORTEST k

      使用选择器SHORTEST k获取每个分区中k条最短路径。

      MATCH p = SHORTEST 2 (a:City)-{,10}(b:City)
      WHERE a._id = 'Arcadia' AND b._id = 'Eldoria'
      RETURN p
      

      结果:

      p
      (:City {_id: "Arcadia"})<-[:Links]-(:City {_id: "Mirage"})-[:Links]->(:City {_id: "Eldoria"})
      (:City {_id: "Arcadia"})-[:Links]->(:City {_id: "Solara"})-[:Links]->(:City {_id: "Eldoria"})

      MATCH p = SHORTEST 3 (a:City)-{,10}(b:City)
      WHERE a._id = 'Arcadia' AND b._id = 'Eldoria'
      RETURN p
      

      由于ArcadiaEldoria之间只有2条总长为2的最短路径,因此需要再选择1条第二短的路径。本例中第二短的路径总长为3,且只有1条,因此返回以下3条路径:

      p
      (:City {_id: "Arcadia"})<-[:Links]-(:City {_id: "Mirage"})-[:Links]->(:City {_id: "Eldoria"})
      (:City {_id: "Arcadia"})-[:Links]->(:City {_id: "Solara"})-[:Links]->(:City {_id: "Eldoria"})
      (:City {_id: "Arcadia"})-[:Links]->(:City {_id: "Verona"})-[:Links]->(:City {_id: "Mirage"})-[:Links]->(:City {_id: "Eldoria"})

      SHORTEST k GROUP

      使用选择器SHORTEST k GROUP从每个分区中获得第1短到第k短路径。该选择器根据路径长度对路径分组,升序排列结果,再从每个分区中选择前k个组中的所有路径。

      MATCH p = SHORTEST 3 GROUP (a:City)-[]-+(b:City)
      WHERE a._id = 'Arcadia' AND b._id = 'Eldoria'
      RETURN p
      

      查询返回了2条总长为2的最短路径,1条总长为3的第二短路径,以及1条总长为4的第三短路径:

      p
      (:City {_id: "Arcadia"})<-[:Links]-(:City {_id: "Mirage"})-[:Links]->(:City {_id: "Eldoria"})
      (:City {_id: "Arcadia"})-[:Links]->(:City {_id: "Solara"})-[:Links]->(:City {_id: "Eldoria"})
      (:City {_id: "Arcadia"})-[:Links]->(:City {_id: "Verona"})-[:Links]->(:City {_id: "Mirage"})-[:Links]->(:City {_id: "Eldoria"})
      (:City {_id: "Arcadia"})-[:Links]->(:City {_id: "Verona"})<-[:Links]-(:City {_id: "Nebula"})<-[:Links]-(:City {_id: "Mirage"})-[:Links]->(:City {_id: "Eldoria"})

      分区

      从理论上说,当路径模式匹配到多个起点和终点时,匹配结果根据不同的起始点对进行分区,随后选择器在各分区中选择最短路径。

      本条查询中,首先生成ab的笛卡尔积,随后变量ab在最短路径中被引用,因此共有4条最短路径从4个分区中被选中:

      MMATCH p = SHORTEST 1 (a:City WHERE a._id = 'Zenith' OR a._id = 'Arcadia')-{,10}(b:City WHERE b._id = 'Eldoria' OR b._id = 'Nebula')
      RETURN p
      

      结果:

      p
      (:City {_id: "Zenith"})<-[:Links]-(:City {_id: "Arcadia"})-[:Links]->(:City {_id: "Verona"})<-[:Links]-(:City {_id: "Nebula"})
      (:City {_id: "Zenith"})<-[:Links]-(:City {_id: "Arcadia"})<-[:Links]-(:City {_id: "Mirage"})-[:Links]->(:City {_id: "Eldoria"})
      (:City {_id: "Arcadia"})-[:Links]->(:City {_id: "Verona"})<-[:Links]-(:City {_id: "Nebula"})
      (:City {_id: "Arcadia"})<-[:Links]-(:City {_id: "Mirage"})-[:Links]->(:City {_id: "Eldoria"})

      单起点最短路径

      本条查询获取Arcadia和其他每个城市间的1条最短路径:

      MATCH p = SHORTEST 1 (c1:City {_id: 'Arcadia'})-{,10}(c2:City)
      WHERE c2._id <> c1._id
      RETURN p
      

      在本图里,Arcadia可以到达除Nexis外的7个城市。以下为可能的返回结果:

      p
      (:City {_id: "Arcadia"})-[:Links]->(:City {_id: "Verona"})
      (:City {_id: "Arcadia"})<-[:Links]-(:City {_id: "Mirage"})
      (:City {_id: "Arcadia"})-[:Links]->(:City {_id: "Solara"})
      (:City {_id: "Arcadia"})-[:Links]->(:City {_id: "Zenith"})
      (:City {_id: "Arcadia"})-[:Links]->(:City {_id: "Verona"})<-[:Links]-(:City {_id: "Nebula"})
      (:City {_id: "Arcadia"})<-[:Links]-(:City {_id: "Mirage"})-[:Links]->(:City {_id: "Eldoria"})
      (:City {_id: "Arcadia"})-[:Links]->(:City {_id: "Solara"})<-[:Links]-(:City {_id: "Lunaria"})
      请完成以下信息后可下载此书
      *
      公司名称不能为空
      *
      公司邮箱必须填写
      *
      你的名字必须填写
      *
      你的电话必须填写
      *
      你的电话必须填写