【问题标题】:TinkerPop 3: Gremlin query to group count by edge directionTinkerPop 3:Gremlin 查询按边缘方向分组计数
【发布时间】:2016-09-01 05:10:26
【问题描述】:

我有一个顶点 id 开始,并希望获得入边和出边的计数。

g.traversal().V().has("__id", "1234").groupCount().by(Direction.BOTH)

由于.by() 步骤不接受Direction 类型。有没有替代方法?

【问题讨论】:

    标签: gremlin graph-traversal tinkerpop3


    【解决方案1】:

    你可以用project step很好地做到这一点:

    gremlin> graph = TinkerFactory.createModern()
    ==>tinkergraph[vertices:6 edges:6]
    gremlin> g = graph.traversal()
    ==>graphtraversalsource[tinkergraph[vertices:6 edges:6], standard]
    gremlin> g.V().has('name','marko').
                   project('out','in').
                     by(outE().count()).
                     by(inE().count())
    ==>[out:3,in:0]
    

    对于没有 project 的 TinkerPop 3.0.x,您可以这样做:

    gremlin> g.V().has('name','marko').as('out','in').
                   select('out','in').
                     by(outE().count()).
                     by(inE().count())
    ==>[out:3,in:0]
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-06
    相关资源
    最近更新 更多