1

我使用以下代码使用 Tinkerpop api 创建了图形并添加了顶点和边

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));

但我想获取图表中的所有边和顶点我在下面的代码中尝试过,它无法在 com.arangodb.blueprints.batch.ArangoDBBatchGraph.getVertices(ArangoDBBatchGraph.java :277) 在 mydb.ArangodbTest.TestConnection.main(TestConnection.java:54)

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));

请帮助使用来自 arangodb 的 tinkerpop api 获取所有边和顶点

提前致谢

4

1 回答 1

0

ArangoDBBatchGraph不支持方法getVertices()getEdges()。您必须使用ArangoDBGraph而不是ArangoDBBatchGraph.

除此之外,您的代码应该可以工作。

于 2016-10-24T11:33:36.303 回答