0

下面的代码打印id: 0。为什么空图数据库中有一个节点?

GraphDatabaseService db = new GraphDatabaseFactory().newEmbeddedDatabase(DB_LOCATION);
GlobalGraphOperations graphOperations = GlobalGraphOperations.at(db);
System.out.println("id: "+graphOperations.getAllNodes().iterator().next().getId());
4

2 回答 2

2

它从来不是一个真正的空图数据库,有一个带有一个节点的图 - id 为 0 的参考节点。Neo4j 总是默认创建这个节点。

另请参阅: 是否所有内容都与 neo4j 中的节点 0 连接

于 2013-05-07T18:36:04.983 回答
2

By default, neo4j is created with what they call a Reference Node which is Node 0. You can delete this without consequence, and I believe that it may be phased out in Future releases, as you can see from the documentation on it that they are deprecating the call to retrieve it.

于 2013-05-07T18:38:05.687 回答