你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
node_degree_out
函数从定向图中的节点计算出 度或传出边缘数。
注释
此函数用于 graph-match
和 graph-shortest-paths
运算符。
语法
node_degree_out([
节点])
详细了解语法约定。
参数
名字 | 类型 | 必选 | 说明 |
---|---|---|---|
节点 | string |
✔️ | 对图形模式中图形节点变量的引用。 在 all()、 any() 和 map() 图形函数与 inner_nodes() 结合使用时,不应传递任何参数。 |
退货
返回输入节点或所有内部节点的外度,当在 all()、 any() 和 map() 函数与 inner_nodes() 结合使用时。
例子
本节中的示例演示如何使用语法帮助你入门。
查找位置和运输模式之间的路径
以下示例使用 Locations
和 Routes
数据表构造一个图形,该图通过 route
查找从源位置到目标位置的路径。 它返回源位置名称、目标位置名称、沿路线的运输方法, node_degree_out
即源节点(位置)的传出边缘数,以及 route_nodes_degree_out
来自路线内部节点(停止位置)的传出边缘数。
// Locations table (nodes)
let Locations = datatable(LocationName: string, LocationType: string) [
"New York", "City",
"San Francisco", "City",
"Chicago", "City",
"Los Angeles", "City",
"Seattle", "Warehouse"
];
// Routes table (edges)
let Routes = datatable(OriginLocationID: string, DestinationLocationID: string, TransportMode: string) [
"New York", "San Francisco", "Truck",
"New York", "Chicago", "Train",
"San Francisco", "Los Angeles", "Truck",
"Chicago", "Seattle", "Train",
"Los Angeles", "New York", "Truck",
"Seattle", "San Francisco", "Train"
];
Routes
| make-graph OriginLocationID --> DestinationLocationID with Locations on LocationName
| graph-match (src)-[route*1..2]->(dest)
project src.LocationName,
dest.LocationName,
node_degree_out(src),
route_TransportModes = map(route, TransportMode),
route_nodes_degree_out = map(inner_nodes(route), node_degree_out())
输出
src_LocationName | dest_LocationName | node_degree_out | route_TransportModes | route_nodes_degree_out |
---|---|---|---|---|
芝加哥 | 西雅图 | 1 | [“Train”] | [] |
纽约 | 芝加哥 | 2 | [“Train”] | [] |
洛杉矶 | 纽约 | 1 | [“卡车”] | [] |
旧金山 | 洛杉矶 | 1 | [“卡车”] | [] |
西雅图 | 旧金山 | 1 | [“Train”] | [] |
纽约 | 旧金山 | 2 | [“卡车”] | [] |
芝加哥 | 旧金山 | 1 | [“Train”,“Train”] | [1] |
纽约 | 西雅图 | 2 | [“Train”,“Train”] | [1] |
纽约 | 洛杉矶 | 2 | [“卡车”,“卡车”] | [1] |
旧金山 | 纽约 | 1 | [“卡车”,“卡车”] | [1] |
西雅图 | 洛杉矶 | 1 | [“Train”,“Truck”] | [1] |
洛杉矶 | 旧金山 | 1 | [“卡车”,“卡车”] | [2] |
洛杉矶 | 芝加哥 | 1 | [“卡车”,“火车”] | [2] |
查找没有经理的员工
以下示例创建一个关系图来表示员工与其经理之间的分层关系。 它使用 graph-match
作员查找向不向其他人报告的高级经理的员工。 它使用 node_degree_out
函数来标识不向任何其他经理报告的经理。
let employees = datatable(name:string, age:long)
[
"Alice", 32,
"Bob", 31,
"Eve", 27,
"Joe", 29,
"Chris", 45,
"Alex", 35,
"Ben", 23,
"Richard", 39,
"Jim", 42,
];
let reports = datatable(employee:string, manager:string)
[
"Bob", "Alice",
"Chris", "Alice",
"Eve", "Bob",
"Ben", "Chris",
"Joe", "Alice",
"Richard", "Bob",
"Alice", "Jim"
];
reports
| make-graph employee --> manager with employees on name
| graph-match (manager)<-[reports]-(employee)
where node_degree_out(manager) == 0
project manager.name, employee.name, di_m=node_degree_in(manager), do_m=node_degree_out(manager), di_e=node_degree_in(employee), do_e=node_degree_out(employee)
输出
manager_name | employee_name | degree_in_m | degree_out_m |
---|---|---|---|
吉姆 | 爱丽丝 | 1 | 0 |