使用tinkerpop blueprints API,找到两个顶点之间是否存在边的最佳方法是什么?我想避免vertex.getEdges()
并迭代直到找到正确的。{/ p>
例如:检查v1
是否是v2
Vertex v1 = g.addVertex(null);
Vertex v2 = g.addVertex(null);
Edge edge = g.addEdge(null, v1, v2, "friends");
Edge edge = g.addEdge(null, v1, v2, "follows");
// Node with lots of edges - Supernode - problem?
List<Edge> edges = new ArrayList<Edge>();
for(Edge edge : g.getVertex(v1.getId()).getEdges(Direction.OUT, "friends")){
if(edge.getVertex(Direction.IN).getId().equals(v2.getId()){
edges.add(edge);
}
}
我应该使用Vertex Query吗?
通过gremlin我能做到:
g.v(v1.getID()).outE("friends").inV.filter{it.id == v2.getID}
IndexHits<Relationship> relationships = relationshipIndex().get("type", edgeType, node1, node2);
感谢您的帮助! 我还是新手。
答案 0 :(得分:4)
gremlin> g.v(1).bothE.as('x').bothV.retain([g.v(3)]).back('x')
答案 1 :(得分:3)
Tinkerpop中不再提供Huangmao Quan答案中使用的back
步骤。正如我已回答此问题question,以下请求可能适用于更新版本的tinkerpop堆栈。
g.V().has('propertykey','value1').outE('thatlabel').as('e').inV().has('propertykey','value2').select('e')
答案 2 :(得分:1)
试试这个:
if (g.v(1).out('follows').retain([g.v(2)]).hasNext())
{
println('v(1) follows v(2)')
}
注意:此处的边缘是单向的,即您无法推断v2是否跟随v1。
来源:https://groups.google.com/forum/#!msg/gremlin-users/Og7Xf8tYbx4/gqBArTw98sAJ
答案 3 :(得分:0)
failed to read the duration of file /home/ankur/Desktop/test_dev_1010_v111.swf.
Here are the file infos returned by ffmpeg:
ffmpeg version 4.1-static https://johnvansickle.com/ffmpeg/ Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 6.3.0 (Debian 6.3.0-18+deb9u1) 20170516
configuration: --enable-gpl --enable-version3 --enable-static --disable-debug --disable-ffplay --disable-indev=sndio --disable-outdev=sndio --cc=gcc-6 --enable-fontconfig --enable-frei0r --enable-gnutls --enable-gray --enable-libaom --enable-libfribidi --enable-libass --enable-libvmaf --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librubberband --enable-libsoxr --enable-libspeex --enable-libvorbis --enable-libopus --enable-libtheora --enable-libvidstab --enable-libvo-amrwbenc --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg
libavutil 56. 22.100 / 56. 22.100
libavcodec 58. 35.100 / 58. 35.100
libavformat 58. 20.100 / 58. 20.100
libavdevice 58. 5.100 / 58. 5.100
libavfilter 7. 40.101 / 7. 40.101
libswscale 5. 3.100 / 5. 3.100
libswresample 3. 3.100 / 3. 3.100
libpostproc 55. 3.100 / 55. 3.100
[mjpeg @ 0x52f5240] Found EOI before any SOF, ignoring
[swf @ 0x52f3b40] [IMGUTILS @ 0x7ffdb41d6e70] Picture size 0x0 is invalid
[swf @ 0x52f3b40] invalid frame size 0x0
Input #0, swf, from '/home/ankur/Desktop/test_dev_1010_v111.swf':
Duration: N/A, bitrate: N/A
Stream #0:0: Video: mjpeg, yuvj420p(pc, bt470bg/unknown/unknown), 1058x794 [SAR 96:96 DAR 529:397], 12 tbr, 12 tbn
At least one output file must be specified