0

I have one Gremlin traversal that looks like this:

g.V().hasLabel("Firma").has("cui","2816464") 
..........subgraph('sub') ......otherV() ...?????....

If I want to get a collection of vertex properties I will end the traversal with:

 "values('prop')"

If I want to save the subgraph in a 'graphml' format I will end the traversal with:

 cap('sub').next().io(IoCore.graphml()).writeGraph('/tmp/a2.xml')

How could I achieve both in a single traversal and get the collection of vertex properties while saving the subgraph in Graphml format?

Mihai Bucica
  • 21
  • 1
  • 5

1 Answers1

0

I assume that you want to return GraphML and not store it on the server, so I've written this answer accordingly. If you are using Java you could do this:

gremlin> g.V().hasLabel('person').
......1>   outE().
......2>   subgraph('sub').
......3>   inV().
......4>   values('name').as('props').
......5>   union(cap('sub'),select('props').fold())
==>tinkergraph[vertices:6 edges:6]
==>[lop,lop,lop,vadas,josh,ripple]

and then generate the GraphML on the client side. If you aren't using Java, I think you would be stuck submitting a script like this:

t = g.V().hasLabel('person').
  outE().
  subgraph('sub').
  inV().
  values('name').store('props').
  cap('sub')
result = []
result << t.next()..... // write graph to GraphML string to place in result
result << t.getSideEffects().get('props')
stephen mallette
  • 45,298
  • 5
  • 67
  • 135
  • I like the second option you presented me. I am sending Gremlin scripts to Gremlin Server from a PHP script via HTTP. Need to return GraphML for use in browser client ( Cytoscape.js has an extension allowing me to directly load a GraphML) and also returning some other node properties to the same browser client .Thanks alot for your answer. – Mihai Bucica Feb 16 '18 at 18:41