1
0
Fork 0

added any expander

This commit is contained in:
Jan Steemann 2013-01-13 14:53:26 +01:00
parent dc9969fb27
commit a2373b7036
2 changed files with 27 additions and 13 deletions

View File

@ -467,6 +467,31 @@ function CollectionInboundExpander (config, vertex, path) {
return connections;
}
////////////////////////////////////////////////////////////////////////////////
/// @brief default "any" expander function
////////////////////////////////////////////////////////////////////////////////
function CollectionAnyExpander (config, vertex, path) {
var connections = [ ];
var edges = config.edgeCollection.edges(vertex._id);
if (edges.length > 1 && config.sort) {
edges.sort(config.sort);
}
edges.forEach(function (edge) {
try {
var vertex = internal.db._document(edge._from);
connections.push({ edge: edge, vertex: vertex });
}
catch (e) {
// continue even in the face of non-existing documents
}
});
return connections;
}
///////////////////////////////////////////////////////////////////////////////////////////
/// @brief default expander that expands all edges labeled with one label in config.labels
///////////////////////////////////////////////////////////////////////////////////////////
@ -664,6 +689,7 @@ ArangoTraverser.EXCLUDE = 'exclude';
exports.Traverser = ArangoTraverser;
exports.CollectionOutboundExpander = CollectionOutboundExpander;
exports.CollectionInboundExpander = CollectionInboundExpander;
exports.CollectionAnyExpander = CollectionAnyExpander;
exports.VisitAllFilter = VisitAllFilter;
exports.TrackingVisitor = TrackingVisitor;
exports.MinDepthFilter = MinDepthFilter;

View File

@ -2316,17 +2316,6 @@ function AHUACATL_TRAVERSE_VISITOR (config, result, vertex, path) {
}
}
////////////////////////////////////////////////////////////////////////////////
/// @brief filter callback function for traversal
////////////////////////////////////////////////////////////////////////////////
function AHUACATL_TRAVERSE_FILTER (config, vertex, path) {
if (config.maxDepth != null && config.maxDepth != undefined && path.edges.length >= config.maxDepth) {
return "prune";
}
return "";
}
////////////////////////////////////////////////////////////////////////////////
/// @brief traverse a graph
////////////////////////////////////////////////////////////////////////////////
@ -2372,10 +2361,9 @@ function AHUACATL_GRAPH_TRAVERSE () {
'forward': traversal.Traverser.FORWARD,
'backward': traversal.Traverser.BACKWARD
}),
maxDepth: params.maxDepth,
trackPaths: params.paths || false,
visitor: AHUACATL_TRAVERSE_VISITOR,
filter: AHUACATL_TRAVERSE_FILTER,
filter: params.maxDepth != undefined ? traversal.MaxDepthFilter : VisitAllFilter,
expander: validate(direction, {
'outbound': traversal.CollectionOutboundExpander,
'inbound': traversal.CollectionInboundExpander,