Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Counting primitives in Neo4j

Tags:

java

neo4j

I have been reading through the documentation for neo4j and it's components and have yet to come across functionality that lets me query the total number of primitives (nodes, relationships, and properties) in the graph. Does this functionality exist somewhere or am I going to have to write code that traverses the entire graph counting as it goes?

like image 426
Kevin Loney Avatar asked Jul 10 '09 18:07

Kevin Loney


People also ask

How many nodes are in Neo4j?

The limitation is currently 2^35, so approximately 34 billion nodes.

How many nodes can a single relationship connect in Neo4j?

Relationships provide directed, named semantic connections between two nodes. A relationship always has a direction, a type, a start node, and an end node.

How can you find out all procedures that are available on your Neo4j instance?

Neo4j comes with a number of built-in procedures. For a list of these, see Operations Manual → Procedures. Users can also develop custom procedures and deploy to the database. See Java Reference → User-defined procedures for details.


2 Answers

Thanks for the question! I'm on the Neo4j team, and we currently have commercial tools which report this kind of information. However, an extension of the API is scheduled for the next open source version. For the time being you can use the following non-official API:

EmbeddedNeo.getConfig().getNeoModule().getNodeManager().getNumberOfIdsInUse(Class)

where the class would be Node.class, Relationship.class or PropertyStore.class.

like image 146
nawroth Avatar answered Oct 18 '22 23:10

nawroth


This worked for me:

import org.neo4j.kernel.impl.nioneo.store.PropertyStore

graph.getConfig().getGraphDbModule().getNodeManager().getNumberOfIdsInUse(Node.class);
graph.getConfig().getGraphDbModule().getNodeManager().getNumberOfIdsInUse(Relationship.class);
graph.getConfig().getGraphDbModule().getNodeManager().getNumberOfIdsInUse(PropertyStore.class)
like image 34
Arthur van Hoff Avatar answered Oct 18 '22 23:10

Arthur van Hoff