適用対象: ✅Microsoft Fabric✅Azure データ エクスプローラー✅Azure Monitor✅Microsoft Sentinel
map()
グラフ関数は、可変長パスに沿ってエッジまたは内部ノードごとに式を計算し、すべての結果の動的配列を返します。
構文
map
(*edge*
, *expression*
)'
map(inner_nodes(
edge),
表現)
パラメーター
名前 | タイプ | 必須 | 説明 |
---|---|---|---|
端 | string |
✔️ | グラフ一致演算子またはグラフ最短パス演算子パターンからの可変長エッジ。 詳細については、「 グラフ パターン表記」を参照してください。 |
式 | string |
✔️ | inner_nodesを使用する場合に、可変長エッジでエッジまたは内部ノードのプロパティに対して実行する計算。 プロパティは、プロパティ名を使用して直接参照されます。 式は、可変長エッジ内のエッジまたは内部ノードごとに評価されます。 |
返品ポリシー
次の動的配列。
- 配列の長さは、可変長エッジで 、inner_nodes を使用する場合のエッジまたは内部ノードの数と一致します。
- 長さ 0 のパスの場合、配列は空です。
- 配列内の各要素は、可変長エッジの各エッジまたは内部ノードに 式 を適用した結果に対応します。
例示
このセクションの例では、構文を使用して作業を開始する方法を示します。
2 つのステーション間の最短ルートの駅と線を検索する
次の例は、 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
アウトプット
〜から | 道 | 送信先 |
---|---|---|
South-West | [ "South (red)", "Central (red)", "North (red)" ] |
北 |
2 つのステーション間のすべてのルートで Wi-Fi を含むストップオーバーの一覧を取得する
次の例では、 graph-match
演算子と all()
関数と inner_nodes
関数を使用して、輸送ネットワーク内の 2 つのステーション間のすべてのルートに沿って 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 | [ "West", "Central"] |
South->Central | [ "Central"] |