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

[master < E-add-label-docs] Add documentation for label module #996

Merged
merged 4 commits into from
Aug 24, 2023
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
65 changes: 65 additions & 0 deletions mage/query-modules/cpp/label.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
---
id: label
title: label
sidebar_label: label
---

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>
);

Labels are used to categorize nodes, and the `label` module provides an array of utilities for working with labels in a Memgraph database.


[![docs-source](https://img.shields.io/badge/source-label-FB6E00?logo=github&style=for-the-badge)](https://github.com/memgraph/mage/tree/main/cpp/label_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

### `exists(node, label)`

Checks whether a specified label exists within the provided node.

#### Input:

- `node: Any` ➡ node whose labels are to be checked.
- `label: string` ➡ name of the label whose existence is to be confirmed.

#### Output:

- `exists: bool` ➡ whether or not provided node has a specified label.

#### Usage:

```cypher
CREATE (:Student {name: 'Ana'});
MATCH (s:Student {name: 'Ana'}) CALL label.exists(s, "Teacher") YIELD exists RETURN exists;
```

```plaintext
+----------------------------+
| exists |
+----------------------------+
| False |
+----------------------------+
```

1 change: 1 addition & 0 deletions mage/templates/_mage_spells.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
| [graph_coloring](/mage/query-modules/python/graph-coloring) | Python | Algorithm for assigning labels to the graph elements subject to certain constraints. In this form, it is a way of coloring the graph vertices such that no two adjacent vertices are of the same color. |
| [katz_centrality](/mage/query-modules/cpp/katz-centrality) | C++ | Katz centrality is a centrality measurement that outputs a node's influence based on the number of shortest paths and their weighted length. |
| [kmeans](/mage/query-modules/python/kmeans) | Python | An algorithm for clustering given data. |
| [label](/mage/query-modules/cpp/label) | C++ | The label module provides an array of utilities for working with labels in a Memgraph database. |
| [map](/mage/query-modules/cpp/map) | C++ | The map module offers a versatile toolkit for manipulating collections of key-value pairs, enabling advanced data operations within a graph database context |
| [max_flow](/mage/query-modules/python/max-flow) | Python | An algorithm for finding a flow through a graph such that it is the maximum possible flow. |
| [node_similarity](/mage/query-modules/cpp/node-similarity) | C++ | A module that contains similarity measures for calculating the similarity between two nodes. |
Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions sidebars/sidebarsMAGE.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ module.exports = {
"query-modules/cpp/katz-centrality",
"query-modules/cpp/katz-centrality-online",
"query-modules/python/kmeans",
"query-modules/cpp/label",
"query-modules/python/link-prediction-with-gnn",
"query-modules/python/llm-util",
"query-modules/cpp/map",
Expand Down