Re: Gremlin Query to return count for nodes and edges


Vinayak Bali
 

Hi All,

The query shared by HadoopMarc works. The query, I executed returns 752650 nodes and 297302 edges as a count.  The time taken is around 1min. Is there any way to optimize it further ??? 
Thank You, Marc, and all others for your help. 

Thanks & Regards,
Vinayak

On Wed, Feb 24, 2021 at 2:32 PM Graham Wallis <graham_wallis@...> wrote:
Good query from @hadoopmarc and I like @cmilowka's suggestion, although I needed to modify it very slightly as follows:

g.V().hasLabel('A').union( __.count(), __.outE().count(), __.outE().inV().count() )

That has to be the shortest and neatest solution. Certainly far better than my rather basic effort below, which surely gets the prize for the longest solution :-)

g.V().hasLabel('A').aggregate('a').outE().aggregate('e').inV().aggregate('b').select('a').dedup().as('as').select('e').dedup().as('es').select('b').dedup().as('bs').select('as','es','bs').by(unfold().count())


Best regards,
 Graham

Graham Wallis
IBM Open Software
Internet: graham_wallis@...    
IBM, Hursley Park, Hursley, Hampshire SO21 2JN







From:        "cmilowka" <cmilowka@...>
To:        janusgraph-users@...
Date:        23/02/2021 22:49
Subject:        [EXTERNAL] Re: [janusgraph-users] Gremlin Query to return count for nodes and edges
Sent by:        janusgraph-users@...







Unless stated otherwise above:
IBM United Kingdom Limited - Registered in England and Wales with number 741598.
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU

Join janusgraph-users@lists.lfaidata.foundation to automatically receive all group messages.