簡體   English   中英

使用路徑過濾進行AQL遍歷

[英]AQL traversal using path filtering

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

我在假設路徑對象僅返回該路徑上的頂點和邊的假設下進行工作。 這是一個錯誤的假設嗎?

如果將起點作為字符串傳遞,則遍歷根本不需要存在任何頂點:

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引用的頂點在該集合中_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 ,因此它們不存在。

刪除頂點時,也可以使用托管圖和常規圖模塊來刪除連接到頂點的邊,以確保一致性。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM