node_degree_out(图函数)

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

node_degree_out 函数从定向图中的节点计算出 或传出边缘数。

注释

此函数用于 graph-matchgraph-shortest-paths 运算符。

语法

node_degree_out( 节点)

详细了解 语法约定。

参数

名字 类型 必填 说明
节点 string ✔️ 对图形模式中图形节点变量的引用。

退货

返回输入节点的输出度。

例子

本节中的示例演示如何使用语法帮助你入门。

查找位置和运输模式之间的路径

以下示例使用 LocationsRoutes 数据表构造一个图形,该图通过 route查找从源位置到目标位置的路径。 它返回源位置名称、目标位置名称、运输方法和 node_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]->(dest)
project src.LocationName, dest.LocationName, route.TransportMode, node_degree_out(src)

输出

src_LocationName dest_LocationName route_TransportMode node_degree_out
纽约 旧金山 卡车 2
纽约 芝加哥 火车 2
旧金山 洛杉矶 卡车 1
芝加哥 西雅图 火车 1
洛杉矶 纽约 卡车 1
西雅图 旧金山 火车 1

查找没有经理的员工

以下示例创建一个关系图来表示员工与其经理之间的分层关系。 它使用 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
吉姆 Alice 1 0