I just created a graph like yours and run the traversal test, it takes a few
milliseconds for the initial runs but with hot caches it executes almost
instantly.
Michael
node count = 952 took 72 ms
node count = 963 took 29 ms
node count = 957 took 39 ms
node count = 973 took 29 ms
node count = 967 took 16 ms
node count = 964 took 19 ms
node count = 952 took 7 ms
node count = 961 took 6 ms
node count = 957 took 6 ms
node count = 973 took 7 ms
node count = 967 took 8 ms
node count = 964 took 9 ms
node count = 1 took 0 ms
node count = 961 took 8 ms
node count = 1 took 2 ms
node count = 973 took 12 ms
node count = 967 took 11 ms
node count = 964 took 10 ms
node count = 952 took 11 ms
node count = 961 took 11 ms
node count = 957 took 12 ms
node count = 973 took 7 ms
node count = 967 took 11 ms
node count = 964 took 6 ms
node count = 952 took 7 ms
node count = 961 took 6 ms
node count = 957 took 6 ms
node count = 973 took 7 ms
node count = 967 took 4 ms
node count = 964 took 4 ms
node count = 952 took 4 ms
node count = 962 took 4 ms
node count = 957 took 4 ms
node count = 973 took 3 ms
node count = 967 took 3 ms
node count = 964 took 3 ms
node count = 952 took 3 ms
node count = 961 took 3 ms
node count = 957 took 3 ms
node count = 973 took 2 ms
node count = 967 took 5 ms
node count = 964 took 4 ms
node count = 952 took 4 ms
node count = 1 took 0 ms
node count = 957 took 3 ms
node count = 973 took 2 ms
node count = 967 took 2 ms
node count = 964 took 2 ms
node count = 954 took 2 ms
node count = 961 took 2 ms
node count = 957 took 1 ms
node count = 973 took 2 ms
node count = 967 took 1 ms
node count = 964 took 2 ms
node count = 952 took 2 ms
node count = 961 took 1 ms
node count = 958 took 2 ms
node count = 1 took 0 ms
node count = 967 took 1 ms
node count = 964 took 2 ms
package org.neo4j.performance.ahmed;
import org.apache.commons.io.FileUtils;
import org.neo4j.graphdb.*;
import org.neo4j.kernel.EmbeddedGraphDatabase;
import java.io.File;
import java.io.IOException;
import java.util.Random;
public class TraverserTest {
public static final int INT = 1000;
enum Rels implements RelationshipType {
_1, _2, _3, _4, _5, _6;
private static Rels randomRel(Random random) {
final Rels[] values = values();
return values[random.nextInt(values.length)];
}
}
public static void main(String[] args) throws IOException {
final File dir = new File("target/traverse");
FileUtils.deleteDirectory(dir);
final EmbeddedGraphDatabase gdb = new
EmbeddedGraphDatabase(dir.getAbsolutePath());
final Random random = new Random(0);
createGraph(gdb, random);
for (int run = 0; run < 10; run++) {
for (Rels rels : Rels.values()) {
runTraversal(gdb, random, rels);
}
}
}
private static void runTraversal(EmbeddedGraphDatabase gdb, Random random,
final Rels relType) {
final Node startNode = gdb.getNodeById(random.nextInt(INT));
long start = System.currentTimeMillis();
Traverser traverser = startNode.traverse(Traverser.Order.DEPTH_FIRST,
StopEvaluator.END_OF_GRAPH, ReturnableEvaluator.ALL, relType,
Direction.OUTGOING);
int count = 0;
for (Node node : traverser) {
count++;
}
long delta = System.currentTimeMillis() - start;
System.out.println("node count = " + count + " took " + delta + " ms");
}
private static void createGraph(EmbeddedGraphDatabase gdb, final Random
random) {
final Transaction tx = gdb.beginTx();
createNodes(gdb);
connectNodes(gdb, random);
tx.success();
tx.finish();
}
private static void connectNodes(EmbeddedGraphDatabase gdb, Random random) {
for (int i = 0; i < INT; i++) {
final Node start = gdb.getNodeById(i);
for (int j = 0; j < 20; j++) {
connectToOtherNodes(gdb, random, start);
}
}
}
private static void createNodes(EmbeddedGraphDatabase gdb) {
for (int i = 0; i < INT; i++) {
gdb.createNode();
}
}
private static void connectToOtherNodes(EmbeddedGraphDatabase gdb, Random
random, Node start) {
Node end = gdb.getNodeById(random.nextInt(INT));
final Rels type = Rels.randomRel(random);
if (type.ordinal() % 2 == 0) {
start.createRelationshipTo(end, type);
} else {
end.createRelationshipTo(start, type);
}
}
}
Am 12.08.2011 um 02:55 schrieb ahmed.elsharkasy:
> My graph contains 281 nodes with a total of 350 relationships . average
> outgoing edges per node less than 10 and the same for in going edges
>
> what do you think?
>
> --
> View this message in context:
> http://neo4j-community-discussions.438527.n3.nabble.com/cant-use-index-after-commit-tp3233038p3247898.html
> Sent from the Neo4j Community Discussions mailing list archive at Nabble.com.
> _______________________________________________
> Neo4j mailing list
> [email protected]
> https://lists.neo4j.org/mailman/listinfo/user
_______________________________________________
Neo4j mailing list
[email protected]
https://lists.neo4j.org/mailman/listinfo/user