Using duplicate intermediate vertex?

31 views
Skip to first unread message

Frank Russell

unread,
Mar 18, 2017, 1:41:12 PM3/18/17
to ArangoDB
How to re-use node as intermediate node ?

When I return the result as path it have all path walked
[2]  A -> B -> C
[3]  A -> B -> D

but when return vertex it remove duplicate vertex B
["A", "B", "C", "D"]

Expected result:
["A", "B", "B", "C", "D"]

| A |   |
|---|---|
| B |   |
| C | D |

Query:
FOR v,e,p IN 1..3 OUTBOUND "columns/0" `table1` RETURN v.title



columns.json
[
   
{
       
"_key": "0",
       
"id": 0,
       
"title": "root",
       
"visible": false
   
},
   
{
       
"_key": "1",
       
"id": 1,
       
"title": "A",
       
"visible": true
   
},
   
{
       
"_key": "2",
       
"id": 2,
       
"title": "B",
       
"visible": false
   
},
   
{
       
"_key": "3",
       
"id": 3,
       
"title": "C",
       
"visible": true
   
},
   
{
       
"_key": "4",
       
"id": 4,
       
"title": "D",
       
"visible": true
   
}
]


table1.json
[
 
{
   
"_key": "1",
   
"_from": "columns/0",
   
"_to": "columns/1"
 
},
 
{
   
"_key": "2",
   
"_from": "columns/1",
   
"_to": "columns/2"
 
},
 
{
   
"_key": "4",
   
"_from": "columns/2",
   
"_to": "columns/3"
 
},
 
{
   
"_key": "5",
   
"_from": "columns/2",
   
"_to": "columns/4"
 
}
]



mpv1989

unread,
Mar 23, 2017, 8:05:38 AM3/23/17
to ArangoDB
You could return all vertices of every path `p` und flatten them into one array.

see docu here
RETURN FLATTEN(FOR v,e,p IN 1..3 OUTBOUND "columns/0" `table1` RETURN p.vertices[*].title)

or alternative see docu here
RETURN (FOR v,e,p IN 1..3 OUTBOUND "columns/0" `table1` RETURN p.vertices[*].title)[**]

Reply all
Reply to author
Forward
0 new messages