Compartir a través de


all() (función graph)

Se aplica a: ✅Microsoft FabricAzure Data Explorer✅Azure MonitorMicrosoft Sentinel

La all() función de grafo evalúa una condición para cada borde o nodo interno a lo largo de una ruta de acceso de longitud variable .

Nota:

Esta función se usa con los operadores graph-match y graph-shortest-paths .

Sintaxis

all( borde,condición)

all(inner_nodes( borde),condición)

Parámetros

Nombre Tipo Obligatorio Descripción
borde string ✔️ Borde de longitud variable desde el operador graph-match o el patrón de operador graph-shortest-paths . Para obtener más información, consulte Notación de patrones de graph.
condición string ✔️ Expresión booleana compuesta de propiedades del nodo perimetral o interno, cuando se usa inner_nodes , en el borde de longitud variable. Se hace referencia a una propiedad mediante el nombre de propiedad directamente. La expresión se evalúa para cada borde o nodo interno en el borde de longitud variable.

Devoluciones

Devuelve true si la condición se evalúa como true para cada borde o nodo interno, cuando se usa inner_nodes , en el borde de longitud variable. En caso contrario, devuelve false.

Para rutas de acceso de longitud cero, la condición se evalúa como true.

Ejemplos

En el ejemplo siguiente se muestra cómo usar el graph-match operador con la all() función para buscar todas las rutas de ida y vuelta entre dos estaciones en una red de transporte. Usa una línea diferente para cada dirección. La consulta construye un gráfico a partir de los connections datos, buscando todas las rutas de acceso hasta cinco conexiones largas que usan la "red" línea para la ruta saliente y la "blue" línea de la ruta de retorno. La all() función garantiza que todos los bordes del borde de longitud variable formen parte de la misma línea, ya sea "red" o "blue".

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-match (start)-[outward*1..5]->(destination)-[return*1..5]->(start)
  where start.station != destination.station and 
        all(outward, line == "red") and
        all(return, line == "blue") 
  project from = start.station, 
          outward_stations = strcat_array(map(inner_nodes(outward), station), "->"), 
          to = destination.station, 
          return_stations = strcat_array(map(inner_nodes(return), station), "->"), 
          back=start.station

Salida

desde outward_stations Para return_stations Atrás
Central Centro-norte-sur>>->South-West Oeste Central
Oeste Sur-Oeste-Sur-Centro-Norte>>> Central Oeste
Central Sur->South-West Oeste Central
Oeste Sur-Oeste-Sur> Central Oeste
Central Centro-norte-sur>>->South-West Oeste Centro-este> Central
Oeste Sur-Oeste-Sur-Centro-Norte>>> Central Centro-este> Oeste
Central Sur->South-West Oeste Centro-este> Central
Oeste Sur-Oeste-Sur> Central Centro-este> Oeste

En el ejemplo siguiente se muestra cómo usar el graph-shortest-paths operador con las all() funciones y inner_nodes para buscar una ruta de acceso entre dos estaciones de una red de transporte. La consulta construye un gráfico a partir de los connections datos y encuentra la ruta más corta de la "South-West" estación a la "North" estación, pasando por estaciones donde Wi-Fi está disponible.

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-shortest-paths (start)-[connections*2..5]->(destination)
  where start.station == "South-West" and
        destination.station == "North" and 
        all(inner_nodes(connections), wifi)
  project from = start.station, 
          stations = strcat_array(map(inner_nodes(connections), station), "->"), 
          to = destination.station

Salida

desde Estaciones Para
Suroeste Centro-oeste> Norte