private static Graph buildGraph() {
BaseConfiguration configuration = new BaseConfiguration();
configuration.setProperty("gremlin.tinkerGraph.vertexIdManager", "ANY");
return TinkerGraph.open(configuration);
}
@Test
public void test() {
Graph graph = buildGraph();
GraphTraversalSource g;
g = AnonymousTraversalSource.traversal().withEmbedded(graph);
g.addV("source").property(T.id, "firstSource")
.addV("sink").property(T.id, "firstSink")
.addE("edge").property(T.id, "firstEdge").from(__.V("firstSource")).to(__.V("firstSink"))
.iterate();
g.addV("source").property(T.id, "secondSource")
.addV("sink").property(T.id, "secondSink")
.addE("edge").property(T.id, "secondEdge").from(__.V("secondSource")).to(__.V("secondSink"))
.iterate();
final Graph firstResult = (Graph) g.E("firstEdge").subgraph("subgraph").cap("subgraph").next();
GraphTraversalSource firstGts = AnonymousTraversalSource.traversal().withEmbedded(firstResult);
firstGts.io("src/test/resources/example.json").write().iterate();
// Here the initial contents of the file are overwritten
final Graph secondResult = (Graph) g.E("secondEdge").subgraph("subgraph").cap("subgraph").next();
GraphTraversalSource secondGts = AnonymousTraversalSource.traversal().withEmbedded(secondResult);
secondGts.io("src/test/resources/example.json").write().iterate();
}
private static Graph buildGraph() {
BaseConfiguration configuration = new BaseConfiguration();
configuration.setProperty("gremlin.tinkerGraph.vertexIdManager", "ANY");
return TinkerGraph.open(configuration);
}
@Test
public void test() {
Graph graph = buildGraph();
GraphTraversalSource g;
g = AnonymousTraversalSource.traversal().withEmbedded(graph);
g.addV("source").property(T.id, "firstSource")
.addV("sink").property(T.id, "firstSink")
.addE("edge").property(T.id, "firstEdge").from(__.V("firstSource")).to(__.V("firstSink"))
.iterate();
g.addV("source").property(T.id, "secondSource")
.addV("sink").property(T.id, "secondSink")
.addE("edge").property(T.id, "secondEdge").from(__.V("secondSource")).to(__.V("secondSink"))
.iterate();
final Graph firstResult = (Graph) g.E("firstEdge").subgraph("subgraph").cap("subgraph").next();
GraphTraversalSource firstGts = AnonymousTraversalSource.traversal().withEmbedded(firstResult);
firstGts.io("src/test/resources/example.json").write().iterate();
// Here the initial contents of the file are overwritten
final Graph secondResult = (Graph) g.E("secondEdge").subgraph("subgraph").cap("subgraph").next();
GraphTraversalSource secondGts = AnonymousTraversalSource.traversal().withEmbedded(secondResult);
secondGts.io("src/test/resources/example.json").write().iterate();
}