graph-mark-components 运算符(预览版)

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

graph-mark-components 运算符查找图形的所有已连接组件,并使用组件标识符标记每个节点。

注意

此运算符与 生成图形运算符一起使用。

语法

G|graph-mark-components [kind=Kind] [with_component_id=ComponentId]

参数

客户 类型​​ 必需 说明
G 字符串 ✔️ 图形源。
种类 字符串 连接的组件类型 weak(默认值)或 strong。 弱组件是由路径连接的一组节点,忽略边缘的方向。 强组件是在两个方向之间连接的一组节点,考虑边缘的方向。
ComponentId 字符串 表示组件标识符的属性名称。 默认的属性名称为 ComponentId

返回

运算符 graph-mark-components 返回一个图形结果,其中每个节点在 ComponentId 属性中都有一个组件标识符。 标识符是组件从零开始的连续索引。 每个组件索引都是任意选择的,在运行中可能不一致。

示例

以下示例从一组子-父对创建图形,并使用 family 标识符标识连接的组件。

let ChildOf = datatable(child:string, parent:string) 
[ 
  "Alice", "Bob",  
  "Carol", "Alice",  
  "Carol", "Dave",  
  "Greg", "Alice",  
  "Greg", "Dave",  
  "Howard", "Alice",  
  "Howard", "Dave",  
  "Eve", "Frank",  
  "Frank", "Mallory",
  "Eve", "Kirk",
]; 
ChildOf 
| make-graph child --> parent with_node_id=name
| graph-mark-components with_component_id = family
| graph-to-table nodes

输出

姓名 家庭
爱丽丝 0
鲍勃 0
颂歌 0
戴夫 0
格雷格 0
霍华德 0
前夕 1
弗兰克 1
马洛里 1
柯克 1

以下示例使用连接的组件 family 标识符和 graph-match 运算符在一组子-父数据中标识每个系列的最高上级。

let ChildOf = datatable(child:string, parent:string) 
[ 
  "Alice", "Bob",  
  "Carol", "Alice",  
  "Carol", "Dave",  
  "Greg", "Alice",  
  "Greg", "Dave",  
  "Howard", "Alice",  
  "Howard", "Dave",  
  "Eve", "Frank",  
  "Frank", "Mallory",
  "Eve", "Kirk",
]; 
ChildOf 
| make-graph child --> parent with_node_id=name
| graph-mark-components with_component_id = family
| graph-match (descendant)-[childOf*1..5]->(ancestor)
  project name = ancestor.name, lineage = map(childOf, child), family = ancestor.family
| summarize (generations, name) = arg_max(array_length(lineage),name) by family

输出

家庭 代数 姓名
1 2 马洛里
0 2 鲍勃