public static function main()
 {
     echo "<pre>";
     self::printTime("initializing...");
     self::clearDir(self::$NEO4J_DB, false);
     self::$neo = new java("org.neo4j.kernel.EmbeddedGraphDatabase", self::$NEO4J_DB);
     self::$neo->shutdown();
     self::printTime("clean db created");
     self::$inserter = new java("org.neo4j.kernel.impl.batchinsert.BatchInserterImpl", self::$NEO4J_DB);
     self::createChildren(self::$inserter->getReferenceNode(), 10, 1);
     self::$inserter->shutdown();
     self::printTime("nodes created");
     self::$neo = new java("org.neo4j.kernel.EmbeddedGraphDatabase", self::$NEO4J_DB);
     for ($i = 0; $i < 10; $i++) {
         echo "\ntraversing through all nodes and counting depthSum...";
         $tx = self::$neo->beginTx();
         $traverser = self::$neo->getReferenceNode()->traverse(java('org.neo4j.graphdb.Traverser$Order')->BREADTH_FIRST, java('org.neo4j.graphdb.StopEvaluator')->END_OF_GRAPH, java('org.neo4j.graphdb.ReturnableEvaluator')->ALL_BUT_START_NODE, java('org.neo4j.graphdb.DynamicRelationshipType')->withName('PARENT'), java('org.neo4j.graphdb.Direction')->OUTGOING);
         $depthSum = 0;
         $nodes = $traverser->iterator();
         while (java_values($nodes->hasNext())) {
             $node = $nodes->next();
             $depthSum += intval(java_values($node->getProperty("level")));
         }
         $tx->finish();
         $tx->success();
         echo "\ndepthSum = {$depthSum}";
         self::printTime("done traversing");
     }
     self::$neo->shutdown();
     echo "\nneo has been shut down";
     echo "</pre>";
 }
<?php

/* ----- bootstrap config ----- */
set_include_path(get_include_path() . PATH_SEPARATOR . realpath(dirname(__FILE__)));
require_once 'Zend/Loader/Autoloader.php';
Zend_Loader_Autoloader::getInstance()->registerNamespace('PetroQuick_');
/* ---------------------------- */
set_time_limit(0);
PetroQuick_Neo4J_Bench_SimpleTest::$NEO4J_DB = realpath(dirname(__FILE__) . '/../db-p');
PetroQuick_Neo4J_Bench_SimpleTest::main();