3
我想读取一个GraphML文件,并使用它与Gremlin遍历。我使用相同的代码,因为这页:正确的方式来阅读GraphML文件与Gremlin使用Groovy
http://tinkerpop.apache.org/docs/3.1.1-incubating/reference/
我写与writeGraph的例子图和读回与readGraph。图表上的toString()调用使得 显示图形被正确读入(每个都有6个节点和6个顶点),但是然后应用Gremlin遍历只产生了TinkerFactory图形的输出,而不是那个是读入。
代码@Grab('org.apache.tinkerpop:tinkergraph-gremlin:3.1.1-incubating')
@Grab('org.apache.tinkerpop:gremlin-core:3.1.1-incubating')
import org.apache.tinkerpop.gremlin.structure.Graph;
import org.apache.tinkerpop.gremlin.structure.io.IoCore;
import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerFactory;
import org.apache.tinkerpop.gremlin.tinkergraph.structure.TinkerGraph;
final Graph graph = TinkerFactory.createModern();
graph.io(IoCore.graphml()).writeGraph("test.xml");
final Graph newGraph = TinkerGraph.open();
newGraph.io(IoCore.graphml()).readGraph("test.xml");
def g = graph.traversal();
def n = newGraph.traversal();
println("Graph")
println(g.toString())
g.V(1).out().values('name').sideEffect{println it}.iterate()
println("newGraph")
println(n.toString())
n.V(1).out().values('name').sideEffect{println it}.iterate()
println("DONE")
输出
Graph
graphtraversalsource[tinkergraph[vertices:6 edges:6], standard]
lop
vadas
josh
newGraph
graphtraversalsource[tinkergraph[vertices:6 edges:6], standard]
DONE
代码似乎与GraphSON和陀螺仪的输出来工作。