Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Gremlin group by and update

I have query that calculates number of inbound edges:

 g.V().in().groupCount().unfold()

How can I update property f.e. "inCount" of each Vertexes with number of inbound edges?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

The property() step can take a Traversal as an argument for the value so:

gremlin> g.V().property('inCount', inE().count())
==>v[1]
==>v[2]
==>v[3]
==>v[4]
==>v[5]
==>v[6]
gremlin> g.V().elementMap()
==>[id:1,label:person,name:marko,inCount:0,age:29]
==>[id:2,label:person,name:vadas,inCount:1,age:27]
==>[id:3,label:software,name:lop,lang:java,inCount:3]
==>[id:4,label:person,name:josh,inCount:1,age:32]
==>[id:5,label:software,name:ripple,lang:java,inCount:1]
==>[id:6,label:person,name:peter,inCount:0,age:35]
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading