Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pages/advanced-algorithms/available-algorithms.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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) |
Expand Down
33 changes: 33 additions & 0 deletions pages/advanced-algorithms/available-algorithms/collections.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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.

<Callout type="info">
This function is equivalent to **apoc.coll.frequenciesAsMap**.
</Callout>

{<h4 className="custom-header"> Input: </h4>}

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

{<h4 className="custom-header"> Output: </h4>}

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

{<h4 className="custom-header"> Usage: </h4>}

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.
Expand Down