tags:

views:

211

answers:

1

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?

+4  A: 

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.

nawroth
Thanks, was very helpful, but shouldn't getNodeModule() be getNeoModule()
Kevin Loney
Oops, thanks for pointing that out! I updated the code sample.
nawroth
This is now documented in the Neo4j FAQ: http://wiki.neo4j.org/content/FAQ#How_can_I_get_the_total_number_of_nodes_and_relationships_currently_in_Neo4j.3F
nawroth