1
0
Fork 0

custom visitors

This commit is contained in:
Jan Steemann 2015-02-13 11:32:13 +01:00
parent 3ffdfe0756
commit 94a362c3c7
2 changed files with 8 additions and 2 deletions

View File

@ -630,7 +630,7 @@ function post_api_traversal(req, res) {
if (json.visitor !== undefined) {
try {
visitor = new Function('config', 'result', 'vertex', 'path', json.visitor);
visitor = new Function('config', 'result', 'vertex', 'path', 'connected', json.visitor);
}
catch (err4) {
return badParam(req, res, "invalid visitor function");

View File

@ -5806,7 +5806,13 @@ function CALCULATE_SHORTEST_PATHES_WITH_DIJKSTRA (graphName, options) {
params.weight = options.weight;
params.defaultWeight = options.defaultWeight;
params = SHORTEST_PATH_PARAMS(params);
params.visitor = TRAVERSAL_DIJSKTRA_VISITOR;
// add user-defined visitor, if specified
if (typeof options.visitor === "string") {
params.visitor = GET_VISITOR(options.visitor, params);
}
else {
params.visitor = TRAVERSAL_DIJSKTRA_VISITOR;
}
var result = [], fromVertices = RESOLVE_GRAPH_TO_FROM_VERTICES(graphName, options),
toVertices = RESOLVE_GRAPH_TO_TO_VERTICES(graphName, options);