private <O extends OutputShim> void writeEdges(final KryoShim<?, O> kryo, final O output, final StarGraph starGraph, final Direction direction) {
        // only write edges if there are some AND if the user requested them to be serialized AND if they match
        // the direction being serialized by the format
        final Map<String, List<Edge>> starEdges = direction.equals(Direction.OUT) ? starGraph.starVertex.outEdges : starGraph.starVertex.inEdges;
        final boolean writeEdges = null != starEdges && edgeDirectionToSerialize != null
                && (edgeDirectionToSerialize == direction || edgeDirectionToSerialize == Direction.BOTH);
        kryo.writeObject(output, writeEdges);
        if (writeEdges) {
            kryo.writeObject(output, starEdges.size());
            for (final Map.Entry<String, List<Edge>> edges : starEdges.entrySet()) {
                kryo.writeObject(output, edges.getKey());
                kryo.writeObject(output, edges.getValue().size());
                for (final Edge edge : edges.getValue()) {
                    kryo.writeClassAndObject(output, edge.id());
                    kryo.writeClassAndObject(output, direction.equals(Direction.OUT) ? edge.inVertex().id() : edge.outVertex().id());
                }
            }
        }
    }
If the returned {@link StarGraph} is null, that means that the {@link GraphFilter} filtered the vertex.
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/star/StarGraphSerializer.java