Exemple de Graph
Les exemples suivants s'exécutent sur ce graph :

path_length()
Retourne le nombre de edges dans un path.
| Syntaxe | path_length(<pathVar>) |
||
| Arguments | Nom | Type | Description |
<pathVar> |
PATH |
Référence de variable de path | |
| Type de Retour | UINT |
||
MATCH p = ()->{1,3}()
RETURN p, PATH_LENGTH(p) AS length
Résultat :
| p | length |
|---|---|
| (:Paper { | |
| _id: "P1", score: 6, title: "Efficient Graph Search", author: "Alex"})-[:Cites {weight: 2}]->(:Paper { | |
| _id: "P2", score: 9, title: "Optimizing Queries", author: "Alex"})-[:Cites {weight: 1]->(:Paper { | |
| _id: "P3", score: 7, title: "Path Patterns", author: "Zack"}) | 2 |
| (:Paper { | |
| _id: "P1", score: 6, title: "Efficient Graph Search", author: "Alex"})-[:Cites {weight: 2]->(:Paper { | |
| _id: "P2", score: 9, title: "Optimizing Queries", author: "Alex"}) | 1 |
| (:Paper { | |
| _id: "P2", score: 9, title: "Optimizing Queries", author: "Alex"})-[:Cites {weight: 1]->(:Paper { | |
| _id: "P3", score: 7, title: "Path Patterns", author: "Zack"}) | 1 |
pedges()
Collecte les edges dans un path dans une liste.
| Syntaxe | pedges(<pathVar>) |
||
| Arguments | Nom | Type | Description |
<pathVar> |
PATH |
Référence de variable de path | |
| Type de Retour | LIST |
||
MATCH p = ({_id: "P1"})-[]->{1,2}()
RETURN pedges(p)
Résultat :
| pedges(p) |
|---|
| [{"from":"P1","to":"P2","uuid":"1","from_uuid":"8791028671650463745","to_uuid":"8718971077612535810","schema":"Cites","values":{"weight":2}}] |
| [{"from":"P1","to":"P2","uuid":"1","from_uuid":"8791028671650463745","to_uuid":"8718971077612535810","schema":"Cites","values":{"weight":2}},{"from":"P2","to":"P3","uuid":"2","from_uuid":"8718971077612535810","to_uuid":"12033620403357220867","schema":"Cites","values":{"weight":1}}] |
pnodes()
Collecte les nodes dans un path dans une liste.
| Syntaxe | pnodes(<pathVar>) |
||
| Arguments | Nom | Type | Description |
<pathVar> |
PATH |
Référence de variable de path | |
| Type de Retour | LIST |
||
MATCH p = ({_id: "P1"})-[]->{1,2}()
RETURN pnodes(p)
Résultat :
| pnodes(p) |
|---|
| [{"id":"P1","uuid":"8791028671650463745","schema":"Paper","values":{"author":"Alex","title":"Efficient Graph Search","score":6}},{"id":"P2","uuid":"8718971077612535810","schema":"Paper","values":{"author":"Alex","title":"Optimizing Queries","score":9}}] |
| [{"id":"P1","uuid":"8791028671650463745","schema":"Paper","values":{"author":"Alex","title":"Efficient Graph Search","score":6}},{"id":"P2","uuid":"8718971077612535810","schema":"Paper","values":{"author":"Alex","title":"Optimizing Queries","score":9}},{"id":"P3","uuid":"12033620403357220867","schema":"Paper","values":{"author":"Zack","title":"Path Patterns","score":7}}] |