all() (grafiekfunctie)

Schakelen tussen services met behulp van de vervolgkeuzelijst Versie . Meer informatie over navigatie.
Van toepassing op: ✅ Microsoft Fabric ✅ Azure Data Explorer ✅ Azure Monitor ✅ Microsoft Sentinel

De all() grafiekfunctie evalueert een voorwaarde voor elk edge - of binnenknooppunt langs een pad met de lengte van een variabele .

Opmerking

Deze functie wordt gebruikt met de graph-match en graph-shortest-paths operators.

Syntaxis

all( rand,conditie)

all(inner_nodes( rand),conditie)

Parameterwaarden

Naam Typologie Verplicht Beschrijving
edge- string ✔️ Een variabele lengterand van de operator voor grafiekovereenkomst of operator voor kortste paden patroon. Zie Graph-patroon notatievoor meer informatie.
voorwaarde string ✔️ Een Boole-expressie die bestaat uit eigenschappen van de rand of het binnenste knooppunt, wanneer inner_nodes wordt gebruikt, in de rand met de lengte van de variabele. Er wordt rechtstreeks naar een eigenschap verwezen met behulp van de naam van de eigenschap. De expressie wordt geëvalueerd voor elke edge- of binnenste knooppunt in de rand van de variabele lengte.

Retouren

Retourneert true of de voorwaarde voor true elk edge - of binnenknooppunt wordt geëvalueerd, wanneer inner_nodes wordt gebruikt, in de rand met de lengte van de variabele. Anders retourneert het false.

Voor paden met lengte nul wordt de voorwaarde geëvalueerd true.

Voorbeelden

In het volgende voorbeeld ziet u hoe u de graph-match operator gebruikt met de all() functie om alle retourpaden tussen twee stations in een transportnetwerk te vinden. Voor elke richting wordt een andere lijn gebruikt. De query maakt een grafiek van de connections gegevens, zoekt alle paden tot vijf verbindingen lang die gebruikmaken van de lijn voor de "red" uitgaande route en de "blue" lijn voor de retourroute. De all() functie zorgt ervoor dat alle randen in de rand van de variabele lengte deel uitmaken van dezelfde lijn, ofwel "red""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

Uitvoer

van outward_stations naar return_stations Terug
Centraal Noord-centraal-zuid>>->South-West Westen Centraal
Westen Zuid-West-Zuid-Centraal-Noord>>> Centraal Westen
Centraal Zuid->South-West Westen Centraal
Westen Zuid-West-Zuid> Centraal Westen
Centraal Noord-centraal-zuid>>->South-West Westen Centraal-Oost> Centraal
Westen Zuid-West-Zuid-Centraal-Noord>>> Centraal Oost-centraal> Westen
Centraal Zuid->South-West Westen Centraal-Oost> Centraal
Westen Zuid-West-Zuid> Centraal Oost-centraal> Westen

In het volgende voorbeeld ziet u hoe u de graph-shortest-paths operator gebruikt met de all() en inner_nodes functies om een pad tussen twee stations in een transportnetwerk te vinden. Met de query wordt een grafiek gemaakt van de connections gegevens en wordt het kortste pad van het "South-West" station naar het "North" station gevonden, waarbij de stations worden doorgegeven waar Wi-Fi beschikbaar is.

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

Uitvoer

van Stations naar
South-West West->- centraal Noorden