Hi I am trying to use TinkerGraph
for some small cases of demonstration and it seems that it doesn't persist using GraphTraversalSource
. Here is the code I currently have:
GraphTraversalSource g = TinkerGraph.open().traversal();
System.out.println(g.V().addV("testlabel").iterate());
System.out.println(g.V().count().next().intValue()); //returns 0
try {g.close(); }
catch(Exception e){
e.printStackTrace();
}
System.out.println(g.V().count().next().intValue()); //returns 0
and here is the output:
[TinkerGraphStep(vertex,[]), AddVertexStep({label=[testlabel]})]
0
0
I know that this works instead:
Graph graph = TinkerGraph.open();
Vertex gremlin = graph.addVertex("testlabel");
System.out.println(IteratorUtils.count(graph.vertices()) == 1);
Thank you :)
It looks like you need to use addV right from the GraphTraversalSource object not from V() (At least for the first object). The following code persists the vertexes in the gremlin console