One option may be to use something like Tinkerpop
blueprints
to create a generic Graph
when traversing, then doing a GraphML
export.
https://github.com/tinkerpop/blueprints/wiki/GraphML-Reader-and-Writer-Library would have more information, but if you are looking to export subgraphs, this is probably your best option.