From f4b67ed01d5e0b039fe378084110a092b1c9a37e Mon Sep 17 00:00:00 2001 From: scottashton Date: Wed, 11 Jun 2014 16:04:15 +0200 Subject: [PATCH 1/4] jslinted --- .../modules/org/arangodb/general-graph.js | 2 +- js/server/modules/org/arangodb/ahuacatl.js | 155 +++++++++++++++--- 2 files changed, 135 insertions(+), 22 deletions(-) diff --git a/js/common/modules/org/arangodb/general-graph.js b/js/common/modules/org/arangodb/general-graph.js index 3c6216d31b..4525d9e87e 100644 --- a/js/common/modules/org/arangodb/general-graph.js +++ b/js/common/modules/org/arangodb/general-graph.js @@ -1480,7 +1480,7 @@ var _create = function (graphName, edgeDefinitions) { ); try { - g = gdb.document(graphName); + var g = gdb.document(graphName); } catch (e) { if (e.errorNum !== errors.ERROR_ARANGO_DOCUMENT_NOT_FOUND.code) { throw e; diff --git a/js/server/modules/org/arangodb/ahuacatl.js b/js/server/modules/org/arangodb/ahuacatl.js index 1dcae193ec..b2d2143114 100644 --- a/js/server/modules/org/arangodb/ahuacatl.js +++ b/js/server/modules/org/arangodb/ahuacatl.js @@ -5704,7 +5704,7 @@ function GENERAL_GRAPH_VERTICES ( function TRANSFER_GENERAL_GRAPH_NEIGHBORS_RESULT (result) { var ret = {}; result.forEach(function (r) { - var v = JSON.stringify(r.vertex) + var v = JSON.stringify(r.vertex); if (! ret[v]) { ret[v] = []; } @@ -5718,7 +5718,8 @@ function TRANSFER_GENERAL_GRAPH_NEIGHBORS_RESULT (result) { //////////////////////////////////////////////////////////////////////////////// /// @startDocuBlock JSF_ahuacatl_general_graph_common_neighbors /// -/// `GRAPH_COMMON_NEIGHBORS (graphName, vertex1Example, vertex2Examples, optionsVertex1, optionsVertex2)` +/// `GRAPH_COMMON_NEIGHBORS (graphName, vertex1Example, vertex2Examples, +/// optionsVertex1, optionsVertex2)` /// *The GRAPH\_COMMON\_NEIGHBORS function returns all common neighbors of the vertices /// defined by the examples.* /// @@ -5797,8 +5798,8 @@ function GENERAL_GRAPH_COMMON_NEIGHBORS ( var neighbors1 = TRANSFER_GENERAL_GRAPH_NEIGHBORS_RESULT( GENERAL_GRAPH_NEIGHBORS(graphName, vertex1Examples, options1) ), neighbors2; - if (vertex1Examples == vertex2Examples) { - neighbors2 == CLONE(neighbors1); + if (vertex1Examples === vertex2Examples) { + neighbors2 = CLONE(neighbors1); } else { neighbors2 = TRANSFER_GENERAL_GRAPH_NEIGHBORS_RESULT( GENERAL_GRAPH_NEIGHBORS(graphName, vertex2Examples, options2) @@ -5835,7 +5836,7 @@ function GENERAL_GRAPH_COMMON_NEIGHBORS ( }); }); Object.keys(res2).forEach(function (r) { - var e = {} + var e = {}; e[r] = res2[r]; res3.push(e); }); @@ -6011,8 +6012,7 @@ function GENERAL_GRAPH_COMMON_PROPERTIES ( /// * String|Object|Array *edgeExamples* : A filter example for the /// edges in the shortest paths (see below). /// * String *algorithm* : The algorithm to calculate -/// the shortest paths. If both start and end vertex examples are empty *Floyd-Warshall* is -/// used, otherwise the default is *Dijkstra* +/// the shortest paths. /// * String *weight* : The name of the attribute of /// the edges containing the length. /// * Number *defaultWeight* : Only used with the option *weight*. @@ -6110,8 +6110,7 @@ function GENERAL_GRAPH_ABSOLUTE_ECCENTRICITY (graphName, vertexExample, options) /// * String *direction* : The direction of the edges. /// Possible values are *outbound*, *inbound* and *any* (default). /// * String *algorithm* : The algorithm to calculate -/// the shortest paths. If both start and end vertex examples are empty *Floyd-Warshall* is -/// used, otherwise the default is *Dijkstra* +/// the shortest paths. /// * String *weight* : The name of the attribute of /// the edges containing the length. /// * Number *defaultWeight* : Only used with the option *weight*. @@ -6202,8 +6201,7 @@ function GENERAL_GRAPH_ECCENTRICITY (graphName, options) { /// * String|Object|Array *edgeExamples* : A filter example for the /// edges in the shortest paths (see below). /// * String *algorithm* : The algorithm to calculate -/// the shortest paths. If both start and end vertex examples are empty *Floyd-Warshall* is -/// used, otherwise the default is *Dijkstra* +/// the shortest paths. /// * String *weight* : The name of the attribute of /// the edges containing the length. /// * Number *defaultWeight* : Only used with the option *weight*. @@ -6300,8 +6298,7 @@ function GENERAL_GRAPH_ABSOLUTE_CLOSENESS (graphName, vertexExample, options) { /// * String *direction* : The direction of the edges. /// Possible values are *outbound*, *inbound* and *any* (default). /// * String *algorithm* : The algorithm to calculate -/// the shortest paths. If both start and end vertex examples are empty *Floyd-Warshall* is -/// used, otherwise the default is *Dijkstra* +/// the shortest paths. /// * String *weight* : The name of the attribute of /// the edges containing the length. /// * Number *defaultWeight* : Only used with the option *weight*. @@ -6396,9 +6393,6 @@ function GENERAL_GRAPH_CLOSENESS (graphName, options) { /// Possible options and there defaults: /// * String *direction* : The direction of the edges. /// Possible values are *outbound*, *inbound* and *any* (default). -/// * String *algorithm* : The algorithm to calculate -/// the shortest paths. If both start and end vertex examples are empty *Floyd-Warshall* is -/// used, otherwise the default is *Dijkstra* /// * String *weight* : The name of the attribute of /// the edges containing the length. /// * Number *defaultWeight* : Only used with the option *weight*. @@ -6507,9 +6501,6 @@ function GENERAL_GRAPH_ABSOLUTE_BETWEENNESS (graphName, options) { /// Possible options and there defaults: /// * String *direction* : The direction of the edges. /// Possible values are *outbound*, *inbound* and *any* (default). -/// * String *algorithm* : The algorithm to calculate -/// the shortest paths. If both start and end vertex examples are empty *Floyd-Warshall* is -/// used, otherwise the default is *Dijkstra* /// * String *weight* : The name of the attribute of /// the edges containing the length. /// * Number *defaultWeight* : Only used with the option *weight*. @@ -6582,7 +6573,68 @@ function GENERAL_GRAPH_BETWEENNESS (graphName, options) { //////////////////////////////////////////////////////////////////////////////// -/// @brief return the radius of the graph +/// @startDocuBlock JSF_ahuacatl_general_graph_radius +/// +/// `GRAPH_RADIUS (graphName, options)` +/// *The GRAPH\_RADIUS function returns the +/// [radius](http://en.wikipedia.org/wiki/Eccentricity_(graph_theory)) +/// of a graph. +/// +/// * String *graphName* : The name of the graph. +/// * Object *options* : Optional options, see below: +/// +/// Possible options and there defaults: +/// * String *direction* : The direction of the edges. +/// Possible values are *outbound*, *inbound* and *any* (default). +/// * String *algorithm* : The algorithm to calculate +/// the shortest paths. +/// * String *weight* : The name of the attribute of +/// the edges containing the length. +/// * Number *defaultWeight* : Only used with the option *weight*. +/// If an edge does not have the attribute named as defined in option *weight* this default +/// is used as length. +/// If no default is supplied the default would be positive Infinity so the path and +/// hence the eccentricity can not be calculated. +/// +/// @EXAMPLES +/// +/// A route planner example, the radius of the graph. +/// +/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphRadius1} +/// ~ var db = require("internal").db; +/// var examples = require("org/arangodb/graph-examples/example-graph.js"); +/// var g = examples.loadGraph("routeplanner"); +/// |db._query("RETURN GRAPH_RADIUS(" +/// |+"'routeplanner')" +/// ).toArray(); +/// @END_EXAMPLE_ARANGOSH_OUTPUT +/// +/// A route planner example, the radius of the graph. +/// This considers the actual distances. +/// +/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphRadius2} +/// ~ var db = require("internal").db; +/// var examples = require("org/arangodb/graph-examples/example-graph.js"); +/// var g = examples.loadGraph("routeplanner"); +/// |db._query("RETURN GRAPH_RADIUS(" +/// |+"'routeplanner', {weight : 'distance'})" +/// ).toArray(); +/// @END_EXAMPLE_ARANGOSH_OUTPUT +/// +/// A route planner example, the cradius of the graph regarding only +/// outbound pathes. +/// +/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphRadius3} +/// ~ var db = require("internal").db; +/// var examples = require("org/arangodb/graph-examples/example-graph.js"); +/// var g = examples.loadGraph("routeplanner"); +/// |db._query("RETURN GRAPH_RADIUS(" +/// | + "'routeplanner', {direction : 'outbound', weight : 'distance'})" +/// ).toArray(); +/// @END_EXAMPLE_ARANGOSH_OUTPUT +/// +/// @endDocuBlock +// //////////////////////////////////////////////////////////////////////////////// function GENERAL_GRAPH_RADIUS (graphName, options) { @@ -6613,7 +6665,68 @@ function GENERAL_GRAPH_RADIUS (graphName, options) { //////////////////////////////////////////////////////////////////////////////// -/// @brief return the diameter of the graph +/// @startDocuBlock JSF_ahuacatl_general_graph_diameter +/// +/// `GRAPH_DIAMETER (graphName, options)` +/// *The GRAPH\_DIAMETER function returns the +/// [diameter](http://en.wikipedia.org/wiki/Eccentricity_(graph_theory)) +/// of a graph. +/// +/// * String *graphName* : The name of the graph. +/// * Object *options* : Optional options, see below: +/// +/// Possible options and there defaults: +/// * String *direction* : The direction of the edges. +/// Possible values are *outbound*, *inbound* and *any* (default). +/// * String *algorithm* : The algorithm to calculate +/// the shortest paths. +/// * String *weight* : The name of the attribute of +/// the edges containing the length. +/// * Number *defaultWeight* : Only used with the option *weight*. +/// If an edge does not have the attribute named as defined in option *weight* this default +/// is used as length. +/// If no default is supplied the default would be positive Infinity so the path and +/// hence the eccentricity can not be calculated. +/// +/// @EXAMPLES +/// +/// A route planner example, the diameter of the graph. +/// +/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphDiameter1} +/// ~ var db = require("internal").db; +/// var examples = require("org/arangodb/graph-examples/example-graph.js"); +/// var g = examples.loadGraph("routeplanner"); +/// |db._query("RETURN GRAPH_DIAMETER(" +/// |+"'routeplanner')" +/// ).toArray(); +/// @END_EXAMPLE_ARANGOSH_OUTPUT +/// +/// A route planner example, tthe diameter of the graph. +/// This considers the actual distances. +/// +/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphDiameter2} +/// ~ var db = require("internal").db; +/// var examples = require("org/arangodb/graph-examples/example-graph.js"); +/// var g = examples.loadGraph("routeplanner"); +/// |db._query("RETURN GRAPH_DIAMETER(" +/// |+"'routeplanner', {weight : 'distance'})" +/// ).toArray(); +/// @END_EXAMPLE_ARANGOSH_OUTPUT +/// +/// A route planner example, the diameter of the graph regarding only +/// outbound pathes. +/// +/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphDiameter3} +/// ~ var db = require("internal").db; +/// var examples = require("org/arangodb/graph-examples/example-graph.js"); +/// var g = examples.loadGraph("routeplanner"); +/// |db._query("RETURN GRAPH_DIAMETER(" +/// | + "'routeplanner', {direction : 'outbound', weight : 'distance'})" +/// ).toArray(); +/// @END_EXAMPLE_ARANGOSH_OUTPUT +/// +/// @endDocuBlock +// //////////////////////////////////////////////////////////////////////////////// function GENERAL_GRAPH_DIAMETER (graphName, options) { From 299b99ed005ee30e264e0b4ffb0abee7f74e4b60 Mon Sep 17 00:00:00 2001 From: Frank Celler Date: Wed, 11 Jun 2014 19:29:28 +0200 Subject: [PATCH 2/4] fixed check-version for empty directory --- Installation/ARM/rc.arangodb | 4 +- arangod/RestServer/ArangoServer.cpp | 47 ++++++++++++------- arangod/RestServer/ArangoServer.h | 2 +- arangod/VocBase/server.cpp | 38 +++++++++++---- arangod/VocBase/server.h | 3 +- .../aardvark/frontend/js/bootstrap/errors.js | 1 + js/common/bootstrap/errors.js | 1 + .../modules/org/arangodb/database-version.js | 9 ++-- lib/BasicsC/errors.dat | 1 + lib/BasicsC/voc-errors.c | 1 + lib/BasicsC/voc-errors.h | 12 +++++ 11 files changed, 82 insertions(+), 37 deletions(-) diff --git a/Installation/ARM/rc.arangodb b/Installation/ARM/rc.arangodb index c48eaa7941..ed3afc8494 100644 --- a/Installation/ARM/rc.arangodb +++ b/Installation/ARM/rc.arangodb @@ -39,11 +39,11 @@ start () { fi if [ "$1" = "--upgrade" ]; then - $DAEMON -c $CONF --uid arangodb --gid arangodb $@ + $DAEMON -c $CONF --uid arangodb --gid arangodb --no-server $@ RETVAL=$? log_end_msg $RETVAL else - $DAEMON -c $CONF --uid arangodb --gid arangodb --check-version + $DAEMON -c $CONF --uid arangodb --gid arangodb --no-server --check-version RETVAL=$? if test $RETVAL -eq 0; then diff --git a/arangod/RestServer/ArangoServer.cpp b/arangod/RestServer/ArangoServer.cpp index 640e356413..be97d85457 100644 --- a/arangod/RestServer/ArangoServer.cpp +++ b/arangod/RestServer/ArangoServer.cpp @@ -770,6 +770,27 @@ int ArangoServer::startupServer () { startServer = false; } + // check version + bool checkVersion = false; + + if (_applicationServer->programOptions().has("check-version")) { + checkVersion = true; + } + + // run upgrade script + bool performUpgrade = false; + + if (_applicationServer->programOptions().has("upgrade")) { + performUpgrade = true; + } + + // skip an upgrade even if VERSION is missing + bool skipUpgrade = false; + + if (_applicationServer->programOptions().has("no-upgrade")) { + skipUpgrade = true; + } + // ............................................................................. // prepare the various parts of the Arango server // ............................................................................. @@ -779,7 +800,7 @@ int ArangoServer::startupServer () { } // open all databases - openDatabases(); + openDatabases(checkVersion, performUpgrade); // fetch the system database TRI_vocbase_t* vocbase = TRI_UseDatabaseServer(_server, TRI_VOC_SYSTEM_DATABASE); @@ -809,19 +830,6 @@ int ArangoServer::startupServer () { _applicationV8->setVocbase(vocbase); _applicationV8->setConcurrency(concurrency); - bool performUpgrade = false; - - if (_applicationServer->programOptions().has("upgrade")) { - performUpgrade = true; - } - - // skip an upgrade even if VERSION is missing - bool skipUpgrade = false; - - if (_applicationServer->programOptions().has("no-upgrade")) { - skipUpgrade = true; - } - #ifdef TRI_ENABLE_MRUBY _applicationMR->setVocbase(vocbase); _applicationMR->setConcurrency(_dispatcherThreads); @@ -851,7 +859,7 @@ int ArangoServer::startupServer () { _applicationServer->prepare2(); // run version check - if (_applicationServer->programOptions().has("check-version")) { + if (checkVersion) { _applicationV8->runUpgradeCheck(); } @@ -1098,7 +1106,7 @@ int ArangoServer::runScript (TRI_vocbase_t* vocbase) { /// @brief opens the database //////////////////////////////////////////////////////////////////////////////// -void ArangoServer::openDatabases () { +void ArangoServer::openDatabases (bool checkVersion, bool performUpgrade) { TRI_vocbase_defaults_t defaults; // override with command-line options @@ -1125,10 +1133,13 @@ void ArangoServer::openDatabases () { LOG_FATAL_AND_EXIT("cannot create server instance: out of memory"); } - const bool isUpgrade = _applicationServer->programOptions().has("upgrade"); - res = TRI_StartServer(_server, isUpgrade); + res = TRI_StartServer(_server, checkVersion, performUpgrade); if (res != TRI_ERROR_NO_ERROR) { + if (checkVersion && res == TRI_ERROR_ARANGO_EMPTY_DATADIR) { + TRI_EXIT_FUNCTION(EXIT_SUCCESS, NULL); + } + LOG_FATAL_AND_EXIT("cannot start server: %s", TRI_errno_string(res)); } diff --git a/arangod/RestServer/ArangoServer.h b/arangod/RestServer/ArangoServer.h index 1d45b8ba8e..5a0cc6bcb1 100644 --- a/arangod/RestServer/ArangoServer.h +++ b/arangod/RestServer/ArangoServer.h @@ -158,7 +158,7 @@ namespace triagens { /// @brief opens the system database //////////////////////////////////////////////////////////////////////////////// - void openDatabases (); + void openDatabases (bool checkVersion, bool performUpgrade); //////////////////////////////////////////////////////////////////////////////// /// @brief closes the database diff --git a/arangod/VocBase/server.cpp b/arangod/VocBase/server.cpp index 60cf81a7ef..f146bc5934 100644 --- a/arangod/VocBase/server.cpp +++ b/arangod/VocBase/server.cpp @@ -290,12 +290,16 @@ static int WriteServerId (char const* filename) { /// @brief read / create the server id on startup //////////////////////////////////////////////////////////////////////////////// -static int DetermineServerId (TRI_server_t* server) { +static int DetermineServerId (TRI_server_t* server, bool checkVersion) { int res; res = ReadServerId(server->_serverIdFilename); if (res == TRI_ERROR_FILE_NOT_FOUND) { + if (checkVersion) { + return TRI_ERROR_ARANGO_EMPTY_DATADIR; + } + // id file does not yet exist. now create it res = GenerateServerId(); @@ -1390,7 +1394,8 @@ static int Move14AlphaDatabases (TRI_server_t* server) { //////////////////////////////////////////////////////////////////////////////// static int InitDatabases (TRI_server_t* server, - bool isUpgrade) { + bool checkVersion, + bool performUpgrade) { TRI_vector_string_t names; int res; @@ -1404,7 +1409,7 @@ static int InitDatabases (TRI_server_t* server, if (names._length == 0) { char* name; - if (! isUpgrade && HasOldCollections(server)) { + if (! performUpgrade && HasOldCollections(server)) { LOG_ERROR("no databases found. Please start the server with the --upgrade option"); return TRI_ERROR_ARANGO_DATADIR_INVALID; @@ -1422,7 +1427,7 @@ static int InitDatabases (TRI_server_t* server, } } - if (res == TRI_ERROR_NO_ERROR && isUpgrade) { + if (res == TRI_ERROR_NO_ERROR && performUpgrade) { char const* systemName; assert(names._length > 0); @@ -1782,7 +1787,8 @@ TRI_server_id_t TRI_GetIdServer () { //////////////////////////////////////////////////////////////////////////////// int TRI_StartServer (TRI_server_t* server, - bool isUpgrade) { + bool checkVersion, + bool performUpgrade) { int res; if (! TRI_IsDirectory(server->_basePath)) { @@ -1832,7 +1838,11 @@ int TRI_StartServer (TRI_server_t* server, // read the server id // ............................................................................. - res = DetermineServerId(server); + res = DetermineServerId(server, checkVersion); + + if (res == TRI_ERROR_ARANGO_EMPTY_DATADIR) { + return res; + } if (res != TRI_ERROR_NO_ERROR) { LOG_ERROR("reading/creating server file failed: %s", @@ -1894,7 +1904,11 @@ int TRI_StartServer (TRI_server_t* server, // perform an eventual migration of the databases. // ............................................................................. - res = InitDatabases(server, isUpgrade); + res = InitDatabases(server, checkVersion, performUpgrade); + + if (res == TRI_ERROR_ARANGO_EMPTY_DATADIR) { + return res; + } if (res != TRI_ERROR_NO_ERROR) { LOG_ERROR("unable to initialise databases: %s", @@ -1909,7 +1923,7 @@ int TRI_StartServer (TRI_server_t* server, if (server->_appPath != NULL && strlen(server->_appPath) > 0 && ! TRI_IsDirectory(server->_appPath)) { - if (! isUpgrade) { + if (! performUpgrade) { LOG_ERROR("specified --javascript.app-path directory '%s' does not exist. " "Please start again with --upgrade option to create it.", server->_appPath); @@ -1929,7 +1943,7 @@ int TRI_StartServer (TRI_server_t* server, if (server->_devAppPath != NULL && strlen(server->_devAppPath) > 0 && ! TRI_IsDirectory(server->_devAppPath)) { - if (! isUpgrade) { + if (! performUpgrade) { LOG_ERROR("specified --javascript.dev-app-path directory '%s' does not exist. " "Please start again with --upgrade option to create it.", server->_devAppPath); @@ -1979,7 +1993,7 @@ int TRI_StartServer (TRI_server_t* server, // ............................................................................. // scan all databases - res = OpenDatabases(server, isUpgrade); + res = OpenDatabases(server, performUpgrade); if (res != TRI_ERROR_NO_ERROR) { LOG_ERROR("could not iterate over all databases: %s", @@ -2686,6 +2700,10 @@ bool TRI_MSync (int fd, return true; } +// ----------------------------------------------------------------------------- +// --SECTION-- END-OF-FILE +// ----------------------------------------------------------------------------- + // Local Variables: // mode: outline-minor // outline-regexp: "/// @brief\\|/// {@inheritDoc}\\|/// @addtogroup\\|/// @page\\|// --SECTION--\\|/// @\\}" diff --git a/arangod/VocBase/server.h b/arangod/VocBase/server.h index 2eba1cdb97..815f2c4a8c 100644 --- a/arangod/VocBase/server.h +++ b/arangod/VocBase/server.h @@ -151,7 +151,8 @@ TRI_server_id_t TRI_GetIdServer (void); //////////////////////////////////////////////////////////////////////////////// int TRI_StartServer (TRI_server_t*, - bool); + bool checkVersion, + bool performUpgrade); //////////////////////////////////////////////////////////////////////////////// /// @brief stop the server diff --git a/js/apps/system/aardvark/frontend/js/bootstrap/errors.js b/js/apps/system/aardvark/frontend/js/bootstrap/errors.js index 324b9bd9e2..8d94b3df07 100644 --- a/js/apps/system/aardvark/frontend/js/bootstrap/errors.js +++ b/js/apps/system/aardvark/frontend/js/bootstrap/errors.js @@ -104,6 +104,7 @@ "ERROR_ARANGO_INDEX_DOCUMENT_ATTRIBUTE_MISSING" : { "code" : 1234, "message" : "index insertion warning - attribute missing in document" }, "ERROR_ARANGO_INDEX_CREATION_FAILED" : { "code" : 1235, "message" : "index creation failed" }, "ERROR_ARANGO_DATAFILE_FULL" : { "code" : 1300, "message" : "datafile full" }, + "ERROR_ARANGO_EMPTY_DATADIR" : { "code" : 1301, "message" : "server database directory is empty" }, "ERROR_REPLICATION_NO_RESPONSE" : { "code" : 1400, "message" : "no response" }, "ERROR_REPLICATION_INVALID_RESPONSE" : { "code" : 1401, "message" : "invalid response" }, "ERROR_REPLICATION_MASTER_ERROR" : { "code" : 1402, "message" : "master error" }, diff --git a/js/common/bootstrap/errors.js b/js/common/bootstrap/errors.js index 53a9e66604..f52b4978c9 100644 --- a/js/common/bootstrap/errors.js +++ b/js/common/bootstrap/errors.js @@ -104,6 +104,7 @@ "ERROR_ARANGO_INDEX_DOCUMENT_ATTRIBUTE_MISSING" : { "code" : 1234, "message" : "index insertion warning - attribute missing in document" }, "ERROR_ARANGO_INDEX_CREATION_FAILED" : { "code" : 1235, "message" : "index creation failed" }, "ERROR_ARANGO_DATAFILE_FULL" : { "code" : 1300, "message" : "datafile full" }, + "ERROR_ARANGO_EMPTY_DATADIR" : { "code" : 1301, "message" : "server database directory is empty" }, "ERROR_REPLICATION_NO_RESPONSE" : { "code" : 1400, "message" : "no response" }, "ERROR_REPLICATION_INVALID_RESPONSE" : { "code" : 1401, "message" : "invalid response" }, "ERROR_REPLICATION_MASTER_ERROR" : { "code" : 1402, "message" : "master error" }, diff --git a/js/server/modules/org/arangodb/database-version.js b/js/server/modules/org/arangodb/database-version.js index d6b47b8030..f7fb45ae46 100644 --- a/js/server/modules/org/arangodb/database-version.js +++ b/js/server/modules/org/arangodb/database-version.js @@ -30,10 +30,9 @@ /// @author Copyright 2014, triAGENS GmbH, Cologne, Germany //////////////////////////////////////////////////////////////////////////////// -var internal = require("internal"); var cluster = require("org/arangodb/cluster"); var fs = require("fs"); -var db = internal.db; +var db = require("org/arangodb").db; var console = require("console"); // ----------------------------------------------------------------------------- @@ -124,7 +123,7 @@ exports.databaseVersion = function () { } // path to the VERSION file - var versionFile = internal.db._path() + "/VERSION"; + var versionFile = db._path() + "/VERSION"; var lastVersion = null; // VERSION file exists, read its contents @@ -152,11 +151,11 @@ exports.databaseVersion = function () { } // extract server version - var currentServerVersion = internal.db._version().match(/^(\d+\.\d+).*$/); + var currentServerVersion = db._version().match(/^(\d+\.\d+).*$/); // server version is invalid for some reason if (! currentServerVersion) { - logger.error("Unexpected ArangoDB server version: " + internal.db._version()); + logger.error("Unexpected ArangoDB server version: " + db._version()); return { result: exports.NO_SERVER_VERSION }; } diff --git a/lib/BasicsC/errors.dat b/lib/BasicsC/errors.dat index c88812522f..f22e592821 100755 --- a/lib/BasicsC/errors.dat +++ b/lib/BasicsC/errors.dat @@ -129,6 +129,7 @@ ERROR_ARANGO_INDEX_CREATION_FAILED,1235,"index creation failed","Will be raised ################################################################################ ERROR_ARANGO_DATAFILE_FULL,1300,"datafile full","Will be raised when the datafile reaches its limit." +ERROR_ARANGO_EMPTY_DATADIR,1301,"server database directory is empty","Will be raised when encoutering an empty server database directory." ################################################################################ ## ArangoDB replication errors diff --git a/lib/BasicsC/voc-errors.c b/lib/BasicsC/voc-errors.c index 07888122ef..6ab4f02e1c 100644 --- a/lib/BasicsC/voc-errors.c +++ b/lib/BasicsC/voc-errors.c @@ -100,6 +100,7 @@ void TRI_InitialiseErrorMessages (void) { REG_ERROR(ERROR_ARANGO_INDEX_DOCUMENT_ATTRIBUTE_MISSING, "index insertion warning - attribute missing in document"); REG_ERROR(ERROR_ARANGO_INDEX_CREATION_FAILED, "index creation failed"); REG_ERROR(ERROR_ARANGO_DATAFILE_FULL, "datafile full"); + REG_ERROR(ERROR_ARANGO_EMPTY_DATADIR, "server database directory is empty"); REG_ERROR(ERROR_REPLICATION_NO_RESPONSE, "no response"); REG_ERROR(ERROR_REPLICATION_INVALID_RESPONSE, "invalid response"); REG_ERROR(ERROR_REPLICATION_MASTER_ERROR, "master error"); diff --git a/lib/BasicsC/voc-errors.h b/lib/BasicsC/voc-errors.h index 4a6811d1eb..a0fd7a41b0 100644 --- a/lib/BasicsC/voc-errors.h +++ b/lib/BasicsC/voc-errors.h @@ -213,6 +213,8 @@ extern "C" { /// Will be raised when an attempt to create an index has failed. /// - 1300: @LIT{datafile full} /// Will be raised when the datafile reaches its limit. +/// - 1301: @LIT{server database directory is empty} +/// Will be raised when encoutering an empty server database directory. /// - 1400: @LIT{no response} /// Will be raised when the replication applier does not receive any or an /// incomplete response from the master. @@ -1444,6 +1446,16 @@ void TRI_InitialiseErrorMessages (void); #define TRI_ERROR_ARANGO_DATAFILE_FULL (1300) +//////////////////////////////////////////////////////////////////////////////// +/// @brief 1301: ERROR_ARANGO_EMPTY_DATADIR +/// +/// server database directory is empty +/// +/// Will be raised when encoutering an empty server database directory. +//////////////////////////////////////////////////////////////////////////////// + +#define TRI_ERROR_ARANGO_EMPTY_DATADIR (1301) + //////////////////////////////////////////////////////////////////////////////// /// @brief 1400: ERROR_REPLICATION_NO_RESPONSE /// From 613dc0613e76ba07abbe22bfeb3d6c310e453885 Mon Sep 17 00:00:00 2001 From: Frank Celler Date: Wed, 11 Jun 2014 19:31:03 +0200 Subject: [PATCH 3/4] fixed check-version for empty directory --- CHANGELOG | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 25a1e0191f..f83650bafe 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,8 @@ v2.2.0 (XXXX-XX-XX) ------------------- +* fixed check-version for empty directory + * moved try/catch block to the top of routing chain * added mountedApp function for foxx-manager From e6d68e607078650b4e8893b40fcd9a5d7bf245d9 Mon Sep 17 00:00:00 2001 From: scottashton Date: Thu, 12 Jun 2014 10:43:20 +0200 Subject: [PATCH 4/4] finished documenation for aql graph --- .../Books/Users/Aql/GraphOperations.mdpp | 2863 ++++++++++++++++- js/server/modules/org/arangodb/ahuacatl.js | 28 +- 2 files changed, 2872 insertions(+), 19 deletions(-) diff --git a/Documentation/Books/Users/Aql/GraphOperations.mdpp b/Documentation/Books/Users/Aql/GraphOperations.mdpp index a08dd9598c..41b1b70920 100644 --- a/Documentation/Books/Users/Aql/GraphOperations.mdpp +++ b/Documentation/Books/Users/Aql/GraphOperations.mdpp @@ -7,25 +7,2878 @@ This chapter describe graph related aql functions. +
+`GRAPH_PATHS (graphName, direction, followCycles, minLength, maxLength)` +*The GRAPH\_PATHS function returns all paths of a graph.* +
+This function determines all available paths in a graph identified by *graphName*. +Except for *graphName* every other parameter is optional. +
+* String *graphName* : The name of the graph. +* String *direction* : The direction of the edges. +Possible values are *any*, *inbound* and *outbound* (default). +* Boolean *followCycles* : If set to *true* the query follows cycles in the graph, +default is false. +* Number *minLength* : Defines the minimal length a path must +have to be returned (default is 0). +* Number *maxLength* : Defines the maximal length a path must +have to be returned (default is 10). +
+@EXAMPLES +
+Return all paths of the graph "social": +
+ +``` +arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); +arangosh> var g = examples.loadGraph("social"); +arangosh> db._query("RETURN GRAPH_PATHS('social')").toArray(); +[ + [ + { + "vertices" : [ + { + "_id" : "female/alice", + "_rev" : "196719176", + "_key" : "alice", + "name" : "Alice" + } + ], + "edges" : [ ], + "source" : { + "_id" : "female/alice", + "_rev" : "196719176", + "_key" : "alice", + "name" : "Alice" + }, + "destination" : { + "_id" : "female/alice", + "_rev" : "196719176", + "_key" : "alice", + "name" : "Alice" + } + }, + { + "vertices" : [ + { + "_id" : "female/alice", + "_rev" : "196719176", + "_key" : "alice", + "name" : "Alice" + }, + { + "_id" : "male/bob", + "_rev" : "197112392", + "_key" : "bob", + "name" : "Bob" + } + ], + "edges" : [ + { + "_id" : "relation/aliceAndBob", + "_rev" : "197898824", + "_key" : "aliceAndBob", + "_from" : "female/alice", + "_to" : "male/bob", + "type" : "married" + } + ], + "source" : { + "_id" : "female/alice", + "_rev" : "196719176", + "_key" : "alice", + "name" : "Alice" + }, + "destination" : { + "_id" : "male/bob", + "_rev" : "197112392", + "_key" : "bob", + "name" : "Bob" + } + }, + { + "vertices" : [ + { + "_id" : "female/alice", + "_rev" : "196719176", + "_key" : "alice", + "name" : "Alice" + }, + { + "_id" : "male/bob", + "_rev" : "197112392", + "_key" : "bob", + "name" : "Bob" + }, + { + "_id" : "female/diana", + "_rev" : "197505608", + "_key" : "diana", + "name" : "Diana" + } + ], + "edges" : [ + { + "_id" : "relation/aliceAndBob", + "_rev" : "197898824", + "_key" : "aliceAndBob", + "_from" : "female/alice", + "_to" : "male/bob", + "type" : "married" + }, + { + "_id" : "relation/bobAndDiana", + "_rev" : "198554184", + "_key" : "bobAndDiana", + "_from" : "male/bob", + "_to" : "female/diana", + "type" : "friend" + } + ], + "source" : { + "_id" : "female/alice", + "_rev" : "196719176", + "_key" : "alice", + "name" : "Alice" + }, + "destination" : { + "_id" : "female/diana", + "_rev" : "197505608", + "_key" : "diana", + "name" : "Diana" + } + }, + { + "vertices" : [ + { + "_id" : "female/alice", + "_rev" : "196719176", + "_key" : "alice", + "name" : "Alice" + }, + { + "_id" : "male/charly", + "_rev" : "197309000", + "_key" : "charly", + "name" : "Charly" + } + ], + "edges" : [ + { + "_id" : "relation/aliceAndCharly", + "_rev" : "198160968", + "_key" : "aliceAndCharly", + "_from" : "female/alice", + "_to" : "male/charly", + "type" : "friend" + } + ], + "source" : { + "_id" : "female/alice", + "_rev" : "196719176", + "_key" : "alice", + "name" : "Alice" + }, + "destination" : { + "_id" : "male/charly", + "_rev" : "197309000", + "_key" : "charly", + "name" : "Charly" + } + }, + { + "vertices" : [ + { + "_id" : "female/alice", + "_rev" : "196719176", + "_key" : "alice", + "name" : "Alice" + }, + { + "_id" : "male/charly", + "_rev" : "197309000", + "_key" : "charly", + "name" : "Charly" + }, + { + "_id" : "female/diana", + "_rev" : "197505608", + "_key" : "diana", + "name" : "Diana" + } + ], + "edges" : [ + { + "_id" : "relation/aliceAndCharly", + "_rev" : "198160968", + "_key" : "aliceAndCharly", + "_from" : "female/alice", + "_to" : "male/charly", + "type" : "friend" + }, + { + "_id" : "relation/charlyAndDiana", + "_rev" : "198357576", + "_key" : "charlyAndDiana", + "_from" : "male/charly", + "_to" : "female/diana", + "type" : "married" + } + ], + "source" : { + "_id" : "female/alice", + "_rev" : "196719176", + "_key" : "alice", + "name" : "Alice" + }, + "destination" : { + "_id" : "female/diana", + "_rev" : "197505608", + "_key" : "diana", + "name" : "Diana" + } + }, + { + "vertices" : [ + { + "_id" : "female/diana", + "_rev" : "197505608", + "_key" : "diana", + "name" : "Diana" + } + ], + "edges" : [ ], + "source" : { + "_id" : "female/diana", + "_rev" : "197505608", + "_key" : "diana", + "name" : "Diana" + }, + "destination" : { + "_id" : "female/diana", + "_rev" : "197505608", + "_key" : "diana", + "name" : "Diana" + } + }, + { + "vertices" : [ + { + "_id" : "male/bob", + "_rev" : "197112392", + "_key" : "bob", + "name" : "Bob" + } + ], + "edges" : [ ], + "source" : { + "_id" : "male/bob", + "_rev" : "197112392", + "_key" : "bob", + "name" : "Bob" + }, + "destination" : { + "_id" : "male/bob", + "_rev" : "197112392", + "_key" : "bob", + "name" : "Bob" + } + }, + { + "vertices" : [ + { + "_id" : "male/bob", + "_rev" : "197112392", + "_key" : "bob", + "name" : "Bob" + }, + { + "_id" : "female/diana", + "_rev" : "197505608", + "_key" : "diana", + "name" : "Diana" + } + ], + "edges" : [ + { + "_id" : "relation/bobAndDiana", + "_rev" : "198554184", + "_key" : "bobAndDiana", + "_from" : "male/bob", + "_to" : "female/diana", + "type" : "friend" + } + ], + "source" : { + "_id" : "male/bob", + "_rev" : "197112392", + "_key" : "bob", + "name" : "Bob" + }, + "destination" : { + "_id" : "female/diana", + "_rev" : "197505608", + "_key" : "diana", + "name" : "Diana" + } + }, + { + "vertices" : [ + { + "_id" : "male/charly", + "_rev" : "197309000", + "_key" : "charly", + "name" : "Charly" + } + ], + "edges" : [ ], + "source" : { + "_id" : "male/charly", + "_rev" : "197309000", + "_key" : "charly", + "name" : "Charly" + }, + "destination" : { + "_id" : "male/charly", + "_rev" : "197309000", + "_key" : "charly", + "name" : "Charly" + } + }, + { + "vertices" : [ + { + "_id" : "male/charly", + "_rev" : "197309000", + "_key" : "charly", + "name" : "Charly" + }, + { + "_id" : "female/diana", + "_rev" : "197505608", + "_key" : "diana", + "name" : "Diana" + } + ], + "edges" : [ + { + "_id" : "relation/charlyAndDiana", + "_rev" : "198357576", + "_key" : "charlyAndDiana", + "_from" : "male/charly", + "_to" : "female/diana", + "type" : "married" + } + ], + "source" : { + "_id" : "male/charly", + "_rev" : "197309000", + "_key" : "charly", + "name" : "Charly" + }, + "destination" : { + "_id" : "female/diana", + "_rev" : "197505608", + "_key" : "diana", + "name" : "Diana" + } + } + ] +] +``` +
+Return all inbound paths of the graph "social" with a maximal +length of 1 and a minimal length of 2: +
+ +``` +arangosh> ~require("internal").db; +-1 +arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); +arangosh> var g = examples.loadGraph("social"); +arangosh> db._query("RETURN GRAPH_PATHS('social', 'inbound', false, 1, 2)").toArray(); +[ + [ + { + "vertices" : [ + { + "_id" : "female/diana", + "_rev" : "128496200", + "_key" : "diana", + "name" : "Diana" + }, + { + "_id" : "male/charly", + "_rev" : "128299592", + "_key" : "charly", + "name" : "Charly" + } + ], + "edges" : [ + { + "_id" : "relation/charlyAndDiana", + "_rev" : "129348168", + "_key" : "charlyAndDiana", + "_from" : "male/charly", + "_to" : "female/diana", + "type" : "married" + } + ], + "source" : { + "_id" : "female/diana", + "_rev" : "128496200", + "_key" : "diana", + "name" : "Diana" + }, + "destination" : { + "_id" : "male/charly", + "_rev" : "128299592", + "_key" : "charly", + "name" : "Charly" + } + }, + { + "vertices" : [ + { + "_id" : "female/diana", + "_rev" : "128496200", + "_key" : "diana", + "name" : "Diana" + }, + { + "_id" : "male/charly", + "_rev" : "128299592", + "_key" : "charly", + "name" : "Charly" + }, + { + "_id" : "female/alice", + "_rev" : "127709768", + "_key" : "alice", + "name" : "Alice" + } + ], + "edges" : [ + { + "_id" : "relation/charlyAndDiana", + "_rev" : "129348168", + "_key" : "charlyAndDiana", + "_from" : "male/charly", + "_to" : "female/diana", + "type" : "married" + }, + { + "_id" : "relation/aliceAndCharly", + "_rev" : "129151560", + "_key" : "aliceAndCharly", + "_from" : "female/alice", + "_to" : "male/charly", + "type" : "friend" + } + ], + "source" : { + "_id" : "female/diana", + "_rev" : "128496200", + "_key" : "diana", + "name" : "Diana" + }, + "destination" : { + "_id" : "female/alice", + "_rev" : "127709768", + "_key" : "alice", + "name" : "Alice" + } + }, + { + "vertices" : [ + { + "_id" : "female/diana", + "_rev" : "128496200", + "_key" : "diana", + "name" : "Diana" + }, + { + "_id" : "male/bob", + "_rev" : "128102984", + "_key" : "bob", + "name" : "Bob" + } + ], + "edges" : [ + { + "_id" : "relation/bobAndDiana", + "_rev" : "129544776", + "_key" : "bobAndDiana", + "_from" : "male/bob", + "_to" : "female/diana", + "type" : "friend" + } + ], + "source" : { + "_id" : "female/diana", + "_rev" : "128496200", + "_key" : "diana", + "name" : "Diana" + }, + "destination" : { + "_id" : "male/bob", + "_rev" : "128102984", + "_key" : "bob", + "name" : "Bob" + } + }, + { + "vertices" : [ + { + "_id" : "female/diana", + "_rev" : "128496200", + "_key" : "diana", + "name" : "Diana" + }, + { + "_id" : "male/bob", + "_rev" : "128102984", + "_key" : "bob", + "name" : "Bob" + }, + { + "_id" : "female/alice", + "_rev" : "127709768", + "_key" : "alice", + "name" : "Alice" + } + ], + "edges" : [ + { + "_id" : "relation/bobAndDiana", + "_rev" : "129544776", + "_key" : "bobAndDiana", + "_from" : "male/bob", + "_to" : "female/diana", + "type" : "friend" + }, + { + "_id" : "relation/aliceAndBob", + "_rev" : "128889416", + "_key" : "aliceAndBob", + "_from" : "female/alice", + "_to" : "male/bob", + "type" : "married" + } + ], + "source" : { + "_id" : "female/diana", + "_rev" : "128496200", + "_key" : "diana", + "name" : "Diana" + }, + "destination" : { + "_id" : "female/alice", + "_rev" : "127709768", + "_key" : "alice", + "name" : "Alice" + } + }, + { + "vertices" : [ + { + "_id" : "male/bob", + "_rev" : "128102984", + "_key" : "bob", + "name" : "Bob" + }, + { + "_id" : "female/alice", + "_rev" : "127709768", + "_key" : "alice", + "name" : "Alice" + } + ], + "edges" : [ + { + "_id" : "relation/aliceAndBob", + "_rev" : "128889416", + "_key" : "aliceAndBob", + "_from" : "female/alice", + "_to" : "male/bob", + "type" : "married" + } + ], + "source" : { + "_id" : "male/bob", + "_rev" : "128102984", + "_key" : "bob", + "name" : "Bob" + }, + "destination" : { + "_id" : "female/alice", + "_rev" : "127709768", + "_key" : "alice", + "name" : "Alice" + } + }, + { + "vertices" : [ + { + "_id" : "male/charly", + "_rev" : "128299592", + "_key" : "charly", + "name" : "Charly" + }, + { + "_id" : "female/alice", + "_rev" : "127709768", + "_key" : "alice", + "name" : "Alice" + } + ], + "edges" : [ + { + "_id" : "relation/aliceAndCharly", + "_rev" : "129151560", + "_key" : "aliceAndCharly", + "_from" : "female/alice", + "_to" : "male/charly", + "type" : "friend" + } + ], + "source" : { + "_id" : "male/charly", + "_rev" : "128299592", + "_key" : "charly", + "name" : "Charly" + }, + "destination" : { + "_id" : "female/alice", + "_rev" : "127709768", + "_key" : "alice", + "name" : "Alice" + } + } + ] +] +``` + !SUBSECTION GRAPH_SHORTEST_PATH -!SUBSECTION_GRAPH_DISTANCE_TO +
+`GRAPH_SHORTEST_PATH (graphName, startVertexExample, endVertexExample, options)` +*The GRAPH\_SHORTEST\_PATH function returns all shortest paths of a graph.* +
+This function determines all shortest paths in a graph identified by *graphName*. +The function accepts an id, an example, a list of examples +or even an empty example as parameter for +start and end vertex. If one wants to calls this function to receive nearly all +shortest paths for a graph the +option *algorithm* should be set to *Floyd-Warshall* to increase performance. +If no algorithm is provided in the options the function chooses the appropriate +one (either *Floyd-Warshall* or *Dijsktra*) according to its parameters. +The length of a path is by default the amount of edges from one start vertex to +an end vertex. The option weight allows the user to define an edge attribute +representing the length. +
+* String *graphName* : The name of the graph. +* String|Object|Array *startVertexExample* : An example for the desired +start Vertices (see below). +* String|Object|Array *endVertexExample* : An example for the desired +end Vertices (see below). +* Object *options* : Optional options, see below: +
+Possible options and there defaults: +* String *direction* : The direction of the edges. +Possible values are *outbound*, *inbound* and *any* (default). +* String|Array *edgeCollectionRestriction* : One or multiple edge +collections that should be considered. +* String|Array *startVertexCollectionRestriction* : One or multiple vertex +collections that should be considered. +* String|Array *endVertexCollectionRestriction* : One or multiple vertex +collections that should be considered. +* String|Object|Array *edgeExamples* : A filter example for the +edges in the shortest paths (see below). +* String *algorithm* : The algorithm to calculate +the shortest paths. If both start and end vertex examples are empty *Floyd-Warshall* is +used, otherwise the default is *Dijkstra* +* String *weight* : The name of the attribute of +the edges containing the length. +* Number *defaultWeight* : Only used with the option *weight*. +If an edge does not have the attribute named as defined in option *weight* this default +is used as length. +If no default is supplied the default would be positive Infinity so the path could +not be calculated. +
+Examples for startVertexExample/endVertexExample: +* {} : Returns all possible start/end vertices for this graph. +* *idString* : Returns the vertex with the id *idString*. +* {*key* : *value*} : Returns the vertices that match this example. +* [{*key1* : *value1*}, {*key2* : *value2*}] : Returns the vertices that match one of +the examples. +
+@EXAMPLES +
+A route planner example, shortest distance from all villages to other cities: +
- +``` +arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); +arangosh> var g = examples.loadGraph("routeplanner"); +arangosh> db._query("FOR e IN GRAPH_SHORTEST_PATH(" +........> +"'routeplanner', {}, {}, {weight : 'distance', endVertexCollectionRestriction : 'city', " + +........> "startVertexCollectionRestriction : 'village'}) RETURN [e.startVertex, e.vertex._id, " + +........> "e.distance, LENGTH(e.paths)]" +........> ).toArray(); +[ + [ + "village/Rosenheim", + "city/Cologne", + 730, + 1 + ], + [ + "village/Rosenheim", + "city/Berlin", + 680, + 1 + ], + [ + "village/Rosenheim", + "city/Munich", + 80, + 1 + ], + [ + "village/Olpe", + "city/Berlin", + 700, + 1 + ], + [ + "village/Olpe", + "city/Munich", + 600, + 1 + ], + [ + "village/Olpe", + "city/Cologne", + 100, + 1 + ] +] +``` +
+A route planner example, shortest distance from Munich and Cologne to Olpe: +
-!SUBSECTION_GRAPH_TRAVERSAL +``` +arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); +arangosh> var g = examples.loadGraph("routeplanner"); +arangosh> db._query("FOR e IN GRAPH_SHORTEST_PATH(" +........> +"'routeplanner', [{_id: 'city/Cologne'},{_id: 'city/Munich'}], 'village/Olpe', " + +........> "{weight : 'distance'}) RETURN [e.startVertex, e.vertex._id, e.distance, LENGTH(e.paths)]" +........> ).toArray(); +[ + [ + "city/Cologne", + "village/Olpe", + 100, + 1 + ], + [ + "city/Munich", + "village/Olpe", + 600, + 1 + ] +] +``` +
+ +!SUBSECTION GRAPH_TRAVERSAL -!SUBSECTION_GRAPH_TRAVERSAL_TREE +
+`GRAPH_TRAVERSAL (graphName, startVertexExample, direction, options)` +*The GRAPH\_TRAVERSAL function traverses through the graph.* +
+This function performs traversals on the given graph. +For a more detailed documentation on the optional parameters see +[Traversals](../Traversals/README.md). +
+* String *graphName* : The name of the graph. +* String|Object|Array *startVerte* : The ID of the start vertex of the traversal. +* String|Object|Array *direction* : The direction of the edges. Possible values +are *outbound*, *inbound* and *any* (default). +* Object *options* : Optional options, see below: +
+@EXAMPLES +
+A route planner example, start a traversal from Munich : +
+ +``` +arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); +arangosh> var g = examples.loadGraph("routeplanner"); +arangosh> db._query("FOR e IN GRAPH_TRAVERSAL('routeplanner', 'city/Munich'," + +........> " 'outbound') RETURN e" +........> ).toArray(); +[ + { + "vertex" : { + "_id" : "city/Munich", + "_rev" : "113553992", + "_key" : "Munich", + "isCapital" : true, + "population" : 1000000 + } + }, + { + "vertex" : { + "_id" : "city/Cologne", + "_rev" : "113357384", + "_key" : "Cologne", + "isCapital" : false, + "population" : 1000000 + } + }, + { + "vertex" : { + "_id" : "village/Olpe", + "_rev" : "114012744", + "_key" : "Olpe", + "isCapital" : false, + "population" : 80000 + } + }, + { + "vertex" : { + "_id" : "village/Rosenheim", + "_rev" : "114209352", + "_key" : "Rosenheim", + "isCapital" : false, + "population" : 80000 + } + }, + { + "vertex" : { + "_id" : "village/Rosenheim", + "_rev" : "114209352", + "_key" : "Rosenheim", + "isCapital" : false, + "population" : 80000 + } + }, + { + "vertex" : { + "_id" : "village/Olpe", + "_rev" : "114012744", + "_key" : "Olpe", + "isCapital" : false, + "population" : 80000 + } + } +] +``` +
+A route planner example, start a traversal from Munich with a max depth of 1 +so only the direct neighbors of munich are returned: +
+ +``` +arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); +arangosh> var g = examples.loadGraph("routeplanner"); +arangosh> db._query("FOR e IN GRAPH_TRAVERSAL('routeplanner', 'city/Munich'," + +........> " 'outbound', {maxDepth : 1}) RETURN e" +........> ).toArray(); +[ + { + "vertex" : { + "_id" : "city/Munich", + "_rev" : "118600264", + "_key" : "Munich", + "isCapital" : true, + "population" : 1000000 + } + }, + { + "vertex" : { + "_id" : "city/Cologne", + "_rev" : "118403656", + "_key" : "Cologne", + "isCapital" : false, + "population" : 1000000 + } + }, + { + "vertex" : { + "_id" : "village/Rosenheim", + "_rev" : "119255624", + "_key" : "Rosenheim", + "isCapital" : false, + "population" : 80000 + } + }, + { + "vertex" : { + "_id" : "village/Olpe", + "_rev" : "119059016", + "_key" : "Olpe", + "isCapital" : false, + "population" : 80000 + } + } +] +``` +
+ +!SUBSECTION GRAPH_TRAVERSAL_TREE -!SUBSECTION_GRAPH_NEIGHBORS +
+`GRAPH_TRAVERSAL_TREE (graphName, startVertexExample, direction, connectName, options)` +*The GRAPH\_TRAVERSAL\_TREE function traverses through the graph.* +This function creates a tree format from the result for a better visualization of +the path. +This function performs traversals on the given graph. +For a more detailed documentation on the optional parameters see +[Traversals](../Traversals/README.md). +
+* String *graphName* : The name of the graph. +* String|Object|Array *startVerte* : The ID of the start vertex +of the traversal. +* String|Object|Array *direction* : The direction of the edges. +Possible values are *outbound*, *inbound* and *any* (default). +* String|Object|Array *connectName* : The result attribute which +contains the connection. +* Object *options* : Optional options, see below: +
+@EXAMPLES +
+A route planner example, start a traversal from Munich : +
+ +``` +arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); +arangosh> var g = examples.loadGraph("routeplanner"); +arangosh> db._query("FOR e IN GRAPH_TRAVERSAL_TREE('routeplanner', 'city/Munich'," + +........> " 'outbound', 'connnection') RETURN e" +........> ).toArray(); +[ + [ + { + "_id" : "city/Munich", + "_rev" : "157004360", + "_key" : "Munich", + "isCapital" : true, + "population" : 1000000, + "connnection" : [ + { + "_id" : "city/Cologne", + "_rev" : "156807752", + "_key" : "Cologne", + "isCapital" : false, + "population" : 1000000, + "connnection" : [ + { + "_id" : "village/Olpe", + "_rev" : "157463112", + "_key" : "Olpe", + "isCapital" : false, + "population" : 80000 + }, + { + "_id" : "village/Rosenheim", + "_rev" : "157659720", + "_key" : "Rosenheim", + "isCapital" : false, + "population" : 80000 + } + ] + }, + { + "_id" : "village/Rosenheim", + "_rev" : "157659720", + "_key" : "Rosenheim", + "isCapital" : false, + "population" : 80000 + }, + { + "_id" : "village/Olpe", + "_rev" : "157463112", + "_key" : "Olpe", + "isCapital" : false, + "population" : 80000 + } + ] + } + ] +] +``` +
+A route planner example, start a traversal from Munich with a max depth of 1 so +only the direct neighbors of munich are returned: +
+ +``` +arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); +arangosh> var g = examples.loadGraph("routeplanner"); +arangosh> db._query("FOR e IN GRAPH_TRAVERSAL_TREE('routeplanner', 'city/Munich',"+ +........> " 'outbound', 'connnection', {maxDepth : 1}) RETURN e" +........> ).toArray(); +[ + [ + { + "_id" : "city/Munich", + "_rev" : "162050632", + "_key" : "Munich", + "isCapital" : true, + "population" : 1000000, + "connnection" : [ + { + "_id" : "city/Cologne", + "_rev" : "161854024", + "_key" : "Cologne", + "isCapital" : false, + "population" : 1000000 + }, + { + "_id" : "village/Rosenheim", + "_rev" : "162705992", + "_key" : "Rosenheim", + "isCapital" : false, + "population" : 80000 + }, + { + "_id" : "village/Olpe", + "_rev" : "162509384", + "_key" : "Olpe", + "isCapital" : false, + "population" : 80000 + } + ] + } + ] +] +``` +
+ +!SUBSECTION GRAPH_DISTANCE_TO + + + +
+`GENERAL_GRAPH_DISTANCE_TO (graphName, startVertexExample, endVertexExample, options)` +/// *The GRAPH\_DISTANCE\_TO function returns all paths and there distance within a graph.* +/// +/// This function is a wrapper of [GRAPH\_SHORTEST\_PATH](#SUBSECTION GRAPH_SHORTEST_PATH). +/// It does not return the actual path but only the distance between two vertices. +
+ +!SUBSECTION GRAPH_NEIGHBORS +
+`GRAPH_NEIGHBORS (graphName, vertexExample, options)` +*The GRAPH\_NEIGHBORS function returns all neighbors of vertices.* +
+The function accepts an id, an example, a list of examples or even an empty +example as parameter for vertex. +
+* String *graphName* : The name of the graph. +* String|Object|Array *vertexExample* : An example for the desired +vertices (see below). +* Object *options* : Optional options, see below: +
+Possible options and there defaults: +* String *direction* : The direction +of the edges. Possible values are *outbound*, *inbound* and *any* (default). +* String|Object|Array *edgeExamples* : A filter example +for the edges to the neighbors (see below). +* String|Object|Array *neighborExamples* : An example for +the desired neighbors (see below). +* String|Array *edgeCollectionRestriction* : One or multiple +edge collections that should be considered. +* String|Array *vertexCollectionRestriction* : One or multiple +vertex collections that should be considered. +* Number *minDepth* : Defines the minimal +depth a path to a neighbor must have to be returned (default is 1). +* Number *maxDepth* : Defines the maximal +depth a path to a neighbor must have to be returned (default is 1). +
+Examples for edgeExamples/neighborExamples: +* {} : Returns all possible edges/neighbors for this graph. +* *idString* : Returns the edge/vertex with the id *idString*. +* {*key* : *value*} : Returns the edges/vertices that match this example. +* [{*key1* : *value1*}, {*key2* : *value2*}] : Returns the edges/vertices that +match one of the examples. +
+@EXAMPLES +
+A route planner example, all neighbors of locations with a distance of either +700 or 600.: +
+ +``` +arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); +arangosh> var g = examples.loadGraph("routeplanner"); +arangosh> db._query("FOR e IN GRAPH_NEIGHBORS(" +........> +"'routeplanner', {}, {edgeExamples : [{distance: 600}, {distance: 700}]}) RETURN e" +........> ).toArray(); +[ + { + "vertex" : { + "_id" : "city/Munich", + "_rev" : "78230088", + "_key" : "Munich", + "isCapital" : true, + "population" : 1000000 + }, + "path" : { + "edges" : [ + { + "_id" : "highway/79475272", + "_rev" : "79475272", + "_key" : "79475272", + "_from" : "city/Berlin", + "_to" : "city/Munich", + "distance" : 600 + } + ], + "vertices" : [ + { + "_id" : "city/Berlin", + "_rev" : "77836872", + "_key" : "Berlin", + "isCapital" : true, + "population" : 3000000 + }, + { + "_id" : "city/Munich", + "_rev" : "78230088", + "_key" : "Munich", + "isCapital" : true, + "population" : 1000000 + } + ] + }, + "startVertex" : "city/Berlin" + }, + { + "vertex" : { + "_id" : "village/Olpe", + "_rev" : "78688840", + "_key" : "Olpe", + "isCapital" : false, + "population" : 80000 + }, + "path" : { + "edges" : [ + { + "_id" : "road/80065096", + "_rev" : "80065096", + "_key" : "80065096", + "_from" : "city/Berlin", + "_to" : "village/Olpe", + "distance" : 700 + } + ], + "vertices" : [ + { + "_id" : "city/Berlin", + "_rev" : "77836872", + "_key" : "Berlin", + "isCapital" : true, + "population" : 3000000 + }, + { + "_id" : "village/Olpe", + "_rev" : "78688840", + "_key" : "Olpe", + "isCapital" : false, + "population" : 80000 + } + ] + }, + "startVertex" : "city/Berlin" + }, + { + "vertex" : { + "_id" : "city/Berlin", + "_rev" : "77836872", + "_key" : "Berlin", + "isCapital" : true, + "population" : 3000000 + }, + "path" : { + "edges" : [ + { + "_id" : "highway/79475272", + "_rev" : "79475272", + "_key" : "79475272", + "_from" : "city/Berlin", + "_to" : "city/Munich", + "distance" : 600 + } + ], + "vertices" : [ + { + "_id" : "city/Munich", + "_rev" : "78230088", + "_key" : "Munich", + "isCapital" : true, + "population" : 1000000 + }, + { + "_id" : "city/Berlin", + "_rev" : "77836872", + "_key" : "Berlin", + "isCapital" : true, + "population" : 3000000 + } + ] + }, + "startVertex" : "city/Munich" + }, + { + "vertex" : { + "_id" : "village/Olpe", + "_rev" : "78688840", + "_key" : "Olpe", + "isCapital" : false, + "population" : 80000 + }, + "path" : { + "edges" : [ + { + "_id" : "road/80654920", + "_rev" : "80654920", + "_key" : "80654920", + "_from" : "city/Munich", + "_to" : "village/Olpe", + "distance" : 600 + } + ], + "vertices" : [ + { + "_id" : "city/Munich", + "_rev" : "78230088", + "_key" : "Munich", + "isCapital" : true, + "population" : 1000000 + }, + { + "_id" : "village/Olpe", + "_rev" : "78688840", + "_key" : "Olpe", + "isCapital" : false, + "population" : 80000 + } + ] + }, + "startVertex" : "city/Munich" + }, + { + "vertex" : { + "_id" : "city/Berlin", + "_rev" : "77836872", + "_key" : "Berlin", + "isCapital" : true, + "population" : 3000000 + }, + "path" : { + "edges" : [ + { + "_id" : "road/80065096", + "_rev" : "80065096", + "_key" : "80065096", + "_from" : "city/Berlin", + "_to" : "village/Olpe", + "distance" : 700 + } + ], + "vertices" : [ + { + "_id" : "village/Olpe", + "_rev" : "78688840", + "_key" : "Olpe", + "isCapital" : false, + "population" : 80000 + }, + { + "_id" : "city/Berlin", + "_rev" : "77836872", + "_key" : "Berlin", + "isCapital" : true, + "population" : 3000000 + } + ] + }, + "startVertex" : "village/Olpe" + }, + { + "vertex" : { + "_id" : "city/Munich", + "_rev" : "78230088", + "_key" : "Munich", + "isCapital" : true, + "population" : 1000000 + }, + "path" : { + "edges" : [ + { + "_id" : "road/80654920", + "_rev" : "80654920", + "_key" : "80654920", + "_from" : "city/Munich", + "_to" : "village/Olpe", + "distance" : 600 + } + ], + "vertices" : [ + { + "_id" : "village/Olpe", + "_rev" : "78688840", + "_key" : "Olpe", + "isCapital" : false, + "population" : 80000 + }, + { + "_id" : "city/Munich", + "_rev" : "78230088", + "_key" : "Munich", + "isCapital" : true, + "population" : 1000000 + } + ] + }, + "startVertex" : "village/Olpe" + } +] +``` +
+A route planner example, all outbound neighbors of munich with a maximal depth of 2 : +
+ +``` +arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); +arangosh> var g = examples.loadGraph("routeplanner"); +arangosh> db._query("FOR e IN GRAPH_NEIGHBORS(" +........> +"'routeplanner', 'city/Munich', {direction : 'outbound', maxDepth : 2}) RETURN e" +........> ).toArray(); +[ + { + "vertex" : { + "_id" : "city/Cologne", + "_rev" : "131576392", + "_key" : "Cologne", + "isCapital" : false, + "population" : 1000000 + }, + "path" : { + "edges" : [ + { + "_id" : "highway/133214792", + "_rev" : "133214792", + "_key" : "133214792", + "_from" : "city/Munich", + "_to" : "city/Cologne", + "distance" : 650 + } + ], + "vertices" : [ + { + "_id" : "city/Munich", + "_rev" : "131773000", + "_key" : "Munich", + "isCapital" : true, + "population" : 1000000 + }, + { + "_id" : "city/Cologne", + "_rev" : "131576392", + "_key" : "Cologne", + "isCapital" : false, + "population" : 1000000 + } + ] + }, + "startVertex" : "city/Munich" + }, + { + "vertex" : { + "_id" : "village/Olpe", + "_rev" : "132231752", + "_key" : "Olpe", + "isCapital" : false, + "population" : 80000 + }, + "path" : { + "edges" : [ + { + "_id" : "highway/133214792", + "_rev" : "133214792", + "_key" : "133214792", + "_from" : "city/Munich", + "_to" : "city/Cologne", + "distance" : 650 + }, + { + "_id" : "road/134394440", + "_rev" : "134394440", + "_key" : "134394440", + "_from" : "city/Cologne", + "_to" : "village/Olpe", + "distance" : 100 + } + ], + "vertices" : [ + { + "_id" : "city/Munich", + "_rev" : "131773000", + "_key" : "Munich", + "isCapital" : true, + "population" : 1000000 + }, + { + "_id" : "city/Cologne", + "_rev" : "131576392", + "_key" : "Cologne", + "isCapital" : false, + "population" : 1000000 + }, + { + "_id" : "village/Olpe", + "_rev" : "132231752", + "_key" : "Olpe", + "isCapital" : false, + "population" : 80000 + } + ] + }, + "startVertex" : "city/Munich" + }, + { + "vertex" : { + "_id" : "village/Rosenheim", + "_rev" : "132428360", + "_key" : "Rosenheim", + "isCapital" : false, + "population" : 80000 + }, + "path" : { + "edges" : [ + { + "_id" : "highway/133214792", + "_rev" : "133214792", + "_key" : "133214792", + "_from" : "city/Munich", + "_to" : "city/Cologne", + "distance" : 650 + }, + { + "_id" : "road/134591048", + "_rev" : "134591048", + "_key" : "134591048", + "_from" : "city/Cologne", + "_to" : "village/Rosenheim", + "distance" : 750 + } + ], + "vertices" : [ + { + "_id" : "city/Munich", + "_rev" : "131773000", + "_key" : "Munich", + "isCapital" : true, + "population" : 1000000 + }, + { + "_id" : "city/Cologne", + "_rev" : "131576392", + "_key" : "Cologne", + "isCapital" : false, + "population" : 1000000 + }, + { + "_id" : "village/Rosenheim", + "_rev" : "132428360", + "_key" : "Rosenheim", + "isCapital" : false, + "population" : 80000 + } + ] + }, + "startVertex" : "city/Munich" + }, + { + "vertex" : { + "_id" : "village/Rosenheim", + "_rev" : "132428360", + "_key" : "Rosenheim", + "isCapital" : false, + "population" : 80000 + }, + "path" : { + "edges" : [ + { + "_id" : "road/134001224", + "_rev" : "134001224", + "_key" : "134001224", + "_from" : "city/Munich", + "_to" : "village/Rosenheim", + "distance" : 80 + } + ], + "vertices" : [ + { + "_id" : "city/Munich", + "_rev" : "131773000", + "_key" : "Munich", + "isCapital" : true, + "population" : 1000000 + }, + { + "_id" : "village/Rosenheim", + "_rev" : "132428360", + "_key" : "Rosenheim", + "isCapital" : false, + "population" : 80000 + } + ] + }, + "startVertex" : "city/Munich" + }, + { + "vertex" : { + "_id" : "village/Olpe", + "_rev" : "132231752", + "_key" : "Olpe", + "isCapital" : false, + "population" : 80000 + }, + "path" : { + "edges" : [ + { + "_id" : "road/134197832", + "_rev" : "134197832", + "_key" : "134197832", + "_from" : "city/Munich", + "_to" : "village/Olpe", + "distance" : 600 + } + ], + "vertices" : [ + { + "_id" : "city/Munich", + "_rev" : "131773000", + "_key" : "Munich", + "isCapital" : true, + "population" : 1000000 + }, + { + "_id" : "village/Olpe", + "_rev" : "132231752", + "_key" : "Olpe", + "isCapital" : false, + "population" : 80000 + } + ] + }, + "startVertex" : "city/Munich" + } +] +``` +
+ + + +!SUBSECTION GRAPH_EDGES + + + +
+`GRAPH_EDGES (graphName, vertexExample, options)` +*The GRAPH\_EDGES function returns all edges of vertices.* +
+The function accepts an id, an example, a list of examples or even an empty +example as parameter for vertex. +
+* String *graphName* : The name of the graph. +* String|Object|Array *vertexExample* : An example for the desired +vertices (see below). +* Object *options* : Optional options, see below: +
+Possible options and there defaults: +* String *direction* : The direction +of the edges. Possible values are *outbound*, *inbound* and *any* (default). +* String|Array *edgeCollectionRestriction* : One or multiple +edge collections that should be considered. +* String|Array *startVertexCollectionRestriction* : One or multiple +vertex collections that should be considered. +* String|Array *endVertexCollectionRestriction* : One or multiple +vertex collections that should be considered. +* String|Object|Array *edgeExamples* : A filter example +for the edges (see below). +* String|Object|Array *neighborExamples* : An example for +the desired neighbors (see below). +* Number *minDepth* : Defines the minimal +depth a path to a neighbor must have to be returned (default is 1). +* Number *maxDepth* : Defines the maximal +depth a path to a neighbor must have to be returned (default is 1). +
+Examples for edgeExamples/neighborExamples: +* {} : Returns all possible edges/neighbors for this graph. +* *idString* : Returns the edge/vertex with the id *idString*. +* {*key* : *value*} : Returns the edges/vertices that match this example. +* [{*key1* : *value1*}, {*key2* : *value2*}] : Returns the edges/vertices that +match one of the examples. +
+@EXAMPLES +
+A route planner example, all edges to locations with a distance of either 700 or 600.: +
+ +``` +arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); +arangosh> var g = examples.loadGraph("routeplanner"); +arangosh> db._query("FOR e IN GRAPH_EDGES(" +........> +"'routeplanner', {}, {edgeExamples : [{distance: 600}, {distance: 700}]}) RETURN e" +........> ).toArray(); +[ + { + "_id" : "highway/29012552", + "_rev" : "29012552", + "_key" : "29012552", + "_from" : "city/Berlin", + "_to" : "city/Munich", + "distance" : 600 + }, + { + "_id" : "road/29602376", + "_rev" : "29602376", + "_key" : "29602376", + "_from" : "city/Berlin", + "_to" : "village/Olpe", + "distance" : 700 + }, + { + "_id" : "highway/29012552", + "_rev" : "29012552", + "_key" : "29012552", + "_from" : "city/Berlin", + "_to" : "city/Munich", + "distance" : 600 + }, + { + "_id" : "road/30192200", + "_rev" : "30192200", + "_key" : "30192200", + "_from" : "city/Munich", + "_to" : "village/Olpe", + "distance" : 600 + }, + { + "_id" : "road/29602376", + "_rev" : "29602376", + "_key" : "29602376", + "_from" : "city/Berlin", + "_to" : "village/Olpe", + "distance" : 700 + }, + { + "_id" : "road/30192200", + "_rev" : "30192200", + "_key" : "30192200", + "_from" : "city/Munich", + "_to" : "village/Olpe", + "distance" : 600 + } +] +``` +
+A route planner example, all outbound edges of munich with a maximal depth of 2 : +
+ +``` +arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); +arangosh> var g = examples.loadGraph("routeplanner"); +arangosh> db._query("FOR e IN GRAPH_EDGES(" +........> +"'routeplanner', 'city/Munich', {direction : 'outbound', maxDepth : 2}) RETURN e" +........> ).toArray(); +[ + { + "_id" : "highway/34255432", + "_rev" : "34255432", + "_key" : "34255432", + "_from" : "city/Munich", + "_to" : "city/Cologne", + "distance" : 650 + }, + { + "_id" : "highway/34255432", + "_rev" : "34255432", + "_key" : "34255432", + "_from" : "city/Munich", + "_to" : "city/Cologne", + "distance" : 650 + }, + { + "_id" : "road/35435080", + "_rev" : "35435080", + "_key" : "35435080", + "_from" : "city/Cologne", + "_to" : "village/Olpe", + "distance" : 100 + }, + { + "_id" : "highway/34255432", + "_rev" : "34255432", + "_key" : "34255432", + "_from" : "city/Munich", + "_to" : "city/Cologne", + "distance" : 650 + }, + { + "_id" : "road/35631688", + "_rev" : "35631688", + "_key" : "35631688", + "_from" : "city/Cologne", + "_to" : "village/Rosenheim", + "distance" : 750 + }, + { + "_id" : "road/35041864", + "_rev" : "35041864", + "_key" : "35041864", + "_from" : "city/Munich", + "_to" : "village/Rosenheim", + "distance" : 80 + }, + { + "_id" : "road/35238472", + "_rev" : "35238472", + "_key" : "35238472", + "_from" : "city/Munich", + "_to" : "village/Olpe", + "distance" : 600 + } +] +``` +
+ + + +!SUBSECTION GRAPH_VERTICES + + + +
+`GRAPH_VERTICES (graphName, vertexExample, options)` +*The GRAPH\_VERTICES function returns all vertices.* +
+The function accepts an id, an example, a list of examples or even an empty +example as parameter for vertex. +According to the optional filters it will only return vertices that have +outbound, onbound or any (default) edges. +
+* String *graphName* : The name of the graph. +* String|Object|Array *vertexExample* : An example for the desired +vertices (see below). +* Object *options* : Optional options, see below: +
+Possible options and there defaults: +* String *direction* : The direction of the +edges. Possible values are *outbound*, *inbound* and *any* (default). +* String|Array *vertexCollectionRestriction* : One or multiple +vertex collections that should be considered. +
+Examples for vertexExample: +* {} : Returns all possible vertices for this graph. +* *idString* : Returns the vertex with the id *idString*. +* {*key* : *value*} : Returns the vertices that match this example. +* [{*key1* : *value1*}, {*key2* : *value2*}] : Returns the vertices that +match one of the examples. +
+@EXAMPLES +
+A route planner example, all vertices of the graph +
+ +``` +arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); +arangosh> var g = examples.loadGraph("routeplanner"); +arangosh> db._query("FOR e IN GRAPH_COMMON_NEIGHBORS(" +........> +"'routeplanner', {}) RETURN e" +........> ).toArray(); +[ArangoError 1541: invalid number of arguments for function '_AQL:GRAPH_COMMON_NEIGHBORS()'] +``` +
+A route planner example, all vertices from collection *city*. +
+ +``` +arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); +arangosh> var g = examples.loadGraph("routeplanner"); +arangosh> db._query("FOR e IN GRAPH_COMMON_NEIGHBORS(" +........> +"'routeplanner', {}, {direction : 'any', vertexCollectionRestriction" + +........> " : 'city'}) RETURN e" +........> ).toArray(); +[ ] +``` +
+ + +!SUBSECTION GRAPH_COMMON_NEIGHBORS + + + +
+`GRAPH_VERTICES (graphName, vertexExample, options)` +*The GRAPH\_VERTICES function returns all vertices.* +
+The function accepts an id, an example, a list of examples or even an empty +example as parameter for vertex. +According to the optional filters it will only return vertices that have +outbound, onbound or any (default) edges. +
+* String *graphName* : The name of the graph. +* String|Object|Array *vertexExample* : An example for the desired +vertices (see below). +* Object *options* : Optional options, see below: +
+Possible options and there defaults: +* String *direction* : The direction of the +edges. Possible values are *outbound*, *inbound* and *any* (default). +* String|Array *vertexCollectionRestriction* : One or multiple +vertex collections that should be considered. +
+Examples for vertexExample: +* {} : Returns all possible vertices for this graph. +* *idString* : Returns the vertex with the id *idString*. +* {*key* : *value*} : Returns the vertices that match this example. +* [{*key1* : *value1*}, {*key2* : *value2*}] : Returns the vertices that +match one of the examples. +
+@EXAMPLES +
+A route planner example, all vertices of the graph +
+ +``` +arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); +arangosh> var g = examples.loadGraph("routeplanner"); +arangosh> db._query("FOR e IN GRAPH_COMMON_NEIGHBORS(" +........> +"'routeplanner', {isCapital : true}, {isCapital : true}) RETURN e" +........> ).toArray(); +[ + { + "city/Berlin" : { + "city/Munich" : [ + { + "_id" : "city/Cologne", + "_rev" : "214651185", + "_key" : "Cologne", + "isCapital" : false, + "population" : 1000000 + }, + { + "_id" : "village/Olpe", + "_rev" : "215306545", + "_key" : "Olpe", + "isCapital" : false, + "population" : 80000 + }, + { + "_id" : "village/Rosenheim", + "_rev" : "215503153", + "_key" : "Rosenheim", + "isCapital" : false, + "population" : 80000 + } + ] + } + }, + { + "city/Munich" : { + "city/Berlin" : [ + { + "_id" : "city/Cologne", + "_rev" : "214651185", + "_key" : "Cologne", + "isCapital" : false, + "population" : 1000000 + }, + { + "_id" : "village/Olpe", + "_rev" : "215306545", + "_key" : "Olpe", + "isCapital" : false, + "population" : 80000 + }, + { + "_id" : "village/Rosenheim", + "_rev" : "215503153", + "_key" : "Rosenheim", + "isCapital" : false, + "population" : 80000 + } + ] + } + } +] +``` +
+A route planner example, all vertices from collection *city*. +
+ +``` +arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); +arangosh> var g = examples.loadGraph("routeplanner"); +arangosh> db._query("FOR e IN GRAPH_COMMON_NEIGHBORS(" +........> +"'routeplanner', 'city/Munich', {}, {direction : 'outbound', maxDepth : 2}, "+ +........> "{direction : 'outbound', maxDepth : 2}) RETURN e" +........> ).toArray(); +[ + { + "city/Munich" : { + "city/Berlin" : [ + { + "_id" : "city/Cologne", + "_rev" : "204558641", + "_key" : "Cologne", + "isCapital" : false, + "population" : 1000000 + }, + { + "_id" : "village/Olpe", + "_rev" : "205214001", + "_key" : "Olpe", + "isCapital" : false, + "population" : 80000 + }, + { + "_id" : "village/Rosenheim", + "_rev" : "205410609", + "_key" : "Rosenheim", + "isCapital" : false, + "population" : 80000 + } + ], + "city/Cologne" : [ + { + "_id" : "village/Olpe", + "_rev" : "205214001", + "_key" : "Olpe", + "isCapital" : false, + "population" : 80000 + }, + { + "_id" : "village/Rosenheim", + "_rev" : "205410609", + "_key" : "Rosenheim", + "isCapital" : false, + "population" : 80000 + } + ] + } + } +] +``` +
+ + + +!SUBSECTION GRAPH_COMMON_PROPERTIES + + + +
+`GRAPH_COMMON_PROPERTIES (graphName, vertex1Example, vertex2Examples, options)` +*The GRAPH\_COMMON\_PROPERTIES function returns all vertices +defined by the examples that share common properties +
+The function accepts an id, an example, a list of examples or even an empty +example as parameter for vertex1Example and vertex2Example. +
+* String *graphName* : The name of the graph. +* String|Object|Array *vertex1Example* : An example for the desired +vertices (see below). +* String|Object|Array *vertex2Example* : An example for the desired +vertices (see below). +* Object *options* : Optional options, see below: +
+Possible options and there defaults: +// * String|Array *vertex1CollectionRestriction* : One or multiple +vertex collections that should be considered. +* String|Array *vertex2CollectionRestriction* : One or multiple +vertex collections that should be considered. +* String|Array *ignoreProperties* : One or multiple +attributes of a document that should be ignored. +
+Examples for vertexExample: +* {} : Returns all possible vertices for this graph. +* *idString* : Returns the vertex with the id *idString*. +* {*key* : *value*} : Returns the vertices that match this example. +* [{*key1* : *value1*}, {*key2* : *value2*}] : Returns the vertices that +match one of the examples. +
+@EXAMPLES +
+A route planner example, all locations with the same properties: +
+ +``` +arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); +arangosh> var g = examples.loadGraph("routeplanner"); +arangosh> db._query("FOR e IN GRAPH_COMMON_PROPERTIES(" +........> +"'routeplanner', {}, {}) RETURN e" +........> ).toArray(); +[ + { + "city/Berlin" : [ + { + "_id" : "city/Munich", + "_rev" : "77156657", + "_key" : "Munich", + "isCapital" : true, + "population" : 1000000 + } + ] + }, + { + "city/Munich" : [ + { + "_id" : "city/Berlin", + "_rev" : "76763441", + "_key" : "Berlin", + "isCapital" : true, + "population" : 3000000 + }, + { + "_id" : "city/Cologne", + "_rev" : "76960049", + "_key" : "Cologne", + "isCapital" : false, + "population" : 1000000 + } + ] + }, + { + "city/Cologne" : [ + { + "_id" : "village/Rosenheim", + "_rev" : "77812017", + "_key" : "Rosenheim", + "isCapital" : false, + "population" : 80000 + }, + { + "_id" : "village/Olpe", + "_rev" : "77615409", + "_key" : "Olpe", + "isCapital" : false, + "population" : 80000 + }, + { + "_id" : "city/Munich", + "_rev" : "77156657", + "_key" : "Munich", + "isCapital" : true, + "population" : 1000000 + } + ] + }, + { + "village/Rosenheim" : [ + { + "_id" : "city/Cologne", + "_rev" : "76960049", + "_key" : "Cologne", + "isCapital" : false, + "population" : 1000000 + }, + { + "_id" : "village/Olpe", + "_rev" : "77615409", + "_key" : "Olpe", + "isCapital" : false, + "population" : 80000 + } + ] + }, + { + "village/Olpe" : [ + { + "_id" : "city/Cologne", + "_rev" : "76960049", + "_key" : "Cologne", + "isCapital" : false, + "population" : 1000000 + }, + { + "_id" : "village/Rosenheim", + "_rev" : "77812017", + "_key" : "Rosenheim", + "isCapital" : false, + "population" : 80000 + } + ] + } +] +``` +
+A route planner example, all cities which share same properties except for population. +
+ +``` +arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); +arangosh> var g = examples.loadGraph("routeplanner"); +arangosh> db._query("FOR e IN GRAPH_COMMON_PROPERTIES(" +........> +"'routeplanner', {}, {}, {vertex1CollectionRestriction : 'city', " + +........> "vertex2CollectionRestriction : 'city'" + +........> " ,ignoreProperties: 'population'}) RETURN e" +........> ).toArray(); +[ + { + "city/Berlin" : [ + { + "_id" : "city/Munich", + "_rev" : "67064113", + "_key" : "Munich", + "isCapital" : true, + "population" : 1000000 + } + ] + }, + { + "city/Munich" : [ + { + "_id" : "city/Berlin", + "_rev" : "66670897", + "_key" : "Berlin", + "isCapital" : true, + "population" : 3000000 + } + ] + } +] +``` +
+ + + +!SUBSECTION GRAPH_ABSOLUTE_ECCENTRICITY + + + +
+`GRAPH_ABSOLUTE_ECCENTRICITY (graphName, vertexExample, options)` +*The GRAPH\_ABSOLUTE\_ECCENTRICITY function returns the +[eccentricity](http://en.wikipedia.org/wiki/Distance_%28graph_theory%29) +of the vertices defined by the examples. +
+The function accepts an id, an example, a list of examples or even an empty +example as parameter for vertexExample. +
+* String *graphName* : The name of the graph. +* String|Object|Array *vertexExample* : An example for the desired +vertices (see below). +* Object *options* : Optional options, see below: +
+Possible options and there defaults: +* String *direction* : The direction of the edges. +Possible values are *outbound*, *inbound* and *any* (default). +* String|Array *edgeCollectionRestriction* : One or multiple edge +collections that should be considered. +* String|Array *startVertexCollectionRestriction* : One or multiple vertex +collections that should be considered. +* String|Array *endVertexCollectionRestriction* : One or multiple vertex +collections that should be considered. +* String|Object|Array *edgeExamples* : A filter example for the +edges in the shortest paths (see below). +* String *algorithm* : The algorithm to calculate +the shortest paths. +* String *weight* : The name of the attribute of +the edges containing the length. +* Number *defaultWeight* : Only used with the option *weight*. +If an edge does not have the attribute named as defined in option *weight* this default +is used as length. +If no default is supplied the default would be positive Infinity so the path and +hence the eccentricity can not be calculated. +
+Examples for vertexExample: +* {} : Returns all possible vertices for this graph. +* *idString* : Returns the vertex with the id *idString*. +* {*key* : *value*} : Returns the vertices that match this example. +* [{*key1* : *value1*}, {*key2* : *value2*}] : Returns the vertices that +match one of the examples. +
+@EXAMPLES +
+A route planner example, the absolute eccentricity of all locations. +
+ +``` +arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); +arangosh> var g = examples.loadGraph("routeplanner"); +arangosh> db._query("RETURN GRAPH_ABSOLUTE_ECCENTRICITY(" +........> +"'routeplanner', {})" +........> ).toArray(); +[ + { + "city/Munich" : 1, + "city/Cologne" : 1, + "city/Berlin" : 1, + "village/Olpe" : 2, + "village/Rosenheim" : 2 + } +] +``` +
+A route planner example, the absolute eccentricity of all locations. +This considers the actual distances. +
+ +``` +arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); +arangosh> var g = examples.loadGraph("routeplanner"); +arangosh> db._query("RETURN GRAPH_ABSOLUTE_ECCENTRICITY(" +........> +"'routeplanner', {}, {weight : 'distance'})" +........> ).toArray(); +[ + { + "city/Berlin" : 800, + "city/Munich" : 650, + "city/Cologne" : 800, + "village/Rosenheim" : 730, + "village/Olpe" : 700 + } +] +``` +
+A route planner example, the absolute eccentricity of all cities regarding only +outbound pathes. +
+ +``` +arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); +arangosh> var g = examples.loadGraph("routeplanner"); +arangosh> db._query("RETURN GRAPH_ABSOLUTE_ECCENTRICITY(" +........> + "'routeplanner', {}, {startVertexCollectionRestriction : 'city', " + +........> "direction : 'outbound', weight : 'distance'})" +........> ).toArray(); +[ + { + "city/Munich" : 650, + "city/Berlin" : 850, + "city/Cologne" : 750 + } +] +``` +
+ + +!SUBSECTION GRAPH_ECCENTRICITY + + + +
+`GRAPH_ECCENTRICITY (graphName, options)` +*The GRAPH\_ECCENTRICITY function returns the normalized +[eccentricity](http://en.wikipedia.org/wiki/Distance_%28graph_theory%29) +of the graphs vertices +
+* String *graphName* : The name of the graph. +* Object *options* : Optional options, see below: +
+Possible options and there defaults: +* String *direction* : The direction of the edges. +Possible values are *outbound*, *inbound* and *any* (default). +* String *algorithm* : The algorithm to calculate +the shortest paths. +* String *weight* : The name of the attribute of +the edges containing the length. +* Number *defaultWeight* : Only used with the option *weight*. +If an edge does not have the attribute named as defined in option *weight* this default +is used as length. +If no default is supplied the default would be positive Infinity so the path and +hence the eccentricity can not be calculated. +
+@EXAMPLES +
+A route planner example, the eccentricity of all locations. +
+ +``` +arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); +arangosh> var g = examples.loadGraph("routeplanner"); +arangosh> db._query("RETURN GRAPH_ECCENTRICITY(" +........> +"'routeplanner')" +........> ).toArray(); +[ + { + "city/Berlin" : 1, + "city/Munich" : 1, + "city/Cologne" : 1, + "village/Rosenheim" : 0.5, + "village/Olpe" : 0.5 + } +] +``` +
+A route planner example, the eccentricity of all locations. +This considers the actual distances. +
+ +``` +arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); +arangosh> var g = examples.loadGraph("routeplanner"); +arangosh> db._query("RETURN GRAPH_ECCENTRICITY(" +........> +"'routeplanner', {weight : 'distance'})" +........> ).toArray(); +[ + { + "city/Munich" : 1, + "city/Cologne" : 0.8125, + "city/Berlin" : 0.8125, + "village/Olpe" : 0.9285714285714286, + "village/Rosenheim" : 0.8904109589041096 + } +] +``` +
+ +!SUBSECTION GRAPH_ABSOLUTE_CLOSENESS + + + +
+`GRAPH_ABSOLUTE_CLOSENESS (graphName, vertexExample, options)` +*The GRAPH\_ABSOLUTE\_CLOSENESS function returns the +[closeness](http://en.wikipedia.org/wiki/Centrality#Closeness_centrality) +of the vertices defined by the examples. +
+The function accepts an id, an example, a list of examples or even an empty +example as parameter for vertexExample. +
+* String *graphName* : The name of the graph. +* String|Object|Array *vertexExample* : An example for the desired +vertices (see below). +* Object *options* : Optional options, see below: +
+Possible options and there defaults: +* String *direction* : The direction of the edges. +Possible values are *outbound*, *inbound* and *any* (default). +* String|Array *edgeCollectionRestriction* : One or multiple edge +collections that should be considered. +* String|Array *startVertexCollectionRestriction* : One or multiple vertex +collections that should be considered. +* String|Array *endVertexCollectionRestriction* : One or multiple vertex +collections that should be considered. +* String|Object|Array *edgeExamples* : A filter example for the +edges in the shortest paths (see below). +* String *algorithm* : The algorithm to calculate +the shortest paths. +* String *weight* : The name of the attribute of +the edges containing the length. +* Number *defaultWeight* : Only used with the option *weight*. +If an edge does not have the attribute named as defined in option *weight* this default +is used as length. +If no default is supplied the default would be positive Infinity so the path and +hence the eccentricity can not be calculated. +
+Examples for vertexExample: +* {} : Returns all possible vertices for this graph. +* *idString* : Returns the vertex with the id *idString*. +* {*key* : *value*} : Returns the vertices that match this example. +* [{*key1* : *value1*}, {*key2* : *value2*}] : Returns the vertices that +match one of the examples. +
+@EXAMPLES +
+A route planner example, the absolute closeness of all locations. +
+ +``` +arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); +arangosh> var g = examples.loadGraph("routeplanner"); +arangosh> db._query("RETURN GRAPH_ABSOLUTE_CLOSENESS(" +........> +"'routeplanner', {})" +........> ).toArray(); +[ + { + "city/Berlin" : 4, + "city/Cologne" : 4, + "city/Munich" : 4, + "village/Rosenheim" : 5, + "village/Olpe" : 5 + } +] +``` +
+A route planner example, the absolute closeness of all locations. +This considers the actual distances. +
+ +``` +arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); +arangosh> var g = examples.loadGraph("routeplanner"); +arangosh> db._query("RETURN GRAPH_ABSOLUTE_CLOSENESS(" +........> +"'routeplanner', {}, {weight : 'distance'})" +........> ).toArray(); +[ + { + "city/Berlin" : 2780, + "city/Cologne" : 2280, + "city/Munich" : 1930, + "village/Olpe" : 2080, + "village/Rosenheim" : 2170 + } +] +``` +
+A route planner example, the absolute closeness of all cities regarding only +outbound pathes. +
+ +``` +arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); +arangosh> var g = examples.loadGraph("routeplanner"); +arangosh> db._query("RETURN GRAPH_ABSOLUTE_CLOSENESS(" +........> + "'routeplanner', {}, {startVertexCollectionRestriction : 'city', " + +........> "direction : 'outbound', weight : 'distance'})" +........> ).toArray(); +[ + { + "city/Berlin" : 2830, + "city/Munich" : 1330, + "city/Cologne" : 850 + } +] +``` +
+ +!SUBSECTION GRAPH_CLOSENESS + + + +
+`GRAPH_CLOSENESS (graphName, options)` +*The GRAPH\_CLOSENESS function returns the normalized +[closeness](http://en.wikipedia.org/wiki/Centrality#Closeness_centrality) +of graphs vertices. +
+* String *graphName* : The name of the graph. +* Object *options* : Optional options, see below: +
+Possible options and there defaults: +* String *direction* : The direction of the edges. +Possible values are *outbound*, *inbound* and *any* (default). +* String *algorithm* : The algorithm to calculate +the shortest paths. +* String *weight* : The name of the attribute of +the edges containing the length. +* Number *defaultWeight* : Only used with the option *weight*. +If an edge does not have the attribute named as defined in option *weight* this default +is used as length. +If no default is supplied the default would be positive Infinity so the path and +hence the eccentricity can not be calculated. +
+@EXAMPLES +
+A route planner example, the closeness of all locations. +
+ +``` +arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); +arangosh> var g = examples.loadGraph("routeplanner"); +arangosh> db._query("RETURN GRAPH_CLOSENESS(" +........> +"'routeplanner')" +........> ).toArray(); +[ + { + "city/Berlin" : 1, + "city/Munich" : 1, + "city/Cologne" : 1, + "village/Rosenheim" : 0.8, + "village/Olpe" : 0.8 + } +] +``` +
+A route planner example, the closeness of all locations. +This considers the actual distances. +
+ +``` +arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); +arangosh> var g = examples.loadGraph("routeplanner"); +arangosh> db._query("RETURN GRAPH_CLOSENESS(" +........> +"'routeplanner', {weight : 'distance'})" +........> ).toArray(); +[ + { + "city/Munich" : 1, + "city/Cologne" : 0.8464912280701755, + "city/Berlin" : 0.6942446043165468, + "village/Rosenheim" : 0.8894009216589862, + "village/Olpe" : 0.9278846153846155 + } +] +``` +
+A route planner example, the absolute closeness of all cities regarding only +outbound pathes. +
+ +``` +arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); +arangosh> var g = examples.loadGraph("routeplanner"); +arangosh> db._query("RETURN GRAPH_CLOSENESS(" +........> + "'routeplanner',{direction : 'outbound', weight : 'distance'})" +........> ).toArray(); +[ + { + "city/Berlin" : 0.3656319670725433, + "city/Munich" : 1, + "city/Cologne" : 0.7216326530612246, + "village/Rosenheim" : 0, + "village/Olpe" : 0 + } +] +``` +
+ +!SUBSECTION GRAPH_ABSOLUTE_BETWEENNESS + + + +
+`GRAPH_ABSOLUTE_BETWEENNESS (graphName, vertexExample, options)` +*The GRAPH\_ABSOLUTE\_BETWEENNESS function returns the +[betweenness](http://en.wikipedia.org/wiki/Betweenness_centrality) +of all vertices in the graph. +
+
+* String *graphName* : The name of the graph. +* Object *options* : Optional options, see below: +
+Possible options and there defaults: +* String *direction* : The direction of the edges. +Possible values are *outbound*, *inbound* and *any* (default). +* String *weight* : The name of the attribute of +the edges containing the length. +* Number *defaultWeight* : Only used with the option *weight*. +If an edge does not have the attribute named as defined in option *weight* this default +is used as length. +If no default is supplied the default would be positive Infinity so the path and +hence the eccentricity can not be calculated. +
+@EXAMPLES +
+A route planner example, the absolute betweenness of all locations. +
+ +``` +arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); +arangosh> var g = examples.loadGraph("routeplanner"); +arangosh> db._query("RETURN GRAPH_ABSOLUTE_BETWEENNESS(" +........> +"'routeplanner', {})" +........> ).toArray(); +[ + { + "city/Berlin" : 0.6666666666666666, + "city/Cologne" : 0.6666666666666666, + "city/Munich" : 0.6666666666666666, + "village/Olpe" : 0, + "village/Rosenheim" : 0 + } +] +``` +
+A route planner example, the absolute closeness of all locations. +This considers the actual distances. +
+ +``` +arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); +arangosh> var g = examples.loadGraph("routeplanner"); +arangosh> db._query("RETURN GRAPH_ABSOLUTE_BETWEENNESS(" +........> +"'routeplanner', {weight : 'distance'})" +........> ).toArray(); +[ + { + "city/Berlin" : 0, + "city/Munich" : 6, + "city/Cologne" : 0, + "village/Olpe" : 2, + "village/Rosenheim" : 0 + } +] +``` +
+A route planner example, the absolute closeness of all cities regarding only +outbound pathes. +
+ +``` +arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); +arangosh> var g = examples.loadGraph("routeplanner"); +arangosh> db._query("RETURN GRAPH_ABSOLUTE_BETWEENNESS(" +........> + "'routeplanner', {direction : 'outbound', weight : 'distance'})" +........> ).toArray(); +[ + { + "city/Berlin" : 0, + "city/Munich" : 1, + "city/Cologne" : 0, + "village/Rosenheim" : 0, + "village/Olpe" : 0 + } +] +``` +
+ +!SUBSECTION GRAPH_BETWEENNESS + + + +
+`GRAPH_BETWEENNESS (graphName, options)` +*The GRAPH\_BETWEENNESS function returns the +[betweenness](http://en.wikipedia.org/wiki/Betweenness_centrality) +of graphs vertices. +
+* String *graphName* : The name of the graph. +* Object *options* : Optional options, see below: +
+Possible options and there defaults: +* String *direction* : The direction of the edges. +Possible values are *outbound*, *inbound* and *any* (default). +* String *weight* : The name of the attribute of +the edges containing the length. +* Number *defaultWeight* : Only used with the option *weight*. +If an edge does not have the attribute named as defined in option *weight* this default +is used as length. +If no default is supplied the default would be positive Infinity so the path and +hence the eccentricity can not be calculated. +
+@EXAMPLES +
+A route planner example, the betweenness of all locations. +
+ +``` +arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); +arangosh> var g = examples.loadGraph("routeplanner"); +arangosh> db._query("RETURN GRAPH_BETWEENNESS(" +........> +"'routeplanner')" +........> ).toArray(); +[ + { + "city/Munich" : 1, + "city/Cologne" : 1, + "city/Berlin" : 1, + "village/Olpe" : 0, + "village/Rosenheim" : 0 + } +] +``` +
+A route planner example, the closeness of all locations. +This considers the actual distances. +
+ +``` +arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); +arangosh> var g = examples.loadGraph("routeplanner"); +arangosh> db._query("RETURN GRAPH_BETWEENNESS(" +........> +"'routeplanner', {weight : 'distance'})" +........> ).toArray(); +[ + { + "city/Berlin" : 0, + "city/Cologne" : 0, + "village/Olpe" : 0.3333333333333333, + "city/Munich" : 1, + "village/Rosenheim" : 0 + } +] +``` +
+A route planner example, the closeness of all cities regarding only +outbound pathes. +
+ +``` +arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); +arangosh> var g = examples.loadGraph("routeplanner"); +arangosh> db._query("RETURN GRAPH_BETWEENNESS(" +........> + "'routeplanner', {direction : 'outbound', weight : 'distance'})" +........> ).toArray(); +[ + { + "city/Berlin" : 0, + "city/Munich" : 1, + "city/Cologne" : 0, + "village/Rosenheim" : 0, + "village/Olpe" : 0 + } +] +``` +
+ +!SUBSECTION GRAPH_RADIUS + + + +
+`GRAPH_RADIUS (graphName, options)` +*The GRAPH\_RADIUS function returns the +[radius](http://en.wikipedia.org/wiki/Eccentricity_%28graph_theory%29) +of a graph. +
+* String *graphName* : The name of the graph. +* Object *options* : Optional options, see below: +
+Possible options and there defaults: +* String *direction* : The direction of the edges. +Possible values are *outbound*, *inbound* and *any* (default). +* String *algorithm* : The algorithm to calculate +the shortest paths. +* String *weight* : The name of the attribute of +the edges containing the length. +* Number *defaultWeight* : Only used with the option *weight*. +If an edge does not have the attribute named as defined in option *weight* this default +is used as length. +If no default is supplied the default would be positive Infinity so the path and +hence the eccentricity can not be calculated. +
+@EXAMPLES +
+A route planner example, the radius of the graph. +
+ +``` +arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); +arangosh> var g = examples.loadGraph("routeplanner"); +arangosh> db._query("RETURN GRAPH_RADIUS(" +........> +"'routeplanner')" +........> ).toArray(); +[ + 1 +] +``` +
+A route planner example, the radius of the graph. +This considers the actual distances. +
+ +``` +arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); +arangosh> var g = examples.loadGraph("routeplanner"); +arangosh> db._query("RETURN GRAPH_RADIUS(" +........> +"'routeplanner', {weight : 'distance'})" +........> ).toArray(); +[ + 650 +] +``` +
+A route planner example, the cradius of the graph regarding only +outbound pathes. +
+ +``` +arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); +arangosh> var g = examples.loadGraph("routeplanner"); +arangosh> db._query("RETURN GRAPH_RADIUS(" +........> + "'routeplanner', {direction : 'outbound', weight : 'distance'})" +........> ).toArray(); +[ + 650 +] +``` +
+ +!SUBSECTION GRAPH_DIAMETER + + + +
+`GRAPH_DIAMETER (graphName, options)` +*The GRAPH\_DIAMETER function returns the +[diameter](http://en.wikipedia.org/wiki/Eccentricity_%28graph_theory%29) +of a graph. +
+* String *graphName* : The name of the graph. +* Object *options* : Optional options, see below: +
+Possible options and there defaults: +* String *direction* : The direction of the edges. +Possible values are *outbound*, *inbound* and *any* (default). +* String *algorithm* : The algorithm to calculate +the shortest paths. +* String *weight* : The name of the attribute of +the edges containing the length. +* Number *defaultWeight* : Only used with the option *weight*. +If an edge does not have the attribute named as defined in option *weight* this default +is used as length. +If no default is supplied the default would be positive Infinity so the path and +hence the eccentricity can not be calculated. +
+@EXAMPLES +
+A route planner example, the diameter of the graph. +
+ +``` +arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); +arangosh> var g = examples.loadGraph("routeplanner"); +arangosh> db._query("RETURN GRAPH_DIAMETER(" +........> +"'routeplanner')" +........> ).toArray(); +[ + 2 +] +``` +
+A route planner example, tthe diameter of the graph. +This considers the actual distances. +
+ +``` +arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); +arangosh> var g = examples.loadGraph("routeplanner"); +arangosh> db._query("RETURN GRAPH_DIAMETER(" +........> +"'routeplanner', {weight : 'distance'})" +........> ).toArray(); +[ + 800 +] +``` +
+A route planner example, the diameter of the graph regarding only +outbound pathes. +
+ +``` +arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); +arangosh> var g = examples.loadGraph("routeplanner"); +arangosh> db._query("RETURN GRAPH_DIAMETER(" +........> + "'routeplanner', {direction : 'outbound', weight : 'distance'})" +........> ).toArray(); +[ + 850 +] +``` +
+ + + diff --git a/js/server/modules/org/arangodb/ahuacatl.js b/js/server/modules/org/arangodb/ahuacatl.js index b2d2143114..043d2d2a39 100644 --- a/js/server/modules/org/arangodb/ahuacatl.js +++ b/js/server/modules/org/arangodb/ahuacatl.js @@ -4970,7 +4970,7 @@ function IS_EXAMPLE_SET (example) { /// @startDocuBlock JSF_ahuacatl_general_graph_shortest_paths /// /// `GRAPH_SHORTEST_PATH (graphName, startVertexExample, endVertexExample, options)` -/// *The GRAPH\_SHORTEST\_PATH function returns all paths of a graph.* +/// *The GRAPH\_SHORTEST\_PATH function returns all shortest paths of a graph.* /// /// This function determines all shortest paths in a graph identified by *graphName*. /// The function accepts an id, an example, a list of examples @@ -4978,7 +4978,7 @@ function IS_EXAMPLE_SET (example) { /// start and end vertex. If one wants to calls this function to receive nearly all /// shortest paths for a graph the /// option *algorithm* should be set to *Floyd-Warshall* to increase performance. -/// If no algorithm is given in the options the function chooses the appropriate +/// If no algorithm is provided in the options the function chooses the appropriate /// one (either *Floyd-Warshall* or *Dijsktra*) according to its parameters. /// The length of a path is by default the amount of edges from one start vertex to /// an end vertex. The option weight allows the user to define an edge attribute @@ -5224,6 +5224,7 @@ function GRAPH_TRAVERSAL_TREE (vertexCollection, /// *The GRAPH\_DISTANCE\_TO function returns all paths and there distance within a graph.* /// /// This function is a wrapper of [GRAPH\_SHORTEST\_PATH](#SUBSECTION GRAPH_SHORTEST_PATH). +/// It does not return the actual path but only the distance between two vertices. /// //////////////////////////////////////////////////////////////////////////////// function GENERAL_GRAPH_DISTANCE_TO (graphName, @@ -5529,7 +5530,7 @@ function GENERAL_GRAPH_NEIGHBORS (graphName, } //////////////////////////////////////////////////////////////////////////////// -/// @startDocuBlock JSF_ahuacatl_general_graph_neighbors +/// @startDocuBlock JSF_ahuacatl_general_graph_edges /// /// `GRAPH_EDGES (graphName, vertexExample, options)` /// *The GRAPH\_EDGES function returns all edges of vertices.* @@ -5759,28 +5760,27 @@ function TRANSFER_GENERAL_GRAPH_NEIGHBORS_RESULT (result) { /// /// @EXAMPLES /// -/// A route planner example, all neighbors of locations with a distance of -/// either 700 or 600.: +/// A route planner example, all common neighbors of capitals. /// /// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphVertices1} /// ~ var db = require("internal").db; /// var examples = require("org/arangodb/graph-examples/example-graph.js"); /// var g = examples.loadGraph("routeplanner"); /// |db._query("FOR e IN GRAPH_COMMON_NEIGHBORS(" -/// |+"'routeplanner', {}) RETURN e" +/// |+"'routeplanner', {isCapital : true}, {isCapital : true}) RETURN e" /// ).toArray(); /// @END_EXAMPLE_ARANGOSH_OUTPUT /// -/// A route planner example, all outbound neighbors of munich with a maximal -/// depth of 2 : +/// A route planner example, all common outbound neighbors of munich with any other location +/// which have a maximal depth of 2 : /// /// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphVertices2} /// ~ var db = require("internal").db; /// var examples = require("org/arangodb/graph-examples/example-graph.js"); /// var g = examples.loadGraph("routeplanner"); /// |db._query("FOR e IN GRAPH_COMMON_NEIGHBORS(" -/// |+"'routeplanner', {}, {direction : 'any', vertexCollectionRestriction" + -/// |" : 'city'}) RETURN e" +/// |+"'routeplanner', 'city/Munich', {}, {direction : 'outbound', maxDepth : 2}, "+ +/// | "{direction : 'outbound', maxDepth : 2}) RETURN e" /// ).toArray(); /// @END_EXAMPLE_ARANGOSH_OUTPUT /// @@ -5989,7 +5989,7 @@ function GENERAL_GRAPH_COMMON_PROPERTIES ( /// /// `GRAPH_ABSOLUTE_ECCENTRICITY (graphName, vertexExample, options)` /// *The GRAPH\_ABSOLUTE\_ECCENTRICITY function returns the -/// [eccentricity](http://en.wikipedia.org/wiki/Distance_(graph_theory)) +/// [eccentricity](http://en.wikipedia.org/wiki/Distance_%28graph_theory%29) /// of the vertices defined by the examples. /// /// The function accepts an id, an example, a list of examples or even an empty @@ -6100,7 +6100,7 @@ function GENERAL_GRAPH_ABSOLUTE_ECCENTRICITY (graphName, vertexExample, options) /// /// `GRAPH_ECCENTRICITY (graphName, options)` /// *The GRAPH\_ECCENTRICITY function returns the normalized -/// [eccentricity](http://en.wikipedia.org/wiki/Distance_(graph_theory)) +/// [eccentricity](http://en.wikipedia.org/wiki/Distance_%28graph_theory%29) /// of the graphs vertices /// /// * String *graphName* : The name of the graph. @@ -6577,7 +6577,7 @@ function GENERAL_GRAPH_BETWEENNESS (graphName, options) { /// /// `GRAPH_RADIUS (graphName, options)` /// *The GRAPH\_RADIUS function returns the -/// [radius](http://en.wikipedia.org/wiki/Eccentricity_(graph_theory)) +/// [radius](http://en.wikipedia.org/wiki/Eccentricity_%28graph_theory%29) /// of a graph. /// /// * String *graphName* : The name of the graph. @@ -6669,7 +6669,7 @@ function GENERAL_GRAPH_RADIUS (graphName, options) { /// /// `GRAPH_DIAMETER (graphName, options)` /// *The GRAPH\_DIAMETER function returns the -/// [diameter](http://en.wikipedia.org/wiki/Eccentricity_(graph_theory)) +/// [diameter](http://en.wikipedia.org/wiki/Eccentricity_%28graph_theory%29) /// of a graph. /// /// * String *graphName* : The name of the graph.