public static Edge createEdge(final Attachable<Edge> attachableEdge, final Graph hostGraph) {
            final Edge baseEdge = attachableEdge.get();
            Iterator<Vertex> vertices = hostGraph.vertices(baseEdge.outVertex().id());
            final Vertex outV = vertices.hasNext() ? vertices.next() : hostGraph.features().vertex().willAllowId(baseEdge.outVertex().id()) ? hostGraph.addVertex(T.id, baseEdge.outVertex().id()) : hostGraph.addVertex();
            vertices = hostGraph.vertices(baseEdge.inVertex().id());
            final Vertex inV = vertices.hasNext() ? vertices.next() : hostGraph.features().vertex().willAllowId(baseEdge.inVertex().id()) ? hostGraph.addVertex(T.id, baseEdge.inVertex().id()) : hostGraph.addVertex();
            if (ElementHelper.areEqual(outV, inV)) {
                final Iterator<Edge> itty = outV.edges(Direction.OUT, baseEdge.label());
                while (itty.hasNext()) {
                    final Edge e = itty.next();
                    if (ElementHelper.areEqual(baseEdge, e))
                        return e;
                }
            }
            final Edge e = hostGraph.features().edge().willAllowId(baseEdge.id()) ? outV.addEdge(baseEdge.label(), inV, T.id, baseEdge.id()) : outV.addEdge(baseEdge.label(), inV);
            baseEdge.properties().forEachRemaining(p -> e.property(p.key(), p.value()));
            return e;
        }
A collection of general methods of attachment. Note that more efficient methods of attachment might exist
if the user knows the source data being attached and the features of the graph that the data is being
attached to.
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/util/Attachable.java