And yes, you can easily build your db with millions of nodes that way. Just try it for yourself.
Important is to choose a batch size for transactions that is not too small. E.g. commit each 10000 nodes. To speed it up further you may disable caching for only the import. Code sample below, it inserts 1 mio node in 3 secs on my mac. Cheers Michael package org.neo4j.load; import org.apache.commons.io.FileUtils; import org.neo4j.graphdb.GraphDatabaseService; import org.neo4j.graphdb.Transaction; import org.neo4j.kernel.AbstractGraphDatabase; import org.neo4j.kernel.EmbeddedGraphDatabase; import java.io.File; import java.io.IOException; import java.util.HashMap; import java.util.Map; public class Loader { public static final int COUNT = 10000; public static final int BATCHES = 100; public static void main(String[] args) throws IOException { FileUtils.deleteDirectory(new File("target/test")); Map<String, String> config=new HashMap<String, String>(); config.put("cache_type","weak"); // or "none" GraphDatabaseService gds = new EmbeddedGraphDatabase("target/test", config); long time = System.currentTimeMillis(); for (int i=0;i< BATCHES;i++) { createNodes(gds, COUNT); } time = System.currentTimeMillis() - time; System.out.println("time for "+BATCHES*COUNT+" = " + time/1000); } private static void createNodes(GraphDatabaseService gds, int count) { Transaction tx = gds.beginTx(); try { for (int i=0;i< count;i++) { gds.createNode(); } tx.success(); } finally { tx.finish(); } System.out.print("."); } } Am 10.05.2011 um 23:36 schrieb Marko Rodriguez: > Hey, > >> One more thing, is there any algorithm which shows the node that has the >> maximum of edges ?? > > > In Java, do: > > Map m = new HashMap(); > for(Node node : graph.getAllNodes()) { > for(Relationship rel : node.getRelationships()) { > c++; > } > m.put(node, c); > } > > ---------------- > > In Gremlin (http://gremlin.tinkerpop.com), do: > m = [:]; g.V.sideEffect{m[it] = it.both.count()} > > ---------------- > > Both yield a map of the degree of each node. You can then sort if you wish or > just alter the code to keep a reference to the highest node degree seen so > far. The latter being less memory intensive. > > Hope that helps, > Marko. > > http://markorodriguez.com > > > > _______________________________________________ > Neo4j mailing list > User@lists.neo4j.org > https://lists.neo4j.org/mailman/listinfo/user _______________________________________________ Neo4j mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user