}
private void createData(GraphDatabaseAPI db, int max) {
Transaction tx = db.beginTx();
try {
final IndexManager indexManager = db.index();
Node[] nodes = new Node[max];
for (int i = 0; i < max; i++) {
nodes[i] = db.createNode();
final Index<Node> index = indexManager.forNodes("node_index_" + String.valueOf(i % 5));
index.add(nodes[i],"ID",i);
}
Random random = new Random();
for (int i = 0; i < max * 2; i++) {
int from = random.nextInt(max);
final int to = (from + 1 + random.nextInt(max - 1)) % max;
final Relationship relationship = nodes[from].createRelationshipTo(nodes[to], DynamicRelationshipType.withName("TEST_" + i));
final Index<Relationship> index = indexManager.forRelationships("rel_index_" + String.valueOf(i % 5));
index.add(relationship, "ID", i);
}
tx.success();
} finally {
tx.finish();