@Override
    protected void writeValue(final Edge value, final Buffer buffer, final GraphBinaryWriter context) throws IOException {

        context.write(value.id(), buffer);
        // wrapping label into list here for now according to GraphBinaryV4, but we aren't allowing null label yet
        if (value.label() == null) {
            throw new IOException("Unexpected null value when nullable is false");
        }
        context.writeValue(Collections.singletonList(value.label()), buffer, false);

        context.write(value.inVertex().id(), buffer);
        context.writeValue(Collections.singletonList(value.inVertex().label()), buffer, false);
        context.write(value.outVertex().id(), buffer);
        context.writeValue(Collections.singletonList(value.outVertex().label()), buffer, false);

        // we don't serialize the parent Vertex for edges.
        context.write(null, buffer);
        if (value instanceof ReferenceEdge) {
            context.write(null, buffer);
        }
        else {
            final List<?> asList = IteratorUtils.toList(value.properties());
            context.write(asList, buffer);
        }
    }
@author Stephen Mallette (http://stephen.genoprime.com)
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/binary/types/EdgeSerializer.java