From c7bc2400398c6f4532e4c09664d36fd223e1588f Mon Sep 17 00:00:00 2001 From: Colin Barry Date: Mon, 10 Nov 2025 09:33:48 +0000 Subject: [PATCH] feat: Add docs for `frequencies_as_map` MAGE function --- .../available-algorithms.mdx | 1 + .../available-algorithms/collections.mdx | 33 +++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/pages/advanced-algorithms/available-algorithms.mdx b/pages/advanced-algorithms/available-algorithms.mdx index b5faa0a21..cc08fe403 100644 --- a/pages/advanced-algorithms/available-algorithms.mdx +++ b/pages/advanced-algorithms/available-algorithms.mdx @@ -139,6 +139,7 @@ This table shows the mapping between APOC functions/procedures and their Memgrap | apoc.coll.removeAll | Removes defined elements from the input list | [collections.remove_all()](/advanced-algorithms/available-algorithms/collections#remove_all) | | apoc.coll.contains | Verifies the existence of an input value in an input list | [collections.contains()](/advanced-algorithms/available-algorithms/collections#contains) | | apoc.coll.flatten | Returns flattened list of inputs provided | [collections.flatten()](/advanced-algorithms/available-algorithms/collections#flatten) | +| apoc.coll.frequenciesAsMap | Returns a map of frequencies of the items in the collection | [collections.frequencies_as_map()](/advanced-algorithms/available-algorithms/collections#frequencies_as_map) | | apoc.coll.pairs | Creates pairs of neighbor elements within an input list | [collections.pairs()](/advanced-algorithms/available-algorithms/collections#pairs) | | apoc.coll.toSet | Converts the input list to a set | [collections.to_set()](/advanced-algorithms/available-algorithms/collections#to_set) | | apoc.coll.sum | Calculates the sum of listed elements | [collections.sum()](/advanced-algorithms/available-algorithms/collections#sum) | diff --git a/pages/advanced-algorithms/available-algorithms/collections.mdx b/pages/advanced-algorithms/available-algorithms/collections.mdx index 9e233c0a7..032558d5b 100644 --- a/pages/advanced-algorithms/available-algorithms/collections.mdx +++ b/pages/advanced-algorithms/available-algorithms/collections.mdx @@ -331,6 +331,39 @@ RETURN collections_module.flatten(input_list) as result +---------------------------------------------------------+ ``` +### `frequencies_as_map()` + +Returns a map of frequencies of the items in the collection. + + +This function is equivalent to **apoc.coll.frequenciesAsMap**. + + +{

Input:

} + +- `coll: List[Any]` ➡ The collection whose item frequencies will be counted. + +{

Output:

} + +- `Map[String, Integer]` ➡ A map where keys are string representations of the +items, and values are their frequencies. + +{

Usage:

} + +The following query will count the frequency of each element in the list: + +```cypher +RETURN collections.frequencies_as_map([1, 1, 2, 1, 3, 4, 1, 3]) AS result; +``` + +```plaintext ++---------------------------------------------------------+ +| result | ++---------------------------------------------------------+ +| {"1": 4, "2": 1, "3": 2, "4": 1} | ++---------------------------------------------------------+ +``` + ### `pairs()` Creates pairs of neighbor elements within an input list.