2017-07-20 105 views
1

我正在AQL(arangodb 3.1.22)中編寫一個圖遍歷查詢,其中對於返回的一些路徑,我得到了未連接到任何邊的路徑對象中的一個頂點在路徑對象內返回(即邊的_from/_to屬性與頂點_id不匹配)。使用路徑過濾的AQL遍歷

我正在假設路徑對象只返回該路徑上的頂點和邊緣。這是一個錯誤的假設?

+0

您的假設是正確的,路徑應該只包含路徑上的頂點和邊。你能發佈你的查詢嗎? – mpv1989

回答

0

如果傳遞的起點爲字符串,沒有頂點必須在所有存在的遍歷:

FOR v, e IN 1..10 OUTBOUND "nodes/non-existing-start" edges 
    RETURN { vertex: v, _from: e._from, _to: e._to } 

數據(收集nodes頂點和edges邊緣):

non-existing-start 
     | 
     v 
non-existing-1 
     | 
     v 
non-existing-2 
     | 
     v 
non-existing-3 

它所做的是沿邊緣(_from_to屬性)遍歷,它們使用邊索引。集合nodes必須存在,但未測試_from_to中引用的頂點是否實際存在於該集合中。查詢結果是:

[ 
    { 
    "vertex": null, 
    "_from": "nodes/non-existing-start", 
    "_to": "nodes/non-existing-1" 
    }, 
    { 
    "vertex": null, 
    "_from": "nodes/non-existing-1", 
    "_to": "nodes/non-existing-2" 
    }, 
    { 
    "vertex": null, 
    "_from": "nodes/non-existing-2", 
    "_to": "nodes/non-existing-3" 
    } 
] 

正如你所看到的,頂點是null,所以他們不存在。

刪除頂點以確保一致性時,您可以使用託管圖和general-graph模塊也可以使用delete edges connected to a vertex