I've got a dataframe inside of Apache spark which I'd like to output as a .gt file.

The dataframe is a table of edges between vertices like so:
0 9
0 8
9 1

I read the guide on the custom gt file format, but how do I actually write one for my edges dataframe?  That too, inside of spark?  Any ideas/examples you could point me to?

Any help is appreciated, thank you!