Hello,
It is a bit unclear what exactly you are asking for here but I think you essentially have a tree where you want to return a different set of properties for the root versus the children. If this is the case you can do this by using the
project() step which would look something like this if you use the modern graph.
gremlin> g.V(1).project('workgroup', 'worker').by(elementMap()).by(repeat(both().simplePath()).emit().dedup().elementMap().fold())
==>[workgroup:[id:1,label:person,name:marko,age:29],worker:[[id:3,label:software,name:lop,lang:java],[id:2,label:person,name:vadas,age:27],[id:4,label:person,name:josh,age:32],[id:6,label:person,name:peter,age:35],[id:5,label:software,name:ripple,lang:java]]]
In your example the query would look something like:
g.V().has('workgroup', 'workGroupID','xxxxx').project('workgroup', 'worker').
by(elementMap()).
by(repeat(in('memberOf').simplePath()).emit().dedup().elementMap().fold())
If this is not the case then if you could provide a sample script to create a small test graph as well as what you would like to see for results it would go a long way in helping us provide a better answer.
Thanks,
Dave