Skip to content
This repository has been archived by the owner on Sep 18, 2023. It is now read-only.

[master < E-util-docs] Write docs for util module #1012

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 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
67 changes: 67 additions & 0 deletions mage/query-modules/cpp/util_module.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
---
id: util_module
title: util_module
sidebar_label: util_module
---

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import RunOnSubgraph from '../../templates/_run_on_subgraph.mdx';

export const Highlight = ({children, color}) => (
<span
style={{
backgroundColor: color,
borderRadius: '2px',
color: '#fff',
padding: '0.2rem',
}}>
{children}
</span>
);

The util module offers a range of functions for tasks such as validation and creating cryptographic hash values. This module serves as a practical resource for streamlining a variety of tasks related to database operations.

[![docs-source](https://img.shields.io/badge/source-util_module-FB6E00?logo=github&style=for-the-badge)](https://github.com/memgraph/mage/tree/main/cpp/util_module)

| Trait | Value |
| ------------------- | ----------------------------------------------------- |
| **Module type** | <Highlight color="#FB6E00">**algorithm**</Highlight> |
| **Implementation** | <Highlight color="#FB6E00">**C++**</Highlight> |
| **Graph direction** | <Highlight color="#FB6E00">**directed**</Highlight>/<Highlight color="#FB6E00">**undirected**</Highlight> |
| **Edge weights** | <Highlight color="#FB6E00">**weighted**</Highlight>/<Highlight color="#FB6E00">**unweighted**</Highlight> |
| **Parallelism** | <Highlight color="#FB6E00">**sequential**</Highlight> |

### Procedures


### `md5(values)`

Gets the string representation of every element in the input list, concatenates it into a single string, and returns the md5 hash of that string.
NOTE: The format of string representations can be seen by checking ToString in [CPP API](/memgraph/reference-guide/query-modules/api/cpp-api) documentation for desired type or Value.

#### Input:
vpavicic marked this conversation as resolved.
Show resolved Hide resolved

- `values: List[Any]` ➡ input list containing elements which can be any of Memgraph's data types.

#### Output:

- `result: string` ➡ resulting md5 hash returned as string.

#### Usage:

NOTE: The hash provided in this documentation will be different from the user's hash for the same input unless the node has the same ID because `Node.ToString()` uses the node's ID in string formation, so different IDs equal different strings, hence, different hashes.

```cypher
CREATE (d:Dog);
MATCH (d:Dog)
CALL util_module.md5([d, "string", 50]) YIELD result RETURN result;
```

```plaintext
+-----------------------------------+
| result |
+-----------------------------------+
| 47e656a5f446fc21316e97df90e8ae33 |
+-----------------------------------+
```
1 change: 1 addition & 0 deletions mage/templates/_mage_spells.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
| [set_cover](/mage/query-modules/python/set-cover) | Python | An algorithm for finding the minimum cost subcollection of sets that covers all elements of a universe. |
| [tsp](/mage/query-modules/python/tsp) | Python | An algorithm for finding the shortest possible route that visits each vertex exactly once. |
| [union_find](/mage/query-modules/python/union-find) | Python | A module with an algorithm that enables the user to check whether the given nodes belong to the same connected component. |
| [util_module](/mage/query-modules/cpp/util_module) | C++ | A module which offers a range of functions for tasks such as validation and creating cryptographic hash values. This module serves as a practical resource for streamlining a variety of tasks related to database operations. |
| [vrp](/mage/query-modules/python/vrp) | Python | Algorithm for finding the shortest route possible between the central depot and places to be visited. The algorithm can be solved with multiple vehicles that represent a visiting fleet. |
| [weakly_connected_components](/mage/query-modules/cpp/weakly-connected-components) | C++ | A module that finds weakly connected components in a graph. |

Expand Down
1 change: 1 addition & 0 deletions sidebars/sidebarsMAGE.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ module.exports = {
"query-modules/python/temporal-graph-networks",
"query-modules/python/tsp",
"query-modules/python/union-find",
"query-modules/cpp/util_module",
"query-modules/cpp/uuid-generator",
"query-modules/python/vrp",
"query-modules/cpp/weakly-connected-components"
Expand Down
Loading