Adding an edge to a non-existent vertex creates a shell vertex

Hi,

I recently noticed an odd behaviour when using the Java Janusgraph library (version 1.1.0) to add edges.

Adding an edge from an existing vertex S, to a non-existing vertex T, will automatically create an empty shell vertex for T.

Is this an intended and reliable behavior that is documented somewhere?

Simplified example:
var transaction = graph.buildTransaction().start(); // graph is a StandardJanusGraph
var g = transaction.traversal();
g.inject(1).addE(edgeLabel).from(V("ExistingVertexId")).to(V("MissingVertexId")).iterate();
transaction.commit();


This creates a shell vertex with the label
vertex
and no properties, which I can see from the gremlin console:

gremlin> g.V("MissingVertexId").label()
==>vertex
gremlin> g.V("MissingVertexId").valueMap()
==>[]


Other observations:
  • Trying to add an edge through the gremlin console in the same way fails with an error about the non-existing target vertex
  • Adding the missing vertex later using the Java library successfully adds the label and properties to the vertex, and preserves the previously-added edge
Thanks in advance!
Was this page helpful?