在arangodb中检索没有链接边的顶点 [英] retrieve vertices with no linked edge in arangodb

查看:21
本文介绍了在arangodb中检索没有链接边的顶点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

检索所有在相关 edge_collection 中没有边的顶点的最佳方法是什么

What is the best way to retrieve all vertices that do not have an edge in a related edge_collection

我尝试使用以下代码,但自从 arangodb 2.8 以来它变得非常慢(在以前的版本中它并不是真的快,但比现在快了大约 10 倍).在大约 1000 个边和大约 3000 个顶点的集合大小上需要超过 30 秒.

I've tried to use the following code but it's got incredibly slow since arangodb 2.8 (It was not really fast in previous versions but round about 10 times faster as now). It takes more than 30 seconds on collection sizes of around 1000 edges and around 3000 vertices.

FOR v IN vertex_collection  
    FILTER LENGTH( EDGES(edge_collection, v._id, "outbound"))==0
RETURN v._id

...

更新

...

玩了一会儿后,我来到了以下查询

After playing around a bit I came to the following query

LET vIDs = (FOR v IN vertex_collection
            RETURN v._id)
LET vEdgesFrom = (FOR e IN edge_collection
                  FILTER e._from IN vIDs
                  RETURN e._from)
FOR v IN vertex_collection
    FILTER v._id IN MINUS(vIDs, vEdgesFrom)
RETURN v._id

这个速度要快得多(大约 0.05 秒),但看起来仍然是某种解决方法(只是考虑到我们需要查询的多个边缘集合).

This one is much faster (around 0.05s) but still looks like some kind of work around (just thinking of more than one edge collections we need to query against).

所以我仍在寻找在特定边集合中找到没有边的顶点的最佳方法.

So I'm still looking for the best method to find vertices having no edge in specific edge collections.

推荐答案

我的建议将是类似的 - 而是使用 加入 比图特征.

My sugestion was going to be similar - rather use joins than graph features.

FOR oneEdge IN edges
LET vertices=(FOR oneVertex IN vertices
        FILTER oneEdge._from == oneVertex._id OR
               oneEdge._to == oneVertex._id
        RETURN 1)
FILTER LENGTH(vertices) < 2
RETURN {v: vertices, e: oneEdge}

找到所有 _from_to 之一指向 nil 的边,然后删除它.

to find all edges where one of _from and _to would point into nil, and then subsequently delete it.

注意 RETURN 1 这将减少从内部查询传递的数据量.

Note the RETURN 1 which will reduce the amount of data passed up from the inner query.

这篇关于在arangodb中检索没有链接边的顶点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆