mirror of https://gitee.com/bigwinds/arangodb
123 lines
3.3 KiB
JavaScript
123 lines
3.3 KiB
JavaScript
/*jslint indent: 2,
|
|
nomen: true,
|
|
maxlen: 80,
|
|
sloppy: true */
|
|
/*global require,
|
|
db,
|
|
assertEqual, assertTrue,
|
|
print,
|
|
PRINT_OBJECT,
|
|
console,
|
|
AvocadoCollection, AvocadoEdgesCollection */
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
/// @brief test the graph class
|
|
///
|
|
/// @file
|
|
///
|
|
/// DISCLAIMER
|
|
///
|
|
/// Copyright 2010-2012 triagens GmbH, Cologne, Germany
|
|
///
|
|
/// Licensed under the Apache License, Version 2.0 (the "License");
|
|
/// you may not use this file except in compliance with the License.
|
|
/// You may obtain a copy of the License at
|
|
///
|
|
/// http://www.apache.org/licenses/LICENSE-2.0
|
|
///
|
|
/// Unless required by applicable law or agreed to in writing, software
|
|
/// distributed under the License is distributed on an "AS IS" BASIS,
|
|
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
/// See the License for the specific language governing permissions and
|
|
/// limitations under the License.
|
|
///
|
|
/// Copyright holder is triAGENS GmbH, Cologne, Germany
|
|
///
|
|
/// @author Lucas Dohmen
|
|
/// @author Copyright 2012, triAGENS GmbH, Cologne, Germany
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
function main(args) {
|
|
var Graph = require("org/arangodb/graph").Graph,
|
|
graph_name = "UnitTestsCollectionGraph",
|
|
vertex = "UnitTestsCollectionVertex",
|
|
edge = "UnitTestsCollectionEdge",
|
|
graph = null,
|
|
base_path = args[1] + "/",
|
|
v1,
|
|
v2,
|
|
e,
|
|
pathes,
|
|
results = [],
|
|
neo4j_results = [],
|
|
single_result = {},
|
|
console = require("console"),
|
|
Helper = require("test-helper").Helper,
|
|
counter,
|
|
i,
|
|
caching = false;
|
|
|
|
if (args[2] === "true") {
|
|
caching = true;
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
/// set up
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
try {
|
|
try {
|
|
// Drop the graph if it exsits
|
|
graph = new Graph(graph_name);
|
|
print("FOUND: ");
|
|
PRINT_OBJECT(graph);
|
|
graph.drop();
|
|
} catch (err1) {
|
|
}
|
|
|
|
graph = new Graph(graph_name, vertex, edge);
|
|
} catch (err2) {
|
|
console.error("[FAILED] setup failed:" + err2);
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
/// compare with Neo4j on a given network
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
console.log("Importing");
|
|
|
|
Helper.process(base_path + "generated_edges.csv", function (row) {
|
|
v1 = graph.getOrAddVertex(row[1]);
|
|
v2 = graph.getOrAddVertex(row[2]);
|
|
e = graph.addEdge(v1, v2);
|
|
});
|
|
|
|
console.log("Starting Tests");
|
|
|
|
processor = function (row) {
|
|
v1 = graph.getVertex(row[0]);
|
|
v2 = graph.getVertex(row[1]);
|
|
|
|
if (v1 !== null && v2 !== null) {
|
|
pathes = v1.pathTo(v2, { cached: caching });
|
|
}
|
|
};
|
|
|
|
while (true) {
|
|
Helper.process(base_path + "generated_testcases.csv", processor);
|
|
console.log("Round Finished");
|
|
}
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
/// tear down
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
try {
|
|
if (graph !== null) {
|
|
graph.drop();
|
|
}
|
|
} catch (err) {
|
|
console.error("[FAILED] tear-down failed:" + err);
|
|
}
|
|
}
|