buildEdgeCountVariable.php
Table of Contents
Functions
- buildEdgeCountVariable() : string|null
- Generates a string of multiple AQL 'LET' statements for calculate the number of edges of a specific document.
Functions
buildEdgeCountVariable()
Generates a string of multiple AQL 'LET' statements for calculate the number of edges of a specific document.
buildEdgeCountVariable(string|null $name[, array<string|int, mixed> $definition = [] ][, string $startVertex = AQL::DOC ][, ContainerInterface|null $container = null ]) : string|null
The count must answer the same question as the list. A count and a
Filter::EDGES projection normally share one definition — the registry's string
shortcut ('descendantsCount' => 'descendants') is the idiomatic way to say so —
therefore every part of that declaration shaping which vertices are walked has
to be read here exactly as buildEdgeSubquery() reads it. Three did not use
to be, each producing a number the rows contradicted:
| Declaration | List | Count, before |
|---|---|---|
AQL::MAX_DEPTH => 5 over a ─┬─ b ── c / └─ e ── f |
[ b , c , e , f ] → 4 |
2 (direct children only) |
depth 1 with a duplicated a → c edge |
[ b , c ] → 2 |
3 (counted twice) |
1..5 over the diamond a → b → d / a → c → d |
[ b , c , d ] → 3 |
6 |
All three are now read through the shared helpers — resolveEdgeDepthRange(),
resolveEdgeVertexScope() and edgeTraversalOptions() — so the count
and the list cannot drift again. AQL::WHERE filters the counted loop and
AQL::PRUNE stops it, both compiled against the inner vertex.
Nothing is emitted for a key that is not declared, so a definition without depth, scope or prune produces the historical single-level count — plus the traversal options, which is the one intentional change to the emitted AQL of an existing definition (and the one that makes a duplicated edge stop being counted twice).
Parameters
- $name : string|null
- $definition : array<string|int, mixed> = []
- $startVertex : string = AQL::DOC
- $container : ContainerInterface|null = null