You can do this...
g.v(1,2,3,4).filter{it.nodeType == 'Category'}.each{ g.addEdge(it, g.v(55), 'Category') }
...or...
Use Groovy's collect method to convert the list of IDs to a list of vertices, and then use Gremlin's Identity pipe to convert the list into a pipe Gremlin can use...
start = [1,2,3,4].collect{ g.v(it) }
categories = start._().filter{ it.nodeType == 'Category' }
categories.each{ g.addEdge(it, g.v(55), 'Category') }
...or as a one liner...
[1,2,3,4].collect{ g.v(it) }._().filter{it.nodeType == 'Category'}.each{ g.addEdge(it, g.v(55), 'Category') }
- James