private void createDbIfNecessary() {
   if (!new File(storeDir, "neostore").exists()) {
     db = new GraphDatabaseFactory().newEmbeddedDatabase(storeDir.getPath());
     BatchTransaction tx = beginBatchTx(db);
     try {
       Node node = db.createNode();
       createRelationships(tx, node, MyRelTypes.TEST, INCOMING, 1);
       createRelationships(tx, node, MyRelTypes.TEST, OUTGOING, 3_000_000);
       createRelationships(tx, node, MyRelTypes.TEST2, OUTGOING, 5);
       createRelationships(tx, node, MyRelTypes.TEST2, BOTH, 5);
       createRelationships(tx, node, MyRelTypes.TEST_TRAVERSAL, OUTGOING, 2_000_000);
       createRelationships(tx, node, MyRelTypes.TEST_TRAVERSAL, INCOMING, 2);
     } finally {
       tx.close();
       db.shutdown();
     }
   }
 }
 private void createRelationships(
     BatchTransaction tx, Node node, RelationshipType type, Direction direction, int count) {
   for (int i = 0; i < count; i++) {
     Node firstNode = direction == OUTGOING || direction == BOTH ? node : db.createNode();
     Node otherNode = direction == INCOMING || direction == BOTH ? node : db.createNode();
     firstNode.createRelationshipTo(otherNode, type);
     tx.increment();
   }
 }