3

Arango でトラバーサルを行うと、次のような json 構造の配列が得られます。

{
  "vertex" : {
    "_id" : "vertices/857831247835",
    "_key" : "857831247835",
    "_rev" : "857831247835",
  },
  "path" : {
    "edges" : [
      {
      "_id" : "edges/857831575515",
      "_key" : "857831575515",
      "_rev" : "857831575515",
      "_from" : "vertices/857831247835",
      "_to" : "vertices/857821417435",
    }
    ],
    "vertices" : [
      {
      "_id" : "vertices/857821417435",
      "_key" : "857821417435",
      "_rev" : "857821417435",
    },
    {
      "_id" : "vertices/857831247835",
      "_key" : "857831247835",
      "_rev" : "857831247835",
    }
    ]
  },
  "startVertex" : "vertices/857821417435"
}

AQL を使用して、トラバーサルで見つかったすべてのエッジ/頂点を上記のような単一の構造に取得する方法はありますか?

4

2 に答える 2

0

少し古いですが、この質問への新しい訪問者のために。別の方法は、パスからエッジを一意に蓄積することです (構文は arangojs 公式クライアントのものです)。

graph.traversal('verticies/startkey', {
    direction: 'any',
    init: `result.verticies = [];
    result.edges = [];`,
    visitor: `
        path.edges
            .forEach(function (x) {
                if (result.edges.indexOf(x) === -1) {
                    result.edges.push(x);
                }
            });
        result.verticies.push(vertex);
    `,
    uniqueness: {
        "vertices": "global",
        "edges": "global"
    }
});
于 2016-02-29T07:01:45.047 に答える