@Override protected void addEdges(KeyedGraph<? extends VCent, EdgeCent> graph) { graph.addEdge(1, 2); graph.addEdge(1, 3); graph.addEdge(1, 5); graph.addEdge(5, 2); graph.addEdge(2, 4); graph.addEdge(3, 4); }
private static void storeEdgeCentrality( Connection connection, TableLocation edgesName, KeyedGraph graph) throws SQLException { final PreparedStatement edgeSt = connection.prepareStatement("INSERT INTO " + edgesName + " VALUES(?,?)"); try { int count = 0; for (EdgeCent e : (Set<EdgeCent>) graph.edgeSet()) { edgeSt.setInt(1, e.getID()); edgeSt.setDouble(2, e.getBetweenness()); edgeSt.addBatch(); count++; if (count >= BATCH_SIZE) { edgeSt.executeBatch(); edgeSt.clearBatch(); count = 0; } } if (count > 0) { edgeSt.executeBatch(); edgeSt.clearBatch(); } connection.commit(); } finally { edgeSt.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(); } }