private void addEdgeToSubgraph(final Edge edge) {
        final Iterator<Edge> edgeIterator = subgraph.edges(edge.id());

        try {
            if (edgeIterator.hasNext()) return;
        } finally {
            CloseableIterator.closeIterator(edgeIterator);
        }

        final Iterator<Vertex> vertexIterator = edge.vertices(Direction.BOTH);
        final Vertex subGraphOutVertex = getOrCreate(vertexIterator.next());
        final Vertex subGraphInVertex = getOrCreate(vertexIterator.next());
        final Edge subGraphEdge = subGraphOutVertex.addEdge(edge.label(), subGraphInVertex, T.id, edge.id());
        edge.properties().forEachRemaining(property -> subGraphEdge.property(property.key(), property.value()));
    }
A side-effect step that produces an edge induced subgraph.

@author Stephen Mallette (http://stephen.genoprime.com)
@author Marko A. Rodriguez (http://markorodriguez.com)
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/sideEffect/SubgraphStep.java