Save gremlin query result as a GraphML?

1,108 views
Skip to first unread message

Alonci

unread,
Jan 26, 2013, 5:29:13 AM1/26/13
to gremli...@googlegroups.com
Hi,
Is there a simple way to convert GremlinPipeline query result to Graph object?
I am trying to save the result of a query in a graphML format.

thank
Alon

Stephen Mallette

unread,
Jan 26, 2013, 6:32:08 AM1/26/13
to gremli...@googlegroups.com
We've discussed how to do a natural way to do a subgraph in gremlin
for a while, but no solid ideas have yet been realized. I typically
try to write the traversal in such a way that it yields the easiest
way possible to sideEffect out the elements i want into another graph.

Stephen
> --
>
>

Marko A. Rodriguez

unread,
Jan 26, 2013, 11:45:22 AM1/26/13
to gremli...@googlegroups.com
Hi,

I'll be going through this process next week for a client so I'll give a heads up on the pattern I ultimately use. But yes, Stephen's technique is what first came to my mind.

1. Use a Gremlin select()-based traversal to grab elements out of one graph.
2. Insert into TinkerGraph.
3. GraphMLWriter.outputGraph(tinkerGraph).

Marko.

http://markorodriguez.com
> --
>
>

Derrick Johnson

unread,
Apr 11, 2013, 11:38:57 AM4/11/13
to gremli...@googlegroups.com
Hi,

I'm curious about what you could find on this.  For example, a method which takes in the parameters of your query, does the traversal, aggregates the results, and returns the result as a Graph object.

Best Wishes,
-Derrick

Yanxin Zhang

unread,
Oct 10, 2013, 8:14:41 PM10/10/13
to gremli...@googlegroups.com
Hello Marko,
Sorry to dig the old question and ask the similar question here. 

I want to extract the sub-graph from gremlin traversal, and put it into gephi. 

I am not quite sure how to use select()-based traversal to grab elements and dump them into TinkerGraph.  

Can you give me some simple example? 

Yanxin

Stephen Mallette

unread,
Oct 11, 2013, 5:12:38 AM10/11/13
to gremli...@googlegroups.com
Here's  the simple way I was suggesting:


Using select() isn't so different:

gremlin> g = TinkerGraphFactory.createTinkerGraph()                      
==>tinkergraph[vertices:6 edges:6]
gremlin> g.v(1).as('marko').outE.as('markoTo').inV.as('something').select
==>[marko:v[1], markoTo:e[7][1-knows->2], something:v[2]]
==>[marko:v[1], markoTo:e[8][1-knows->4], something:v[4]]
==>[marko:v[1], markoTo:e[9][1-created->3], something:v[3]]

I've used to select() to get the "marko" subgraph...just write those vertices/edges into a new TinkerGraph and you have your new subgraph.  It remains to be seen if we could have a more fluid way of doing subgraphing in TinkerPop3.

Stephen



--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-user...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

ni...@knoldus.com

unread,
May 11, 2016, 3:34:07 AM5/11/16
to Gremlin-users
Hi stephen,

can you please tell us how do we export titangraph to graphml?. I went through tinkerpop documentation but didn't find anything.

Thanks 

Dylan Millikin

unread,
May 11, 2016, 4:35:49 AM5/11/16
to gremli...@googlegroups.com
Hey,

Unless I'm misunderstanding, provided a titan graph (graph) the following should work:

graph.io(IoCore.graphml()).writeGraph("path/to/graphml.xml");



--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-user...@googlegroups.com.

ni...@knoldus.com

unread,
May 16, 2016, 6:25:27 AM5/16/16
to Gremlin-users
Hi Dmill,

Thanks for your reply. I have one more question, lets say that is execute :> x =1 in my gremlin shell which sends x = 1 to gremlin server then how can i retrieve back value of x ? 

Thanks
Nitin

Dylan Millikin

unread,
May 16, 2016, 8:57:34 AM5/16/16
to gremli...@googlegroups.com
You can do it with :
         \,,,/
         (o o)
-----oOOo-(3)-oOOo-----
gremlin> x = 1
==>1
gremlin> x
==>1

If you're using a driver to communicate with gremlin-server you will need to check the driver documentation and run your queries in "session" mode.

--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-user...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages