Aravind Yarram
Aravind Yarram

Reputation: 80194

Why does neo4j always has a single node?

The below code prints id: 0. Why is there a node in empty graph db?

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

Upvotes: 0

Views: 96

Answers (2)

Gopi
Gopi

Reputation: 10293

Its never really an empty graph db, there is a graph with one node - the reference node with id 0. Neo4j always has this node created by default.

Also refer : should everything connect with node 0 in neo4j

Upvotes: 2

Nicholas
Nicholas

Reputation: 7521

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.

Upvotes: 2

Related Questions