MinAgg¶
A MinAgg aggregator value variable (MinAgg<T>) maintains the minimum value among all inputs, where T represents the data type of the input values. To maintain the maximum value, see MaxAgg.
Declaration syntax¶
- min_agg_declaration
min_agg_declaration ::=
'NODE'? 'VALUE' aggregator_value_variable 'MinAgg' '<' ('INT8'|'INT16'|'INT32'|'INT64'|'FLOAT'|'DOUBLE'|'STRING') '>' '=' value_expression
For information about the parameters in the declaration syntax, see Parameters.
Initial value¶
As indicated in the declaration syntax, an initial value is required during declaration.
Input type and supported operations¶
The input type must be T, which is specified during declaration.
Both assignment and aggregation operations are supported.
Return type¶
MinAgg<T> -> T
The return type is the same as the type T specified during declaration.
Examples¶
The following examples are based on the temporary graph #movie_temporary_graph created in CREATE TEMPORARY GRAPH.
Global MinAgg aggregator value variables¶
'''
USE #movie_temporary_graph {
VALUE global_min_int MinAgg<INT> = 100
VALUE global_min_double MinAgg<DOUBLE> = 100.0
VALUE global_min_string MinAgg<STRING> = "zzz"
// INT type: Get the minimum integer value
SET @global_min_int += 30 // min: 30 (30 < 100, updates to 30)
SET @global_min_int += 10 // min: 10 (10 < 30, updates to 10)
SET @global_min_int += 50 // min: 10 (50 > 10, keeps 10)
// DOUBLE type: Get the minimum floating-point value
SET @global_min_double += 35.5 // min: 35.5 (35.5 < 100.0, updates to 35.5)
SET @global_min_double += 12.8 // min: 12.8 (12.8 < 35.5, updates to 12.8)
SET @global_min_double += 58.3 // min: 12.8 (58.3 > 12.8, keeps 12.8)
// STRING type: Get the lexicographically smallest string by byte comparison
SET @global_min_string += "cherry" // min: "cherry" ("cherry" < "zzz", updates to "cherry")
SET @global_min_string += "apple" // min: "apple" ("apple" < "cherry", updates to "apple")
SET @global_min_string += "banana" // min: "apple" ("banana" > "apple", keeps "apple")
RETURN @global_min_int, @global_min_double, @global_min_string
}
'''
Return:
+-----------------+--------------------+--------------------+
| @global_min_int | @global_min_double | @global_min_string |
+-----------------+--------------------+--------------------+
| 10 | 12.8 | apple |
+-----------------+--------------------+--------------------+
Node-attached MinAgg aggregator value variables¶
'''
USE #movie_temporary_graph {
NODE VALUE node_min MinAgg<DOUBLE> = 100
MATCH (a@User WHERE a.id IN [1,3,4])-[w@Watch]->(b@Movie)
PER PATH {
// For each user, track the lowest rating on Watch edges
SET a.@node_min += w.rate
}
PER NODE (a) {
LOG_INFO("a.id: ", a.id, " a.@node_min: ", a.@node_min)
}
}
'''
Return:
Log:
2025-08-22T03:57:02.248668 INFO - a.id: 4 a.@node_min: 1
2025-08-22T03:57:02.248668 INFO - a.id: 1 a.@node_min: 4
2025-08-22T03:57:02.248668 INFO - a.id: 3 a.@node_min: 3