与えられたエッジリレーションに沿ってすべての子孫と共に頂点のセットを削除したいと思います。私の場合、グラフには、タイプがのセッションと、タイプがのいくつかの頂点があります。ラベルは、in_sessionのセッションからイベントまでのアークです。タイタングラフの子孫を削除する
これをワンパスですばやく行うことはできないようです。ここに私が使用したコードがあります:
// First, select all event descendants of sessions with r < 700
GraphTraversal<Vertex, Vertex> t = g.V()
.has("type", "session")
.has("r", P.lt(700))
.in("in_session");
// And remove those events
while (t.hasNext())
t.next().remove();
// Then, using the first part of the query again,
// select the same sessions as before
t = g.V().has("type", "session").has("r", P.lt(700));
// And delete them as well
while (t.hasNext())
t.next().remove();
私は非常にclunkyようです。さらに、下位レベルの子孫を削除したい場合は、より多くのステップを繰り返して実行する必要があります(一番下に移動してから削除し、次に1つのレベルをバックアップしてから削除し、次に1つのレベルを再度バックアップするなど)。 ..)。また、TitanGraphにremoveVertexメソッドがないことに気付きました。
私は、gV()、has( "type"、 "session")を使用していました。( "r"、P.lt(700))sideEffect(in "in_session")。drop() )、頂点は削除されませんでした。また、thinkerpop javadocにはdrop()は記述されていません。 – Totem
最初の 'drop()'は 'GraphTraversal'クラスのメソッドです。 http://tinkerpop.apache.org/docs/current/reference/#drop-stepを参照してください。次に、あなたのトラバーサルを反復する必要があります(コンソールがそれを行います)。 iterate()のトラバーサル - http://tinkerpop.apache.org/docs/current/tutorials/the-gremlin-console/#result-iterationを参照してください。 –