<commit_before>/*jslint indent: 2, nomen: true, maxlen: 100, sloppy: true, vars: true, white: true, plusplus: true, evil: true */
/*global require */

////////////////////////////////////////////////////////////////////////////////
/// @brief traversal actions
///
/// @file
///
/// DISCLAIMER
///
/// Copyright 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 <NAME>
/// @author Copyright 2013, triAGENS GmbH, Cologne, Germany
////////////////////////////////////////////////////////////////////////////////

var arangodb = require("org/arangodb");
var actions = require("org/arangodb/actions");
var db = require("internal").db;
var traversal = require("org/arangodb/graph/traversal");
var Traverser = traversal.Traverser;
var graph = require("org/arangodb/general-graph");

// -----------------------------------------------------------------------------
// --SECTION--                                                 private functions
// -----------------------------------------------------------------------------

////////////////////////////////////////////////////////////////////////////////
/// @addtogroup ArangoAPI
/// @{
////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////
/// @brief create a "bad parameter" error
////////////////////////////////////////////////////////////////////////////////

function badParam (req, res, message) {
  actions.resultBad(req,
                    res,
                    arangodb.ERROR_HTTP_BAD_PARAMETER,
                    message);
}

////////////////////////////////////////////////////////////////////////////////
/// @brief create a "not found" error
////////////////////////////////////////////////////////////////////////////////

function notFound (req, res, code, message) {
  actions.resultNotFound(req,
                         res,
                         code,
                         message);
}

////////////////////////////////////////////////////////////////////////////////
/// @brief execute a server-side traversal
/// @startDocuBlock JSF_HTTP_API_TRAVERSAL
///
/// @RESTHEADER{POST /_api/traversal,executes a traversal}
///
/// @RESTBODYPARAM{body,string,required}
///
/// @RESTDESCRIPTION
/// Starts a traversal starting from a given vertex and following.
/// edges contained in a given edgeCollection. The request must
/// contain the following attributes.
///
/// - *startVertex*: id of the startVertex, e.g. *"users/foo"*.
///
/// - *edgeCollection*: **Deprecated** name of the collection that contains the edges.
///
/// - *graphName*: name of the graph that contains the edges.
///
/// - *filter* (optional, default is to include all nodes):
///         body (JavaScript code) of custom filter function
///         function signature: (config, vertex, path) -> mixed
///         can return four different string values:
///         - *"exclude"* -> this vertex will not be visited.
///         - *"prune"* -> the edges of this vertex will not be followed.
///         - *""* or *undefined* -> visit the vertex and follow it's edges.
///         - *Array* -> containing any combination of the above.
///             If there is at least one *"exclude"* or *"prune"* respectivly
///             is contained, it's effect will occur.
///
/// - *minDepth* (optional, ANDed with any existing filters):
///    visits only nodes in at least the given depth
///
/// - *maxDepth* (optional, ANDed with any existing filters):
///    visits only nodes in at most the given depth
///
/// - *visitor* (optional): body (JavaScript) code of custom visitor function
///          function signature: (config, result, vertex, path) -> void
///          visitor function can do anything, but its return value is ignored. To
///          populate a result, use the *result* variable by reference
///
/// - *direction* (optional): direction for traversal
///            - *if set*, must be either *"outbound"*, *"inbound"*, or *"any"*
///            - *if not set*, the *expander* attribute must be specified
///
/// - *init* (optional): body (JavaScript) code of custom result initialisation function
///       function signature: (config, result) -> void
///       initialise any values in result with what is required
///
/// - *expander* (optional): body (JavaScript) code of custom expander function
///           *must* be set if *direction* attribute is **not** set
///           function signature: (config, vertex, path) -> array
///           expander must return an array of the connections for *vertex*
///           each connection is an object with the attributes *edge* and *vertex*<commit_msg>Fixed indention of sublists in api-traversal docu<commit_after>/*jslint indent: 2, nomen: true, maxlen: 100, sloppy: true, vars: true, white: true, plusplus: true, evil: true */
/*global require */

////////////////////////////////////////////////////////////////////////////////
/// @brief traversal actions
///
/// @file
///
/// DISCLAIMER
///
/// Copyright 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 <NAME>
/// @author Copyright 2013, triAGENS GmbH, Cologne, Germany
////////////////////////////////////////////////////////////////////////////////

var arangodb = require("org/arangodb");
var actions = require("org/arangodb/actions");
var db = require("internal").db;
var traversal = require("org/arangodb/graph/traversal");
var Traverser = traversal.Traverser;
var graph = require("org/arangodb/general-graph");

// -----------------------------------------------------------------------------
// --SECTION--                                                 private functions
// -----------------------------------------------------------------------------

////////////////////////////////////////////////////////////////////////////////
/// @addtogroup ArangoAPI
/// @{
////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////
/// @brief create a "bad parameter" error
////////////////////////////////////////////////////////////////////////////////

function badParam (req, res, message) {
  actions.resultBad(req,
                    res,
                    arangodb.ERROR_HTTP_BAD_PARAMETER,
                    message);
}

////////////////////////////////////////////////////////////////////////////////
/// @brief create a "not found" error
////////////////////////////////////////////////////////////////////////////////

function notFound (req, res, code, message) {
  actions.resultNotFound(req,
                         res,
                         code,
                         message);
}

////////////////////////////////////////////////////////////////////////////////
/// @brief execute a server-side traversal
/// @startDocuBlock JSF_HTTP_API_TRAVERSAL
///
/// @RESTHEADER{POST /_api/traversal,executes a traversal}
///
/// @RESTBODYPARAM{body,string,required}
///
/// @RESTDESCRIPTION
/// Starts a traversal starting from a given vertex and following.
/// edges contained in a given edgeCollection. The request must
/// contain the following attributes.
///
/// - *startVertex*: id of the startVertex, e.g. *"users/foo"*.
///
/// - *edgeCollection*: **Deprecated** name of the collection that contains the edges.
///
/// - *graphName*: name of the graph that contains the edges.
///
/// - *filter* (optional, default is to include all nodes):
///         body (JavaScript code) of custom filter function
///         function signature: (config, vertex, path) -> mixed
///         can return four different string values:
///         - *"exclude"* -> this vertex will not be visited.
///         - *"prune"* -> the edges of this vertex will not be followed.
///         - *""* or *undefined* -> visit the vertex and follow it's edges.
///         - *Array* -> containing any combination of the above.
///             If there is at least one *"exclude"* or *"prune"* respectivly
///             is contained, it's effect will occur.
///
/// - *minDepth* (optional, ANDed with any existing filters):
///    visits only nodes in at least the given depth
///
/// - *maxDepth* (optional, ANDed with any existing filters):
///    visits only nodes in at most the given depth
///
/// - *visitor* (optional): body (JavaScript) code of custom visitor function
///          function signature: (config, result, vertex, path) -> void
///          visitor function can do anything, but its return value is ignored. To
///          populate a result, use the *result* variable by reference
///
/// - *direction* (optional): direction for traversal
///   - *if set*, must be either *"outbound"*, *"inbound"*, or *"any"*
///   - *if not set*, the *expander* attribute must be specified
///
/// - *init* (optional): body (JavaScript) code of custom result initialisation function
///       function signature: (config, result) -> void
///       initialise any values in result with what is required
///
/// - *expander* (optional): body (JavaScript) code of custom expander function
///           *must* be set if *direction* attribute is **not** set
///           function signature: (config, vertex, path) -> array
///           expander must return an array of the connections for *vertex*
///           each connection is an object with the attributes *edge* and *vertex*
{'fraction_non_alphanumeric': 0.27893649004133786, 'fraction_numerical': 0.003006388575723412, 'mean_word_length': 1.4303652968036529, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6858205', 'n_tokens_mistral': 2454, 'n_tokens_neox': 2362, 'n_words': 959}