Java 如何在arangodb中使用Tinkerpop blueprints API获取所有顶点和边
我使用下面的代码创建了图形,并使用TinkerpoAPI添加了顶点和边Java 如何在arangodb中使用Tinkerpop blueprints API获取所有顶点和边,java,arangodb,tinkerpop,tinkerpop-blueprint,Java,Arangodb,Tinkerpop,Tinkerpop Blueprint,我使用下面的代码创建了图形,并使用TinkerpoAPI添加了顶点和边 ArangoDBBatchGraph arang = new ArangoDBBatchGraph("localhost", 8529, "testgraph", "testcollection", "testedgecollection"); Vertex user = null; Vertex preVertex = null; preVertex = arang.addV
ArangoDBBatchGraph arang = new ArangoDBBatchGraph("localhost", 8529, "testgraph", "testcollection", "testedgecollection");
Vertex user = null;
Vertex preVertex = null;
preVertex = arang.addVertex(0);
preVertex.setProperty("name", "edgevertex");
long startTime = System.currentTimeMillis();
for(int rec = 1; rec<=10; rec++) {
user = arang.addVertex(rec);
user.setProperty("name", "user"+ rec);
user.setProperty("userid", rec);
user.setProperty("gender", "male");
user.setProperty("firstname", "user");
user.setProperty("lastname", rec);
user.setProperty("employee number", "emp0"+ rec);
arang.addEdge(rec, user, preVertex, "edge"+ rec);
preVertex = user;
}
System.out.println("write Time consumed : "+ (System.currentTimeMillis() - startTime));
arangodbatchgraph arang=新的arangodbatchgraph(“localhost”,8529,“testgraph”,“testcollection”,“testedgecollection”);
顶点用户=null;
顶点preVertex=null;
preVertex=arang.addVertex(0);
preVertex.setProperty(“名称”、“edgevertex”);
long startTime=System.currentTimeMillis();
for(int rec=1;recarangodbatchgraph
不支持方法getVertices()
和getEdges()
。必须使用arangodgraph
而不是arangodbatchgraph
除此之外,您的代码应该可以工作。ArangodBatchGraph
不支持方法getVertices()
和GetEdge()
。您必须使用ArangodGraph
而不是ArangodBatchGraph
除此之外,您的代码应该可以工作
startTime = System.currentTimeMillis();
Iterable<Vertex> iter = arang.getVertices();
List<Vertex> list = new ArrayList<Vertex>();
if(iter != null) {
for(final Vertex vert : iter) {
list.add(vert);
}
}
Iterable<Edge> iterEdge = arang.getEdges();
List<Edge> listEdge = new ArrayList<Edge>();
if(iter != null) {
for(Edge edge : iterEdge) {
listEdge.add(edge);
}
}
System.out.println("Read vertices list: "+ list.size() + ", Edges List: "+listEdge+ "; Time consumed : "+ (System.currentTimeMillis() - startTime));