UltipaDocs
Try Playground
  • Introduction
  • Terminologies
    • Reserved Words
    • Data Types
    • Alias
    • Operators
    • Expression
    • Filter
    • Prefix
    • Node and Edge Templates
    • Homologous and Heterologous Data
    • Clause Execution Times
    • Graphset
    • Schema
    • Property
    • Insert
    • Overwrite
    • Upsert
    • Update
    • Delete
    • Find Nodes
    • Find Edges
      • AB
      • Autonet
      • Spread
      • Path Template
      • K-Hop
      • K-Hop Template
    • Find Subgraphs
    • GROUP BY
    • ORDER BY
    • SKIP
    • LIMIT
    • WHERE
    • RETURN
    • WITH
    • UNCOLLECT
    • UNION
    • UNION ALL
    • CALL
    • BATCH
      • Schema Checker
      • Equal
      • Not Equal
      • Less Than
      • Greater Than
      • Less Than or Equal
      • Greater Than or Equal
      • Between
      • Between or Equal
      • Beong to
      • Not Belong To
      • CONTAINS | String
      • CONTAINS | Full-Text
      • Regular Match
      • IS NULL
      • IS NOT NULL
      • And
      • Or
      • Not
      • Exclusive OR
      • DISTINCT
      • toString()
      • toInteger()
      • toFloat()
      • toDouble()
      • toDecimal()
      • toSet()
      • castToRaw()
      • now()
      • dateAdd()
      • dateDiff()
      • year()
      • month()
      • day()
      • dayOfWeek()
      • dateFormat()
      • point()
      • distance()
      • pointInPolygon()
      • lower()
      • upper()
      • reverse()
      • startsWith()
      • endsWith()
      • JSON_decode()
      • JSON_merge()
      • trim()
      • ltrim()
      • rtrim()
      • left()
      • right()
      • substring()
      • replace()
      • split()
      • intersection()
      • difference()
      • listUnion()
      • size()
      • head()
      • reduce()
      • listContains()
      • append()
      • pi()
      • pow()
      • sqrt()
      • abs()
      • floor()
      • ceil()
      • round()
      • sin()
      • cos()
      • tan()
      • cot()
      • asin()
      • acos()
      • atan()
      • length()
      • pnodes()
      • pedges()
      • count()
      • sum()
      • max()
      • min()
      • avg()
      • stddev()
      • collect()
      • dedup()
      • CASE
      • table()
      • coalesce()
      • ifnull()
    • Acceleration
    • Index
    • Full-text
    • LTE
    • Real-time Process
    • Backend Task
    • Analytics Node
    • Server Statistics
    • Server Backup
    • Privilege
    • Policy
    • User
  • Trigger
  1. Docs
  2. /
  3. UQL
  4. /
  5. Find Paths

Autonet

The autonet().src().dest().depth() query can find and return paths from a group of initial-nodes to a group of terminal-nodes. It is a batch processing of A-B path query by paring an initial-node and a terminal-node for each query, and its parameter limit() is limiting the number of returns of each A-B pair of each subquery, but not that of all A-B pairs of each subquery.

Determined by the usage of parameter dest(), autonet query works in two modes:

a) Inter-group Networking (when setting dest())

  • N nodes from one group pairing with M nodes from another group
  • N * M times of A-B path query
  • When the parameter limit(n) is carried and the value of n is not -1, maximum n * N * M paths will be found

b) Intra-group Networking (when omitting dest())

  • N nodes from one group pairing with each other:
  • N(N-1)/2 times of A-B path query
  • When the parameter limit(n) is carried and the value of n is not -1, maximum n * N(N-1)/2 paths will be found
Inter-group Networking (Left image) and Intra-group Networking (Right image)
(Each Line represents an A-B query execution)

Syntax:

  • Statement alias: supported (PATH)
  • All parameters:
ParameterTypeSpecificationDescriptionStructure of Custom Alias
src()FilterMandatoryThe filtering rules of the start nodeNODE
dest()FilterThe filtering rules of the end nodeNODE
depth()RangeMandatoryTo set the depth of the path
depth(N): N edges
depth(:N): 1~N edges
depth(M:N): M~N edges
depth(N).shortest(): the shortest path within N edges
Not supported
shortest()/ or @<schema>.<property>LTE-ed numeric edge propertyReturn the (weighted) shortest path. When an edge property (with non-negative values) is specified, edges without that property will not be considered

The shortest() method only supports depth(N), indicating the (weighted) shortest paths within N steps
Not supported
node_filter()FilterThe filtering rules that nodes other than src and dest need to satisfyNot supported
edge_filter()FilterThe filtering rules that all edges need to satisfyNot supported
direction()Stringleft, rightTo specify the direction of the edgeNot supported
no_circle()//To dismiss the paths with circles; see Basic Concept - Terminologies for the definition of circleNot supported
limit()Int-1 or >=0Number of results of each A-B pair to return, -1 means to return all resultsNot supported

Sample graph: (to be used for the following examples)

(All nodes and edges are of schema @default)
Run below UQLs one by one in an empty graphset to create graph data: ```customlang___fold__lang_uql create().edge_property(@default, "weight", int32) insert().into(@default).nodes([{_id:"A", _uuid:1}, {_id:"B", _uuid:2}, {_id:"C", _uuid:3}, {_id:"D", _uuid:4}, {_id:"E", _uuid:5}, {_id:"F", _uuid:6}]) insert().into(@default).edges([{_uuid:1, _from_uuid:1, _to_uuid:3, weight:1}, {_uuid:2, _from_uuid:5, _to_uuid:2 , weight:1}, {_uuid:3, _from_uuid:1, _to_uuid:5 , weight:4}, {_uuid:4, _from_uuid:4, _to_uuid:3 , weight:2}, {_uuid:5, _from_uuid:5, _to_uuid:4 , weight:3}, {_uuid:6, _from_uuid:2, _to_uuid:1 , weight:2}, {_uuid:7, _from_uuid:6, _to_uuid:1 , weight:4}]) ```

Inter-Group: Filter Depth

Example: Find 1~3-step paths from [A,B] to [D,E], carry all properties

UQL
autonet().src({_id in ["A","B"]}).dest({_id in ["D","E"]}).depth(:3) as p
return p{*}
Result
A --3--> E --5--> D
A --1--> C <--4-- D
A <--6-- B <--2-- E --5--> D
A --3--> E
A --1--> C <--4-- D <--5-- E
A <--6-- B <--2-- E
B --6--> A --3--> E --5--> D
B --6--> A --1--> C <--4-- D
B <--2-- E --5--> D
B --6--> A --3--> E
B <--2-- E

Inter-Group: Non-weighted Shortest Path

Example: Find shortest paths from [A,B] to [D,E] within 3 steps, carry all properties

UQL
autonet().src({_id in ["A","B"]}).dest({_id in ["D","E"]}).depth(3)
  .shortest() as p
return p{*}
Result
A --1--> C <--4-- D
A --3--> E --5--> D
A --3--> E
B <--2-- E --5--> D
B <--2-- E

Inter-Group: limit()

Example: Find 1~3-step paths from [A,B] to [D,E], return 1 path for each pair of nodes, carry all properties

UQL
autonet().src({_id in ["A","B"]}).dest({_id in ["D","E"]}).depth(:3).limit(1) as p
return p{*}
Result
A <--6-- B <--2-- E --5--> D
A <--6-- B <--2-- E
B <--2-- E --5--> D
B <--2-- E

Intra-Group: Filter Depth

Example: Find 1~3-step paths among [A,B,C], carry all properties

UQL
autonet().src({_id in ["A","B","C"]}).depth(:3) as p
return p{*}
Result
A --3--> E --2--> B
A <--6-- B
A --3--> E --5--> D --4--> C
A --1--> C
B --6--> A --1--> C
B <--2-- E --5--> D --4--> C
B <--2-- E <--3-- A --1--> C

Intra-Group: Non-weighted Shortest Path

Example: Find shortest paths among [A,B,C] within 3 steps, carry all properties

UQL
autonet().src({_id in ["A","B","C"]}).depth(3)
  .shortest() as p
return p{*}
Result
A <--6-- B
A --1--> C
B --6--> A --1--> C

Intra-Group: limit()

Example: Find 1~3-step paths among [A,B,C], return 1 path for each pair of nodes, carry all properties

UQL
autonet().src({_id in ["A","B","C"]}).depth(:3).limit(1) as p
return p{*}
Result
A <--6-- B
A --1--> C
B <--2-- E <--3-- A --1--> C