throw new IllegalStateException(String.format("The direction %s was requested but no attempt was made to serialize edges into this stream", directionRequested));
// if there are edges in the stream and the direction is not present then the rest of the stream is
// simply ignored
if (directionRequested != null) {
final Direction directionsInStream = kryo.readObject(input, Direction.class);
if (directionsInStream != Direction.BOTH && directionsInStream != directionRequested)
throw new IllegalStateException(String.format("Stream contains %s edges, but requesting %s", directionsInStream, directionRequested));
final Direction firstDirection = kryo.readObject(input, Direction.class);
if (firstDirection == Direction.OUT && (directionRequested == Direction.BOTH || directionRequested == Direction.OUT))
readEdges(input, edgeMaker);
else {
// requested direction in, but BOTH must be serialized so skip this. the illegalstateexception
// prior to this IF should have caught a problem where IN is not supported at all