![](/img/trans.png)
[英]How can I view the visual graph representation of the nodes created from a Neo4J Java Application?
[英]How can I get the number of nodes of a Neo4j graph database from java and can we store and reuse graphdb from disk?
我剛剛開始研究neo4j,以將其用於與社交網絡相關的項目。 在此期間,我遇到了以下代碼:
https://github.com/neo4j/neo4j/blob/1.9.M04/community/embedded-examples/src/main/java/org/neo4j/examples/EmbeddedNeo4jWithIndexing.java
在瀏覽過程中(請參閱上面的代碼鏈接),我一直在努力地了解如何獲取添加到給定graphDb
的節點graphDb
。 有什么方法可以使用graphDb
或nodeIndex
或referenceIndex
或其他方式找到它(節點總數)? 如果是,如何?
我還需要幫助才能知道,如何將graphdb存儲到磁盤上的任何給定路徑? 如何加載此存儲的graphdb並對其執行操作,例如搜索節點/關系等?
(執行上述代碼時,在給定的DB_PATH
創建了多個文件,例如* .db,*。id,*。keys等。這些文件有什么用處?這些文件中是否包含創建的節點?如果是,我們如何使用它們?)
我們如何從Web界面(例如位於http://localhost:7474/webadmin/
Dashboard或http://localhost:7474/db/data/
訪問此graphDb
?
如果您需要任何特定信息來幫助我,請告訴我。
謝謝你,尼丁。
有關Neo4j Embedded和Java API的入門,請參閱:
http://docs.neo4j.org/chunked/milestone/tutorials-java-embedded.html
獲取正確的節點和關系數:
IteratorUtil.count(GlobalGraphOperations.at(gdb).getAllNodes())
IteratorUtil.count(GlobalGraphOperations.at(gdb).getAllRelationships())
有關使用集成neo4j服務器訪問嵌入式圖形數據庫的信息,請參見http://docs.neo4j.org/chunked/milestone/server-embedded.html
哎呀! 這些對於一個條目來說是很多問題...
要獲取數據庫中節點和關系的總數,請使用:
NodeManager nodeManager = ((GraphDatabaseAPI) graphDb).getDependencyResolver().resolveDependency(
NodeManager.class);
long currentRelationships = nodeManager.getNumberOfIdsInUse(Relationship.class);
long currentNodes = nodeManager.getNumberOfIdsInUse(Node.class);
要更改圖形數據庫的路徑,只需將路徑傳遞給GraphDatabaseFactory()。newEmbeddedDatabase方法。 在您提到的示例中,您可以簡單地將DB_PATH設置為/home/youruser/neo4j
。
要使用Webadmin訪問數據庫,請下載neo4j,更改文件conf/neo4j-server.properties
的org.neo4j.server.database.location屬性,並將其指向數據庫的路徑並啟動服務器。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.