Traversing the Graph
The traversal that was evaluated on each database started from some root vertex and emanated n-steps out. There was no sorting, no distinct-ing, etc. The only two variables for the experiments are the length of the traversal and the root vertex to start the traversal from. In MySQL, the following 5 queries denote traversals of length 1 through 5. Note that the "?" is a variable parameter of the query that denotes the root vertex.
SELECT a.inV FROM graph as a WHERE a.outV=?
SELECT b.inV FROM graph as a, graph as b WHERE a.inV=b.outV AND a.outV=?
SELECT c.inV FROM graph as a, graph as b, graph as c WHERE a.inV=b.outV AND b.inV=c.outV AND a.outV=?
SELECT d.inV FROM graph as a, graph as b, graph as c, graph as d WHERE a.inV=b.outV AND b.inV=c.outV AND c.inV=d.outV AND a.outV=?
SELECT e.inV FROM graph as a, graph as b, graph as c, graph as d, graph as e WHERE a.inV=b.outV AND b.inV=c.outV AND c.inV=d.outV AND d.inV=e.outV AND a.outV=?
For Neo4j, the Blueprints Pipes framework was used. A pipe of length n was constructed using the following static method.
public static Pipeline createPipeline(final Integer steps) {
final ArrayList<Pipe> pipes = new ArrayList<Pipe>();
for (int i = 0; i < steps; i++) {
Pipe pipe1 = new VertexEdgePipe(VertexEdgePipe.Step.OUT_EDGES);
Pipe pipe2 = new EdgeVertexPipe(EdgeVertexPipe.Step.IN_VERTEX);
pipes.add(pipe1);
pipes.add(pipe2);
}
return new Pipeline(pipes);
}
For both MySQL and Neo4j, the results of the query (SQL and Pipes) were iterated through. Thus, all results were retrieved for each query. In MySQL, this was done as follows.
while (resultSet.next()) {
resultSet.getInt(finalColumn);
}
In Neo4j, this is done as follows.
while (pipeline.hasNext()) {
pipeline.next();
}