private static void storeNodeCentrality(Connection connection, TableLocation nodesName, KeyedGraph graph) throws SQLException { final PreparedStatement nodeSt = connection.prepareStatement("INSERT INTO " + nodesName + " VALUES(?,?,?)"); try { int count = 0; for (VCent v : (Set<VCent>) graph.vertexSet()) { nodeSt.setInt(1, v.getID()); nodeSt.setDouble(2, v.getBetweenness()); nodeSt.setDouble(3, v.getCloseness()); nodeSt.addBatch(); count++; if (count >= BATCH_SIZE) { nodeSt.executeBatch(); nodeSt.clearBatch(); count = 0; } } if (count > 0) { nodeSt.executeBatch(); nodeSt.clearBatch(); } connection.commit(); } finally { nodeSt.close(); } }
for (V predecessor : (Set<V>) w.getPredecessors()) { final double sigmaFactor = ((double) predecessor.getSPCount() / w.getSPCount()); final double depContribution = sigmaFactor * (1 + w.getDependency()); predecessor.accumulateDependency(depContribution); final double oldBetw = w.getBetweenness(); w.accumulateBetweenness(w.getDependency());
for (V node : nodeSet) { final double normalizedBetweenness = (node.getBetweenness() - minBetweenness) / vertexBetwRange; node.setBetweenness(normalizedBetweenness);
/** * Finds the maximum and minimum betweenness values. */ private void findExtremeBetweennessValues() { long start = System.currentTimeMillis(); for (V node : nodeSet) { final double betweenness = node.getBetweenness(); if (betweenness > maxBetweenness) { maxBetweenness = betweenness; } if (betweenness < minBetweenness) { minBetweenness = betweenness; } } for (E edge : graph.edgeSet()) { final double betweenness = edge.getBetweenness(); if (betweenness > maxEdgeBetweenness) { maxEdgeBetweenness = betweenness; } if (betweenness < minEdgeBetweenness) { minEdgeBetweenness = betweenness; } } long stop = System.currentTimeMillis(); LOGGER.info("({} ms) Extreme betweenness values v({}, {}), e({}, {}).", (stop - start), minBetweenness, maxBetweenness, minEdgeBetweenness, maxEdgeBetweenness); } }
private static void storeNodeCentrality(Connection connection, TableLocation nodesName, KeyedGraph graph) throws SQLException { final PreparedStatement nodeSt = connection.prepareStatement("INSERT INTO " + nodesName + " VALUES(?,?,?)"); try { int count = 0; for (VCent v : (Set<VCent>) graph.vertexSet()) { nodeSt.setInt(1, v.getID()); nodeSt.setDouble(2, v.getBetweenness()); nodeSt.setDouble(3, v.getCloseness()); nodeSt.addBatch(); count++; if (count >= BATCH_SIZE) { nodeSt.executeBatch(); nodeSt.clearBatch(); count = 0; } } if (count > 0) { nodeSt.executeBatch(); nodeSt.clearBatch(); } connection.commit(); } finally { nodeSt.close(); } }
private static void storeNodeCentrality(Connection connection, TableLocation nodesName, KeyedGraph graph) throws SQLException { final PreparedStatement nodeSt = connection.prepareStatement("INSERT INTO " + nodesName + " VALUES(?,?,?)"); try { int count = 0; for (VCent v : (Set<VCent>) graph.vertexSet()) { nodeSt.setInt(1, v.getID()); nodeSt.setDouble(2, v.getBetweenness()); nodeSt.setDouble(3, v.getCloseness()); nodeSt.addBatch(); count++; if (count >= BATCH_SIZE) { nodeSt.executeBatch(); nodeSt.clearBatch(); count = 0; } } if (count > 0) { nodeSt.executeBatch(); nodeSt.clearBatch(); } connection.commit(); } finally { nodeSt.close(); } }