적용 대상: ✅Microsoft Fabric✅Azure Data Explorer✅Azure Monitor✅Microsoft Sentinel
map() 그래프 함수는 변수 길이 경로를 따라 각 에지 또는 내부 노드 대한 식을 계산하고 모든 결과의 동적 배열을 반환합니다.
통사론
map(*edge*, *expression*)'
에지map(inner_nodes(
매개 변수
| 이름 | 형 | 필수 | 묘사 |
|---|---|---|---|
| 에지 | string |
✔️ | 그래프 일치 연산자 또는 그래프 최단 경로 연산자 패턴의 가변 길이 가장자리입니다. 자세한 내용은 그래프 패턴 표기법참조하세요. |
| 식 | string |
✔️ | inner_nodes 사용할 때 에지 또는 내부 노드 가변 길이 에지대해 수행할 계산입니다. 속성은 속성 이름을 사용하여 직접 참조됩니다. 식은 변수 길이 에지각 에지 또는 내부 노드 대해 평가됩니다. |
반환
다음을 수행할 동적 배열입니다.
- 배열 길이는 가변 길이 에지에서 inner_nodes 사용되는 경우 에지 또는 내부 노드의 수와 일치합니다.
- 길이가 0인 경로의 경우 배열이 비어 있습니다.
- 배열의 각 요소는 변수 길이 가장자리의 각 에지 또는 내부 노드에 식을 적용한 결과에 해당합니다.
예제
이 섹션의 예제에서는 구문을 사용하여 시작하는 방법을 보여 줍니다.
두 역 사이의 가장 짧은 경로에 대한 역과 라인을 찾습니다.
다음 예제에서는 graph-shortest-paths 연산자를 사용하여 운송 네트워크에서 "South-West""North" 스테이션 간의 최단 경로를 찾는 방법을 보여 줍니다.
map() 함수를 사용하여 경로에 선 정보를 추가합니다. 쿼리는 최대 5개의 연결 길이를 고려하여 connections 데이터에서 그래프를 생성합니다.
쿼리 실행
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-shortest-paths (start)-[connections*1..5]->(destination)
where start.station == "South-West" and destination.station == "North"
project from = start.station, path = map(connections, strcat(to_station, " (", line, ")")), to = destination.station
출력
| 보낸 사람 | 길 | 받는 사람 |
|---|---|---|
| 남서부 | [ "남쪽(빨간색)", "Central(빨간색)", "북쪽(빨간색)" ] |
북쪽 |
두 스테이션 사이의 모든 경로에서 Wi-Fi 있는 스톱오버 목록 가져오기
다음 예제에서는 graph-match 및 all() 함수와 함께 inner_nodes 연산자를 사용하여 운송 네트워크의 두 스테이션 사이의 모든 경로를 따라 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-match cycles=none (start)-[connections*1..5]->(destination)
where start.station == "South-West" and destination.station == "East"
project stopovers = strcat_array(map(inner_nodes(connections), station), "->"),
stopovers_with_wifi = set_intersect(map(inner_nodes(connections), station), map(inner_nodes(connections), iff(wifi, station, "")))
출력
| 스톱 오버 | stopovers_with_wifi |
|---|---|
| 웨스트>센트럴 | [ "West", "Central"] |
| 사우스>센트럴 | [ "Central"] |
관련 콘텐츠
- 그래프 연산자
- 그래프 일치 연산자
- 그래프 최단 경로 연산자
- inner_nodes()