示例图集
以下示例根据该图集运行:
path_length()
返回路径中的总边数。
语法 | path_length(<pathVar>) |
||
参数 | 名称 | 类型 | 描述 |
<pathVar> |
PATH |
路径变量引用 | |
返回类型 | UINT |
MATCH p = ()->{1,3}()
RETURN p, PATH_LENGTH(p) AS length
结果:
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()
将路径中的所有边放入一个列表。
语法 | pedges(<pathVar>) |
||
参数 | 名称 | 类型 | 描述 |
<pathVar> |
PATH |
路径变量引用 | |
返回类型 | LIST |
MATCH p = ({_id: "P1"})-[]->{1,2}()
RETURN pedges(p)
结果:
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()
将路径中的所有点放入一个列表。
语法 | pnodes(<pathVar>) |
||
参数 | 名称 | 类型 | 描述 |
<pathVar> |
PATH |
路径变量引用 | |
返回类型 | LIST |
MATCH p = ({_id: "P1"})-[]->{1,2}()
RETURN pnodes(p)
结果:
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}}] |