| 96 | // in the extensions of graph, namely code to handle weighted graphs. |
| 97 | // The third is not mentioned but is a necessary add on to read weights. |
| 98 | public static void setEdgeWeighted(TransactionContext tcx, final String node, final String neighbor, final long weight){ |
| 99 | tcx.run(new Function<Transaction,Void>(){ |
| 100 | public Void apply(Transaction tr){ |
| 101 | ByteBuffer b = ByteBuffer.allocate(8); |
| 102 | b.order(ByteOrder.LITTLE_ENDIAN); |
| 103 | b.putLong(weight); |
| 104 | tr.set(wEdge.pack(Tuple.from(node,neighbor)), b.array()); |
| 105 | tr.set(wInverse.pack(Tuple.from(neighbor,node)), b.array()); |
| 106 | return null; |
| 107 | } |
| 108 | }); |
| 109 | } |
| 110 | |
| 111 | public static void updateEdgeWeight(TransactionContext tcx, final String node, final String neighbor, final long change){ |
| 112 | tcx.run(new Function<Transaction,Void>() { |