그래프 함수는 all()변수 길이 경로를 따라 각 에지 또는 내부 노드에 대한 조건을 평가합니다.
문법
all(
가장자리,조건)
all(inner_nodes(
가장자리),조건)
매개 변수
| 이름 | 유형 | 필수 | 설명 |
|---|---|---|---|
| 에지 | string |
✔️ | 그래프 일치 연산자 또는 그래프 최단 경로 연산자 패턴의 가변 길이 가장자리입니다. 자세한 내용은 그래프 패턴 표기법참조하세요. |
| 조건 | string |
✔️ | 가변 길이 에지에서 inner_nodes 사용되는 경우 에지 또는 내부 노드의 속성으로 구성된 부울 식입니다. 속성은 속성 이름을 사용하여 직접 참조됩니다. 식은 변수 길이 에지각 에지 또는 내부 노드 대해 평가됩니다. |
반품
변수 true지에서 true 사용되는 경우 각 에지 또는 내부 노드에 대해 조건이 계산 되는지 여부를 반환 합니다. 그 외의 경우 false를 반환합니다.
길이가 0인 경로의 경우 조건은 .로 true계산됩니다.
예시
다음 예제에서는 함수와 함께 graph-match 연산자를 all() 사용하여 운송 네트워크의 두 스테이션 간에 모든 왕복 경로를 찾는 방법을 보여 줍니다. 각 방향에 대해 다른 선을 사용합니다. 쿼리는 데이터에서 connections 그래프를 생성하여 바깥쪽 경로에 대한 선을 사용하는 "red" 최대 5개의 연결과 반환 경로의 "blue" 줄을 찾는 모든 경로를 찾습니다. 이 함수는 all() 가변 길이 에지의 모든 가장자리가 같은 선 중 하나 "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
출력
| 보낸 사람 | outward_stations | 에게 | return_stations | 뒤로 |
|---|---|---|---|---|
| 중심적인 | 중남>>부South-West> | 서쪽 | 중심적인 | |
| 서쪽 | 남서->남-중->>북 | 중심적인 | 서쪽 | |
| 중심적인 | 남->South-West | 서쪽 | 중심적인 | |
| 서쪽 | 남서남부> | 중심적인 | 서쪽 | |
| 중심적인 | 중남>>부South-West> | 서쪽 | 중부 동부> | 중심적인 |
| 서쪽 | 남서->남-중->>북 | 중심적인 | 동중>앙 | 서쪽 |
| 중심적인 | 남->South-West | 서쪽 | 중부 동부> | 중심적인 |
| 서쪽 | 남서남부> | 중심적인 | 동중>앙 | 서쪽 |
다음 예제에서는 연산자와 graph-shortest-pathsall() 함수를 inner_nodes 사용하여 운송 네트워크에서 두 스테이션 사이의 경로를 찾는 방법을 보여 줍니다. 쿼리는 데이터에서 그래프를 생성하고 스테이션에서 connections"South-West" 스테이션까지 "North" 의 가장 짧은 경로를 찾아 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-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
출력
| 보낸 사람 | 방송국 | 에게 |
|---|---|---|
| 남서부 | 웨스트>센트럴 | 북쪽 |
관련 콘텐츠
- 그래프 연산자
- 그래프 일치 연산자
- 그래프 최단 경로 연산자
- inner_nodes()