Foreach edge export the vertices id's to csv

366 views
Skip to first unread message

Jamie Scott

unread,
Nov 4, 2015, 11:47:58 AM11/4/15
to Gremlin-users
Trying to write a simple gremlin script to take all the edges from:

g.V().outE('FOLLOWS')


and write all the vertices id's to a csv file.


vid1,vid2

vid1,vid2


What is the most efficient way to loop through and export using gremlin on a massive graph?


Thanks



Daniel Kuppitz

unread,
Nov 4, 2015, 11:50:14 AM11/4/15
to gremli...@googlegroups.com
Can you define "massive graph? How many vertices / edges?

Cheers,
Daniel


--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/0a463994-ca91-4eff-9390-b073ddd84ffa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jamie Scott

unread,
Nov 4, 2015, 11:55:48 AM11/4/15
to Gremlin-users
The graph has about 500 million vertices and over a billion edges. Not counted.

Can't seem to get the id's only.

So far:

g.V().as('from').outE('FOLLOWS').inV().as('to').select('from','to')

Will probably just use file.append once I can just return a line with the 2 id's

Thanks

Daniel Kuppitz

unread,
Nov 4, 2015, 12:02:28 PM11/4/15
to gremli...@googlegroups.com
Ok, that's huge, I was expecting a much smaller graph. A BulkDumpVertexProgram is still on our TODO list:


Unfortunately, I can't think of a nice way to do it with the tools that we currently have.

Cheers,
Daniel


Jamie Scott

unread,
Nov 4, 2015, 12:07:28 PM11/4/15
to Gremlin-users
In fairness it will be a subset but still large.

Whats the most efficient way of looping through all the edges and just echoing the adjacent vertices id's out using groovy?

Cheers

Daniel Kuppitz

unread,
Nov 4, 2015, 12:12:54 PM11/4/15
to gremli...@googlegroups.com
Yea I would try that first. Something like:

new File('/tmp/result.txt').withWriter { def w ->
  g.V().has("foo","bar").outE().each { def e ->
    w << e.outVertex().id() + "\t" + e.inVertex().id() + "\n"
  }
}

Cheers,
Daniel


Jamie Scott

unread,
Nov 4, 2015, 12:16:10 PM11/4/15
to Gremlin-users
Cheers. 

Jamie Scott

unread,
Nov 4, 2015, 12:51:19 PM11/4/15
to Gremlin-users
14 million rows in a a couple of minutes. That will do nicely !
Reply all
Reply to author
Forward
0 new messages