1

http://gremlindocs.spmallette.documentup.com/#shortest-path

试图弄清楚如何在 Gremlin 脚本范围内初始化集合,同时在 Java 中形成 Gremlin 管道,以优化最短路径查询

Pipe pipe;
pipe = Gremlin.compile("s = _() as      Set;_().as('x').bothE().bothV().simplePath().loop('x'){it.loops<=7 }{ !(it.object.id in ['#"+fromId+"','#"+toId+"'])}.path.filter{it.last().TYPE==\""+toType+"\" && it.last().OBJECTREF==\""+toObjectRef+"\"}.path[0]");
pipe.setStarts(new SingleIterator<Vertex>(fromV));

我正在尝试实现以下目标,这在上面的链接中有记录

gremlin> s = [root] as Set
==>v[0]
gremlin> target = '99'; c = 0;root.both().except(s).store(s).sideEffect{c++}.loop(4){it.object.id != target && it.loops <= 10}.has('id',target).path().iterate(); c
==>100

任何帮助将不胜感激

4

0 回答 0