简体   繁体   English

Gremlin 查询:到目前为止如何获取查询中的所有“内部”边缘?

[英]Gremlin Query: How to get all "internal" edges in the query so far?

So I'm trying to visualize the nodes so far in a gremlin query together with only the edges between these nodes;所以我试图在 gremlin 查询中可视化到目前为止的节点以及这些节点之间的边缘; the "internal" edges if you may.如果可以的话,“内部”边缘。

For example, I have this gremlin query:例如,我有这个 gremlin 查询:

g.V().hasLabel("Person").out("Expert in")

which results in a set of nodes.这导致一组节点。 How do I, in a general matter, make a gremlin query to get all the edges between the nodes in this resultset?在一般情况下,我如何进行 gremlin 查询以获取此结果集中节点之间的所有边?

Thanks for any help :)谢谢你的帮助 :)

The out() step is a shorthand for outE().inV() so the first step to getting the edges is to explicitly traverse the edges so that they become part of the path history. out()步骤是outE().inV()的简写,因此获取边缘的第一步是显式遍历边缘,使它们成为路径历史的一部分。 You could get the edges from that history in a variety of ways - how about the path() step?您可以通过多种方式从该历史记录中获取边缘 - path() 步骤如何?

g.V().hasLabel("Person").outE("Expert in").inV().path()

I figured it out!我想到了!

This gremlin query should do the trick:这个 gremlin 查询应该可以解决问题:

g.V().hasLabel('Person') // <-- Nodes chosen so far; can be any query resulting in nodes
.dedup()
.union(outE(), inE()) 
.groupCount()
.unfold()
.where(select(values).is(gt(1)))
.select(keys)

This takes the union of all outgoing and all ingoing edges, and then removes those edges that does not appear more than once.这需要所有出边和所有入边的联合,然后删除那些出现次数不超过一次的边。 The result is all the edges between the nodes in the query so far :)结果是到目前为止查询中节点之间的所有边:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Gremlin 查询以获取所有直接和间接相关的顶点 - Gremlin query to get all the directly as well as indirectly related vertices 如何获取数据库中每个日期到目前为止最大日期的数据 - how to get for each date in the database the data of max date so far 我如何获得所有表与选择查询 - how i get all table with select query 使用 window function 来获取客户到目前为止下了多少订单以及他们最后一次下订单的时间 - Using window function to get how many orders a customer has made so far and when was their last order Gremlin中TinerGraph转JanusGraph时出现查询错误? - In Gremlin, there is a query error when converting TinerGraph to JanusGraph? 根据日期查询 Cosmos Db 的 Gremlin 语法 - Gremlin Syntax to Query Cosmos Db Based on date 在一个查询中获取所有后代? - Get all descendants in one query? 查询以获取全部而不是FirstOrDefault - Query to get all instead of FirstOrDefault 我如何查询和显示我邀请的所有人以及他们邀请的人等等? - How can i query and show all the people that i invited and the people that they invited and so on? 如何在neo4j中编写遍历查询(gremlin / cypher之一)? - How could I write a traversal query in neo4j (gremlin/cypher either one)?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM