@Override public void writeVertices(final OutputStream outputStream,final Iterator<Vertex> vertexIterator,final Direction direction) throws IOException {
  final BufferedWriter writer=new BufferedWriter(new OutputStreamWriter(outputStream));
  try (final ByteArrayOutputStream baos=new ByteArrayOutputStream()){
    if (wrapAdjacencyList)     writer.write("{\"" + GraphSONTokens.VERTICES + "\":[");
    while (vertexIterator.hasNext()) {
      writeVertex(baos,vertexIterator.next(),direction);
      writer.write(new String(baos.toByteArray()));
      if (wrapAdjacencyList) {
        if (vertexIterator.hasNext())         writer.write(",");
      }
 else {
        writer.newLine();
      }
      baos.reset();
    }
    if (wrapAdjacencyList)     writer.write("]}");
  }
   writer.flush();
}

@ Override public void writeVertices ( final OutputStream outputStream , final Iterator < Vertex > vertexIterator , final Direction direction ) throws IOException { final BufferedWriter writer = new BufferedWriter ( new OutputStreamWriter ( outputStream ) ) ; try ( final ByteArrayOutputStream baos = new ByteArrayOutputStream ( ) ) { if ( wrapAdjacencyList ) writer . write ( "{\"" + GraphSONTokens . VERTICES + "\":[" ) ; while ( vertexIterator . hasNext ( ) ) { writeVertex ( baos , vertexIterator . next ( ) , direction ) ; writer . write ( new String ( baos . toByteArray ( ) ) ) ; if ( wrapAdjacencyList ) { if ( vertexIterator . hasNext ( ) ) writer . write ( "," ) ; } else { writer . newLine ( ) ; } baos . reset ( ) ; } if ( wrapAdjacencyList ) writer . write ( "]}" ) ; } writer . flush ( ) ; }
writes a list of vertices in adjacency list format where vertices are written with edges from both directions . under this serialization model , edges are grouped by label .
