@Override public void compute(String label, String type, int iterations) { degree = new int[nodeCount]; Arrays.fill(degree, -1); try ( Transaction tx = db.beginTx()) { ThreadToStatementContextBridge ctx = this.db.getDependencyResolver().resolveDependency(ThreadToStatementContextBridge.class); ReadOperations ops = ctx.get().readOperations(); int labelId = ops.labelGetForName(label); int relationshipTypeId = ops.relationshipTypeGetForName(type); PrimitiveLongIterator it = ops.nodesGetForLabel(labelId); int totalCount = nodeCount; runOperations(pool, it, totalCount, ops, new OpsRunner() { public void run(int id) throws EntityNotFoundException { degree[id] = ops.nodeGetDegree(id, direction, relationshipTypeId); } }); tx.success(); } catch (Exception e) { e.printStackTrace(); } }
ReadOperations ops = ctx.get().readOperations(); int labelId = ops.labelGetForName(label); int typeId = ops.relationshipTypeGetForName(type);
@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(); } }
key = readOperationsOn( db ).propertyKeyGetForName( "key" ); mandatory = tokenWriteOperationsOn( db ).propertyKeyGetOrCreateForName( "mandatory" ); C = readOperationsOn( db ).relationshipTypeGetForName( "C" ); T = readOperationsOn( db ).relationshipTypeGetForName( "T" ); M = tokenWriteOperationsOn( db ).relationshipTypeGetOrCreateForName( "M" );