This repository was archived by the owner on Sep 18, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
[master < E-node] Add docs for node module #1013
Open
imilinovic
wants to merge
16
commits into
master
Choose a base branch
from
E-mage-node-docs
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 14 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
fba4865
add initial structure for node docs
ind1xa 9e6e7dc
add rel_exists docs
ind1xa d0a3ee8
relationship_types
imilinovic 088c62e
newline at end
imilinovic 77de6af
add fullstops
ind1xa d6ccfdd
Merge branch 'master' of github.com:memgraph/docs into E-mage-node-docs
imilinovic 3709ac4
Add node function (#1014)
mpintaric55334 178e022
Fix small spelling error
mpintaric55334 33f6b8a
Merge branch 'E-mage-node-docs' into E-idora-node-docs
ind1xa 5f12bab
Merge pull request #1002 from memgraph/E-idora-node-docs
ind1xa 035d836
fix typo
imilinovic 9e455de
Merge branch 'E-mage-node-docs' of github.com:memgraph/docs into E-ma…
imilinovic 08978f0
fix typos
imilinovic c2b4556
merge with master
imilinovic f68689d
Apply suggestions from code review
vpavicic 2b420f5
change-to-util
vpavicic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,162 @@ | ||
--- | ||
id: node | ||
title: node | ||
sidebar_label: node | ||
--- | ||
|
||
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 `node` module provides a comprehensive toolkit for managing graph nodes, enabling creation, deletion, updating, merging, and more. | ||
|
||
[](https://github.com/memgraph/mage/tree/main/cpp/node_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 | ||
|
||
### `relationship_types(node, types)` | ||
|
||
Returns a list of distinct relationship types of the given node contained within the given list of types. If the list of types is empty returns all distinct relationship types. Relationship types can also be directed: | ||
- <type - incoming relationship | ||
- type> - outgoing relationship | ||
- type - either way | ||
vpavicic marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
#### Input: | ||
|
||
- `node: Node` ➡ the given node | ||
- `types: List[string] (default = [])` ➡ list of relationship types to filter by | ||
vpavicic marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
#### Output: | ||
|
||
- `relationship_types: List[string]` ➡ list of distinct relationship types contained within the given list of types | ||
vpavicic marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
#### Usage: | ||
|
||
```cypher | ||
CREATE (ivan: Intern {name: 'Ivan'}) | ||
CREATE (idora: Intern {name: 'Idora'}) | ||
CREATE (matija: Intern {name: 'Matija'}) | ||
MERGE (ivan)-[:KNOWS]->(idora) | ||
MERGE (matija)-[:HEARS]->(idora) | ||
MERGE (matija)-[:SEES]->(ivan); | ||
``` | ||
|
||
```cypher | ||
MATCH (intern:Intern) CALL node.relationship_types(intern, ["<KNOWS", "SEES>", "HEARS"]) yield relationship_types return intern.name as name, relationship_types; | ||
``` | ||
|
||
```plaintext | ||
+--------------------------------+ | ||
| name relationship_types | | ||
+--------------------------------+ | ||
| Ivan [] | | ||
+--------------------------------+ | ||
| Idora ["HEARS", "KNOWS"] | | ||
+--------------------------------+ | ||
| Matija ["SEES", "HEARS"] | | ||
+--------------------------------+ | ||
``` | ||
|
||
### `relationship_exists(node, pattern)` | ||
|
||
Checks if given node has a relationship of the pattern. | ||
|
||
#### Input: | ||
|
||
- `node: Node` ➡ node for which relationship existance is to be verified. | ||
- `pattern: List[string] (optional)` ➡ list of relationship types for which it will be checked if at least one of them exists; if nothing is stated, procedure checks all types of relationships. | ||
|
||
:::info | ||
|
||
If '<' is added in front of the relationship type, only relationships coming into the node will be checked (e.g., "<KNOWS"), while if '>' is added at the end of the relationship type, only relationships coming from the node will be checked (e.g., "KNOWS>"). | ||
Furthermore, if relationship type is not relevant, it is possible to enter only "<" or ">" to check incoming or outgoing relationships. | ||
|
||
::: | ||
|
||
#### Output: | ||
|
||
- `exists: bool` ➡ whether or not provided node has a relationship of specified type. | ||
|
||
#### Usage: | ||
|
||
```cypher | ||
MERGE (a:Person {name: "Phoebe"}) MERGE (b:Person {name: "Joey"}) CREATE (a)-[f:FRIENDS]->(b); | ||
MATCH (a:Person {name: "Joey"}) CALL node.relationship_exists(a, ["<FRIENDS"]) | ||
YIELD exists RETURN exists; | ||
``` | ||
|
||
```plaintext | ||
+----------------------------+ | ||
| exists | | ||
+----------------------------+ | ||
| True | | ||
+----------------------------+ | ||
``` | ||
|
||
|
||
vpavicic marked this conversation as resolved.
Show resolved
Hide resolved
|
||
### `relationships_exist(node, relationships)` | ||
|
||
Checks if relationships in the input list exist at the given node. Results are returned as a map, represented as string-bool pair, where string represents the relationship, and bool represents if the relationship exists or not. Relationships can be directed, and the syntax for direction specification is provided below: | ||
- <type - incoming relationship. | ||
- type> - outgoing relationship. | ||
- type - both incoming and outgoing. | ||
- anything else results in an exception. | ||
|
||
#### Input: | ||
|
||
- `node: Node` ➡ the input node. | ||
- `relationships: List[string]` ➡ list of relationships to be checked. | ||
|
||
#### Output: | ||
|
||
- `result: Map` ➡ map of string-bool pairs, where string represents the relationship, and bool represents if the relationship exist or not. Example: `{rel1: true, rel2>: false}` means rel1 exists, and outgoing rel2 doesn't exist. | ||
|
||
#### Usage: | ||
|
||
```cypher | ||
CREATE (d:Dog)-[l:LOVES]->(h:Human)-[t:TAKES_CARE_OF]->(d); | ||
``` | ||
|
||
```cypher | ||
MATCH (d:Dog) CALL node.relationships_exist(d, ["LOVES>", "TAKES_CARE_OF", "FOLLOWS", "<LOVES"]) YIELD result RETURN result; | ||
``` | ||
|
||
```plaintext | ||
+----------------------------------------------------------------------------+ | ||
| result | | ||
+----------------------------------------------------------------------------+ | ||
| {"<LOVES": false, "FOLLOWS": false, "LOVES>": true, "TAKES_CARE_OF": true} | | ||
+----------------------------------------------------------------------------+ | ||
``` | ||
|
||
```cypher | ||
MATCH (h:Human) CALL node.relationships_exist(h, ["LOVES>", "TAKES_CARE_OF", "FOLLOWS", "<LOVES"]) YIELD result RETURN result; | ||
``` | ||
|
||
```plaintext | ||
+----------------------------------------------------------------------------+ | ||
| result | | ||
+----------------------------------------------------------------------------+ | ||
| {"<LOVES": true, "FOLLOWS": false, "LOVES>": false, "TAKES_CARE_OF": true} | | ||
+----------------------------------------------------------------------------+ | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.