修改密码

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

修改昵称

当前昵称:
提交

申请证书

证书详情

Please complete this required field.

  • Ultipa Blaze (v4)

Standalone

Please complete this required field.

Please complete this required field.

Please complete this required field.

Please complete this required field.

如果不需要 HDC 服务,则此项留空。

Please complete this required field.

如果不需要 HDC 服务,则此项留空。

Please complete this required field.

Please complete this required field.

所有服务器的MAC地址,由换行符或逗号分隔。

Please complete this required field.

Please complete this required field.

取消
申请
ID
产品
状态
核数
Shard 服务最大数量
Shard 服务最大总核数
HDC 服务最大数量
HDC 服务最大总核数
申请天数
审批日期
过期日期
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

      展开

      概述

      使用语句spread().src().depth()可以执行广度优先搜索,从每个遍历起点向外展开,逐层获取一步路径,随着路径逐步加深,向邻居点扩展。

      这就是从遍历起点(上图中的红色节点)逐层展开的过程。在第k步:

      • 识别遍历起点的k-1步邻居(k = 1时对应遍历起点)与k步邻居之间的一步路径。
      • 与此同时,发现k步邻居之间的一步路径,包括k步邻居的自环路径。
      • 特别注意,遍历起点的自环路径被识别为第一步路径。

      语法

      spread().src(<filter?>).depth(<steps>)
      
      • 语句别名:类型为PATH
      • 方法:
      方法
      参数
      描述
      可选
      别名类型
      src() <filter?> 将过滤条件包裹在{}中,或使用别名指定遍历的起点集。 留空时会作用在所有点上 NODE
      depth() <steps> 展开的最大深度(≥1) N/A
      node_filter() <filter?> 将过滤条件包裹在{}中,对路径中除遍历起点外的所有点生效。留空则不应用任何过滤条件 N/A
      edge_filter() <filter?> 将针对路径中边的过滤条件包裹在{}中。留空则不应用任何过滤条件 N/A
      direction() <leftRight> 指定向外展开时,路径中边的方向,可以为leftright N/A
      limit() <N> 限制每个遍历起点返回的路径数量(N≥-1);-1表示返回所有路径 N/A

      示例图集

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

      create().edge_property(@default, "weight", int32)
      insert().into(@default).nodes([{_id:"A"}, {_id:"B"}, {_id:"C"}, {_id:"D"}, {_id:"E"}, {_id:"F"}, {_id:"G"}])
      insert().into(@default).edges([{_from:"A", _to:"C", weight:1}, {_from:"E", _to:"B", weight:1}, {_from:"A", _to:"E", weight:4}, {_from:"D", _to:"C", weight:2}, {_from:"E", _to:"D", weight:3}, {_from:"B", _to:"A", weight:2}, {_from:"F", _to:"A", weight:4}])
      

      从点展开

      从点B展开1步:

      spread().src({_id == "B"}).depth(1) as p
      return p
      

      结果:p

      从点B展开2步:

      spread().src({_id == "B"}).depth(2) as p
      return p
      

      结果:p

      过滤邻居点

      从点D展开2步,同时不经过点E

      spread().src({_id == "D"}).depth(2).node_filter({_id != "E"}) as p
      return p
      

      结果:p

      不经过点E意味着从图中移除点E和与其相连的边。

      过滤边

      分别从点A和点B展开2步,同时仅经过边属性weight大于1的边:

      spread().src({_id in ["A", "B"]}).depth(2).edge_filter({weight > 1}) as p
      return p
      

      结果:p

      排除属性weight不超过1的边,相当于将这些边从图中移除。

      设置边方向

      从点B沿出向边展开2步:

      spread().src({_id == "B"}).depth(2).direction(right) as p
      return p
      

      结果:p

      从点B沿入向边展开2步:

      spread().src({_id == "B"}).depth(2).direction(left) as p
      return p
      

      结果:p

      虽然语句spread()返回的结果为出向一步路径格式,但direction()方法限制了从当前点向外查询的方向。

      限制查询数量

      分别从点A和点B展开2步,且每个遍历起点仅返回2条路径:

      spread().src({_id in ["A", "D"]}).depth(2).limit(2) as p
      return p
      

      结果:p

      基于广度优先搜索的特性,展开过程中,优先返回浅层路径。

      使用OPTIONAL

      本条查询中,spread()语句执行两次,每次使用n中的一条记录。使用OPTIONAL前缀后,如果没有查询到数据,则返回null

      find().nodes({_id in ["F", "G"]}) as n
      OPTIONAL spread().src(n).depth(1) as p
      return p
      

      结果:p

      若不使用OPTIONAL前缀,则仅返回一条结果:

      find().nodes({_id in ["F", "G"]}) as n
      spread().src(n).depth(1) as p
      return p
      

      结果:p

      请完成以下信息后可下载此书
      *
      公司名称不能为空
      *
      公司邮箱必须填写
      *
      你的名字必须填写
      *
      你的电话必须填写
      *
      你的电话必须填写