@Override
public void compute(String label, String type, int iterations) {
float[] src = new float[nodes];
dst = new float[nodes];
try ( Transaction tx = db.beginTx()) {
ThreadToStatementContextBridge ctx = this.db.getDependencyResolver().resolveDependency(ThreadToStatementContextBridge.class);
ReadOperations ops = ctx.get().readOperations();
int labelId = ops.labelGetForName(label);
int typeId = ops.relationshipTypeGetForName(type);
int[] degrees = computeDegrees(ops,labelId, typeId);
RelationshipVisitor<RuntimeException> visitor = new RelationshipVisitor<RuntimeException>() {
public void visit(long relId, int relTypeId, long startNode, long endNode) throws RuntimeException {
if (relTypeId == typeId) {
dst[((int) endNode)] += src[(int) startNode];
}
}
};
for (int iteration = 0; iteration < iterations; iteration++) {
startIteration(src, dst, degrees);
PrimitiveLongIterator rels = ops.relationshipsGetAll();
while (rels.hasNext()) {
ops.relationshipVisit(rels.next(), visitor);
}
}
tx.success();
} catch (EntityNotFoundException e) {
e.printStackTrace();
}
}