all(图函数)

适用于:✅Azure 数据资源管理器Azure MonitorMicrosoft Sentinel

图形all()函数计算沿可变长度路径的每个边缘内部节点的条件。

注释

此函数与 图形匹配图形最短路径 运算符一起使用。

语法

all( 边缘,条件)

all(inner_nodes( 边缘),条件)

参数

名称 类型 必选 DESCRIPTION
边缘 string ✔️ 图形匹配运算符图形最短路径运算符 模式中的可变长度边缘。 有关详细信息,请参阅 图形模式表示法
条件 string ✔️ 可变长度边缘中使用inner_nodes时,由边缘内部节点的属性组成的布尔表达式。 直接使用属性名称引用属性。 为 可变长度边缘中的每个 边缘内部节点 计算表达式。

退货

如果true条件在true中使用inner_nodes时计算结果为每个边缘内部节点。 否则,它将返回 false

对于零长度路径,条件的计算结果为 true

例子

以下示例演示如何将 graph-match 作员与函数一起使用 all() ,以查找交通网络中两个车站之间的所有往返路径。 它为每个方向使用不同的线条。 查询从 connections 数据构造一个图形,查找长度为五个连接的所有路径,这些连接 "red" 长度为向外路由的行,以及返回路由的 "blue" 线条。 该all()函数可确保可变长度边缘中的所有边缘都属于同一行或"red""blue"同一行。

let connections = datatable(from_station:string, to_station:string, line:string) 
[ 
  "Central", "North", "red",
  "North", "Central", "red", 
  "Central", "South",  "red", 
  "South", "Central",  "red", 
  "South", "South-West", "red", 
  "South-West", "South", "red", 
  "South-West", "West", "red", 
  "West", "South-West", "red", 
  "Central", "East", "blue", 
  "East", "Central", "blue", 
  "Central", "West", "blue",
  "West", "Central", "blue",
]; 
connections 
| make-graph from_station --> to_station with_node_id=station
| graph-match (start)-[outward*1..5]->(destination)-[return*1..5]->(start)
  where start.station != destination.station and 
        all(outward, line == "red") and
        all(return, line == "blue") 
  project from = start.station, 
          outward_stations = strcat_array(map(inner_nodes(outward), station), "->"), 
          to = destination.station, 
          return_stations = strcat_array(map(inner_nodes(return), station), "->"), 
          back=start.station

输出

outward_stations return_stations 返回
中央 南北->>>South-West 西部 中央
西部 西南->西南->中>北部 中央 西部
中央 南South-West> 西部 中央
西部 西南->南 中央 西部
中央 南北->>>South-West 西部 >中东部 中央
西部 西南->西南->中>北部 中央 东->中 西部
中央 南South-West> 西部 >中东部 中央
西部 西南->南 中央 东->中 西部

以下示例演示如何将作员与函数graph-shortest-pathsall()起使用inner_nodes,以查找交通网络中两个车站之间的路径。 该查询从connections数据构造一个图形,并查找从工作站到"South-West"工作站的最短路径"North",通过 Wi-Fi 可用的工作站。

let connections = datatable(from_station:string, to_station:string, line:string) 
[ 
  "Central", "North", "red",
  "North", "Central", "red", 
  "Central", "South",  "red", 
  "South", "Central",  "red", 
  "South", "South-West", "red", 
  "South-West", "South", "red", 
  "South-West", "West", "red", 
  "West", "South-West", "red", 
  "Central", "East", "blue", 
  "East", "Central", "blue", 
  "Central", "West", "blue",
  "West", "Central", "blue",
]; 
let stations = datatable(station:string, wifi: bool) 
[ 
  "Central", true,
  "North", false,
  "South", false,
  "South-West", true,
  "West", true,
  "East", false
];
connections 
| make-graph from_station --> to_station with stations on station
| graph-shortest-paths (start)-[connections*2..5]->(destination)
  where start.station == "South-West" and
        destination.station == "North" and 
        all(inner_nodes(connections), wifi)
  project from = start.station, 
          stations = strcat_array(map(inner_nodes(connections), station), "->"), 
          to = destination.station

输出

South-West 中西部-> 北部