Statement spread().src().depth()
can find and return edges from a start node within K hops, by specifying depth (number of edges), applying filters on the nodes and edges. The found edges are returned in the k-index ascending order, as 1-step paths formed by the edges and their start/end nodes.
Spread is a BFS (Breadth First Search) query method that is commonly used in graph query/analysis industry for observing layers of relationship around an entity, and to retrieve and acquire data quickly.
Syntax:
- Statement alias: supported (PATH)
- All parameters:
Parameter | Type | Specification | Description | Structure of Custom Alias |
---|---|---|---|---|
src() |
Filter | Mandatory | The filtering rules of the start node; error will occur if multiple nodes are found | NODE |
depth() |
Int | >0; mandatory | The maximum depth to spread | Not supported |
node_filter() |
Filter | The filtering rules that neighbor nodes other than src need to satisfy |
Not supported | |
edge_filter() |
Filter | The filtering rules that all edges need to satisfy | Not supported | |
direction() |
String | left, right | To specify the direction of the edge | Not supported |
limit() |
Int | -1 or >=0 | Number of results to return for each subquery, -1 means to return all results | Not supported |
1~N Steps
Example: Spread from Card CA001 for 3 steps, return 10 one-step paths with their properties
spread().src({_id == "CA001"}).depth(3) as p
limit 10
return p{*}
node_filter()
Example: Spread from Card CA001 for 3 steps, filter all @card nodes, return 10 one-step paths with their properties
spread().src({_id == "CA001"}).depth(3)
.node_filter({!@card}) as p
limit 10
return p{*}
edge_filter()
Example: Spread from Card CA001 for 3 steps, filter all @transfer edges, return 10 one-step paths with their properties
spread().src({_id == "CA001"}).depth(3)
.edge_filter({!@transfer}) as p
limit 10
return p{*}
direction(right)
Example: Spread from Card CA001 for 3 steps, filter all edges in the right direction, return 10 one-step paths with their properties
spread().src({_id == "CA001"}).depth(3)
.direction(right) as p
limit 10
return p{*}
direction(left)
Example: Spread from Card CA001 for 3 steps, filter all edges in the left direction, return 10 one-step paths with their properties
spread().src({_id == "CA001"}).depth(3)
.direction(left) as p
limit 10
return p{*}
limit()
Example: Spread from Card CA001 and Card CA002 for 3 steps, return 20 one-step paths with their properties for each node
uncollect ["CA001","CA002"] as n
spread().src({_id == n}).depth(3)
.limit(20) as p
return p{*}