簡體   English   中英

如何在arangodb中使用Tinkerpop藍圖API來獲取所有頂點和邊緣

[英]how to use Tinkerpop blueprints API in arangodb to get all vertices and edges

我使用下面的代碼創建了圖形並使用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));

但我想得到圖中我試過的所有邊和頂點代碼,它不起作用拋出異常在線程“main”java.lang.UnsupportedOperationException中的異常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幫助獲取所有邊和頂點

提前致謝

ArangoDBBatchGraph不支持getVertices()getEdges() 您必須使用ArangoDBGraph而不是ArangoDBBatchGraph

除此之外,您的代碼應該可行。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM