I want to select all l labelled vertices along with their t labelled vertices grouped by their neighbours. Also I want to apply a limit on the length of the neighbours.
For ex for neighbour limit = 2 something like below should be output.
[
{"l1",[t1,t2]},
{"l2",[t3]},
{"l3",[]}
]
For ex for neighbour limit = 1 something like below should be output.
[
{"l1",[t1]},
{"l2",[t3]},
{"l3",[]}
]
grelify link https://gremlify.com/xun4v83y54/1
g.addV('Vertex').as('1').property(single, 'name', 'l1').property(single, 'label', 'l').
addV('Vertex').as('2').property(single, 'name', 'l2').property(single, 'label', 'l').
addV('Vertex').as('3').property(single, 'name', 'l3').property(single, 'label', 'l').
addV('Tag').as('4').property(single, 'name', 't1').property(single, 'label', 't').
addV('Tag').as('5').property(single, 'name', 't2').property(single, 'label', 't').
addV('Tag').as('6').property(single, 'name', 't3').property(single, 'label', 't').
addE('connected').from('1').to('4').
addE('connected').from('1').to('5').
addE('connected').from('2').to('6')
I think
group()would work well here:Note that the second
by()modulator is a reducing operation for the collected items you grouped. In there you may manipulate that collection further as needed. To demonstrated I modified your data a bit:In the following case I just used
union()to create two lists - one of each "type":but you could use other collection manipulation techniques to get it into other forms of course.