37514

retrieve vertices with no linked edge in arangodb

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

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

...

update

...

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

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.

Answer1:

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}

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

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

Recommend

  • Regular expression (PCRE) for URL matching
  • Group files in a directory based on their prefix
  • Change error highlight color in vs code
  • DOMDocument::getElementById returns NULL [duplicate]
  • droppable in droppable
  • Check to see if an object has been created
  • Detect if two line segments intersect using Cramer
  • Cropping an image in Powerpoint using VBA
  • ASP.NET Deserialize Json object with single and array
  • argumentnullexception bitmap save to memorystream
  • auto layout leading or trainling -16
  • Symfony YAML format conversion
  • What icons required for app to submit to MAC App Store?
  • Submitting two different forms with an external Submit button not working properly
  • No handler found for portlet request: mode 'view', phase 'RENDER_PHASE'
  • Use WPF object to 'punch' hole in another?
  • Multiple Layouts Previews for Android in Eclipse
  • WPF ClickOnce missed references
  • Thrust filter by key value
  • Can't connect Entity Framework to local SQL Server Express
  • Build Matrix of Comparisons in SQl Server
  • Accessing Rows In A LINQ Result Without A Foreach Loop?
  • Where these are stored?
  • abstracting over a collection
  • How can I tell a form not to dispose a particular control when it closes?
  • Calculating ratio of reciprocated ties for each node in igraph
  • Is it possible to open regedit and navigate to straight to a specific key using process.start?
  • print() is showing quotation marks in results
  • Record samples being played with OpenAL
  • dc-js disable selecting slices on click for pie chart
  • Q promise. Difference between .when and .then
  • Illegal mix of collations for operation for date/time comparison
  • Spring security and special characters
  • AES padding and writing the ciphertext to a disk file
  • How would I use PHP exceptions to define a redirect?
  • FormattedException instead of throw new Exception(string.Format(…)) in .NET
  • Change div Background jquery
  • Linking SubReports Without LinkChild/LinkMaster
  • apache spark aggregate function using min value
  • Python/Django TangoWithDjango Models and Databases