From 0eff0753e86cf865bf384fd2a0fcefc371f058cf Mon Sep 17 00:00:00 2001 From: Michael Hackstein Date: Fri, 20 Jun 2014 14:57:04 +0200 Subject: [PATCH] Started improving the layout of FluentAQL Documentation in general graph module --- .../General-Graphs/FluentAQLInterface.mdpp | 4 + .../js/modules/org/arangodb/general-graph.js | 811 ++++++++++++++++-- .../modules/org/arangodb/general-graph.js | 164 ++-- 3 files changed, 820 insertions(+), 159 deletions(-) diff --git a/Documentation/Books/Users/General-Graphs/FluentAQLInterface.mdpp b/Documentation/Books/Users/General-Graphs/FluentAQLInterface.mdpp index f78258c28b..332cac605d 100644 --- a/Documentation/Books/Users/General-Graphs/FluentAQLInterface.mdpp +++ b/Documentation/Books/Users/General-Graphs/FluentAQLInterface.mdpp @@ -8,6 +8,10 @@ As an example you can start with a set of vertices, select their direct neighbor The result of this query will be the set of outgoing edges. For each part of the query it is possible to further refine the resulting set of elements by giving examples for them. +!SECTION Definition of examples + +@startDocuBlock JSF_general_graph_example_description + !SECTION Starting Points This section describes the entry points for the fluent interface. diff --git a/js/apps/system/aardvark/frontend/js/modules/org/arangodb/general-graph.js b/js/apps/system/aardvark/frontend/js/modules/org/arangodb/general-graph.js index 3b74bfe7ea..8e183d32c8 100644 --- a/js/apps/system/aardvark/frontend/js/modules/org/arangodb/general-graph.js +++ b/js/apps/system/aardvark/frontend/js/modules/org/arangodb/general-graph.js @@ -178,6 +178,22 @@ var wrapCollection = function(col) { return wrapper; }; +//////////////////////////////////////////////////////////////////////////////// +/// @startDocuBlock JSF_general_graph_example_description +/// +/// For many of the following functions *examples* can be passed in as a parameter. +/// *Examples* are used to filter the result set for objects that match the conditions. +/// These *examples* can have the following values: +/// +/// * Empty, there is no matching executed all found results are valid. +/// * A string, only the result having this value as it's *_id* is returned. +/// * An example object, defining a set of attributes. +/// Only results having these attributes are matched. +/// * A list containing example objects and/or strings. +/// All results matching at least one of the elements in the list are returned. +/// +/// @endDocuBlock +//////////////////////////////////////////////////////////////////////////////// var transformExample = function(example) { if (example === undefined) { @@ -396,16 +412,16 @@ AQLGenerator.prototype._edges = function(edgeExample, options) { //////////////////////////////////////////////////////////////////////////////// /// @startDocuBlock JSF_general_graph_fluent_aql_edges -/// Select all edges for the vertices selected before. +/// `graph_query.edges(examples)` +/// *Select all edges for the vertices selected before.* /// -/// `graph-query.edges(examples)` /// /// Creates an AQL statement to select all edges for each of the vertices selected /// in the step before. /// This will include *inbound* as well as *outbound* edges. /// The resulting set of edges can be filtered by defining one or more *examples*. /// -/// *examples* can have the following values: +/// * *examples*: See #definition_of_examples /// /// * Empty, there is no matching executed all edges are valid. /// * A string, only the edge having this value as it's id is returned. @@ -453,9 +469,9 @@ AQLGenerator.prototype.edges = function(example) { //////////////////////////////////////////////////////////////////////////////// /// @startDocuBlock JSF_general_graph_fluent_aql_outEdges -/// Select all outbound edges for the vertices selected before. +/// `graph_query.outEdges(examples)` +/// *Select all outbound edges for the vertices selected before.* /// -/// `graph-query.outEdges(examples)` /// /// Creates an AQL statement to select all *outbound* edges for each of the vertices selected /// in the step before. @@ -887,6 +903,19 @@ AQLGenerator.prototype.pathEdges = function() { /// Only vertices having these attributes are matched. /// * A list containing example objects and/or strings. /// All vertices matching at least one of the elements in the list are returned. +/// 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|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* /// @@ -1440,7 +1469,7 @@ var _list = function() { /// The list of edge definitions of a graph can be managed by the graph module itself. /// This function is the entry point for the management and will return the correct list. /// -/// @EXAMPLES +/// *Examples* /// /// /// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphEdgeDefinitions} @@ -1472,7 +1501,7 @@ var _edgeDefinitions = function () { /// In order to add more edge definitions to the graph before creating /// this function can be used to add more definitions to the initial list. /// -/// @EXAMPLES +/// *Examples* /// /// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphEdgeDefinitionsExtend} /// var graph = require("org/arangodb/general-graph"); @@ -1520,7 +1549,7 @@ var _extendEdgeDefinitions = function (edgeDefinition) { /// * *edge-definitions*: array - list of edge definition objects /// * *orphan-collections*: array - list of additonal vertex collection names /// -/// @EXAMPLES +/// *Examples* /// /// Create an empty graph, edge definitions can be added at runtime: /// @@ -1534,7 +1563,7 @@ var _extendEdgeDefinitions = function (edgeDefinition) { /// /// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphCreateGraph2} /// var graph = require("org/arangodb/general-graph"); -/// g = graph._create("mygraph", [graph._undirectedRelationDefinition("relation", ["male", "female"])], ["sessions"]); +/// g = graph._create("mygraph", [graph._undirectedRelation("relation", ["male", "female"])], ["sessions"]); /// ~ graph._drop("mygraph"); /// @END_EXAMPLE_ARANGOSH_OUTPUT /// @@ -2059,7 +2088,7 @@ var Graph = function(graphName, edgeDefinitions, vertexCollections, edgeCollecti /// /// * *graph-name*: string - unique identifier of the graph /// -/// @EXAMPLES +/// *Examples* /// /// Load a graph: /// @@ -2162,7 +2191,7 @@ var checkIfMayBeDropped = function(colName, graphName, graphs) { /// * *graphName*: string - unique identifier of the graph /// * *dropCollections*: boolean (optional) - define if collections should be dropped (default: false) /// -/// @EXAMPLES +/// *Examples* /// /// Drop a graph: /// @@ -2520,22 +2549,18 @@ Graph.prototype._getVertexCollectionByName = function(name) { //////////////////////////////////////////////////////////////////////////////// -/// @startDocuBlock JSF_general_graph_common_neighbors +/// @startDocuBlock JSF_general_graph_neighbors /// -/// `general_graph._listCommonNeighbors(vertex1Example, vertex2Examples, -/// optionsVertex1, optionsVertex2)` -/// *The general_graph._listCommonNeighbors function returns all common neighbors -/// of the vertices defined by the examples.* +/// `general_graph._neighbors(vertexExample, options)` +/// *The general_graph._neighbors function returns all neighbors +/// of the vertices defined by the example.* /// /// The function accepts an id, an example, a list of examples or even an empty -/// example as parameter for vertex1Example and vertex2Example. +/// example as parameter for vertexExample. /// -/// * String|Object|Array *vertex1Example* : An example for the desired +/// * String|Object|Array *vertexExample* : An example for the desired /// vertices (see below). -/// * String|Object|Array *vertex2Example* : An example for the desired -/// vertices (see below). -/// * Object *optionsVertex1* : Optional options, see below: -/// * Object *optionsVertex2* : Optional options, see below: +/// * Object *options* : Optional options, see below: /// /// Possible options and there defaults: /// * String *direction* : The direction of the @@ -2560,7 +2585,64 @@ Graph.prototype._getVertexCollectionByName = function(name) { /// * [{*key1* : *value1*}, {*key2* : *value2*}] : Returns the vertices that /// match one of the examples. /// -/// @EXAMPLES +/// *Examples* +/// +/// A route planner example, all neighbors of capitals. +/// +/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphModuleNeighbors1} +/// ~ var db = require("internal").db; +/// var examples = require("org/arangodb/graph-examples/example-graph.js"); +/// var g = examples.loadGraph("routeplanner"); +/// g._neighbors({isCapital : true}); +/// @END_EXAMPLE_ARANGOSH_OUTPUT +/// +/// A route planner example, all outbound neighbors of Hamburg. +/// +/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphModuleNeighbors2} +/// ~ var db = require("internal").db; +/// var examples = require("org/arangodb/graph-examples/example-graph.js"); +/// var g = examples.loadGraph("routeplanner"); +/// g._neighbors('germanCity/Hamburg', {direction : 'outbound', maxDepth : 2}); +/// @END_EXAMPLE_ARANGOSH_OUTPUT +/// +/// @endDocuBlock +// +//////////////////////////////////////////////////////////////////////////////// +Graph.prototype._neighbors = function(vertexExample, options) { + var AQLStmt = new AQLGenerator(this); + // If no direction is specified all edges are duplicated. + // => For initial requests a direction has to be set + if (!options) { + options = {}; + } + return AQLStmt.vertices(vertexExample).neighbors(options.neighborExamples, options) + .toArray(); +}; + + +//////////////////////////////////////////////////////////////////////////////// +/// @startDocuBlock JSF_general_graph_common_neighbors +/// +/// `general_graph._commonNeighbors(vertex1Example, vertex2Examples, +/// optionsVertex1, optionsVertex2)` +/// *The general_graph._commonNeighbors function returns all common neighbors +/// 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 vertex1Example and vertex2Example. +/// +/// This function returns the intersection of *general_graph._neighbors(vertex1Example, optionsVertex1)* +/// and *general_graph._neighbors(vertex2Example, optionsVertex2)*. +/// For parameter documentation read the documentation *general_graph._neighbors*. +/// +/// 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 common neighbors of capitals. /// @@ -2568,25 +2650,28 @@ Graph.prototype._getVertexCollectionByName = function(name) { /// ~ var db = require("internal").db; /// var examples = require("org/arangodb/graph-examples/example-graph.js"); /// var g = examples.loadGraph("routeplanner"); -/// g._listCommonNeighbors({isCapital : true}, {isCapital : true}); +/// g._commonNeighbors({isCapital : true}, {isCapital : true}); /// @END_EXAMPLE_ARANGOSH_OUTPUT /// -/// A route planner example, all common outbound neighbors of munich with any other location +/// A route planner example, all common outbound neighbors of Hamburg with any other location /// which have a maximal depth of 2 : /// /// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphModuleCommonNeighbors2} /// ~ var db = require("internal").db; -/// var examples = require("org/arangodb/graph-examples/example-graph.js"); -/// var g = examples.loadGraph("routeplanner"); -/// |g._listCommonNeighbors('city/Munich', {}, {direction : 'outbound', maxDepth : 2}, -/// {direction : 'outbound', maxDepth : 2}); +/// var examples = require("org/arangodb/graph-examples/example-graph.js"); +/// var g = examples.loadGraph("routeplanner"); +/// | g._commonNeighbors( +/// | 'germanCity/Hamburg', +/// | {}, +/// | {direction : 'outbound', maxDepth : 2}, +/// {direction : 'outbound', maxDepth : 2}); /// @END_EXAMPLE_ARANGOSH_OUTPUT /// /// @endDocuBlock // //////////////////////////////////////////////////////////////////////////////// -Graph.prototype._listCommonNeighbors = function(vertex1Example, vertex2Example, optionsVertex1, optionsVertex2) { +Graph.prototype._commonNeighbors = function(vertex1Example, vertex2Example, optionsVertex1, optionsVertex2) { var ex1 = transformExample(vertex1Example); var ex2 = transformExample(vertex2Example); @@ -2610,11 +2695,11 @@ Graph.prototype._listCommonNeighbors = function(vertex1Example, vertex2Example, }; //////////////////////////////////////////////////////////////////////////////// -/// @startDocuBlock JSF_general_graph_amount_common_neighbors +/// @startDocuBlock JSF_general_graph_count_common_neighbors /// -/// `general_graph._amountCommonNeighbors(vertex1Example, vertex2Examples, +/// `general_graph._countCommonNeighbors(vertex1Example, vertex2Examples, /// optionsVertex1, optionsVertex2)` -/// *The general_graph._amountCommonNeighbors function returns the amount of +/// *The general_graph._countCommonNeighbors function returns the amount of /// common neighbors of the vertices defined by the examples.* /// /// The function accepts an id, an example, a list of examples or even an empty @@ -2650,7 +2735,7 @@ Graph.prototype._listCommonNeighbors = function(vertex1Example, vertex2Example, /// * [{*key1* : *value1*}, {*key2* : *value2*}] : Returns the vertices that /// match one of the examples. /// -/// @EXAMPLES +/// *Examples* /// /// A route planner example, all common neighbors of capitals. /// @@ -2658,17 +2743,17 @@ Graph.prototype._listCommonNeighbors = function(vertex1Example, vertex2Example, /// ~ var db = require("internal").db; /// var examples = require("org/arangodb/graph-examples/example-graph.js"); /// var g = examples.loadGraph("routeplanner"); -/// g._amountCommonNeighbors({isCapital : true}, {isCapital : true}); +/// g._countCommonNeighbors({isCapital : true}, {isCapital : true}); /// @END_EXAMPLE_ARANGOSH_OUTPUT /// -/// A route planner example, all common outbound neighbors of munich with any other location +/// A route planner example, all common outbound neighbors of Hamburg with any other location /// which have a maximal depth of 2 : /// /// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphModuleCommonNeighborsAmount2} /// ~ var db = require("internal").db; /// var examples = require("org/arangodb/graph-examples/example-graph.js"); /// var g = examples.loadGraph("routeplanner"); -/// |g._amountCommonNeighbors('city/Munich', {}, {direction : 'outbound', maxDepth : 2}, +/// |g._countCommonNeighbors('germanCity/Hamburg', {}, {direction : 'outbound', maxDepth : 2}, /// {direction : 'outbound', maxDepth : 2}); /// @END_EXAMPLE_ARANGOSH_OUTPUT /// @@ -2676,7 +2761,7 @@ Graph.prototype._listCommonNeighbors = function(vertex1Example, vertex2Example, // //////////////////////////////////////////////////////////////////////////////// -Graph.prototype._amountCommonNeighbors = function(vertex1Example, vertex2Example, optionsVertex1, optionsVertex2) { +Graph.prototype._countCommonNeighbors = function(vertex1Example, vertex2Example, optionsVertex1, optionsVertex2) { var ex1 = transformExample(vertex1Example); var ex2 = transformExample(vertex2Example); var query = "FOR e" @@ -2717,9 +2802,9 @@ Graph.prototype._amountCommonNeighbors = function(vertex1Example, vertex2Example //////////////////////////////////////////////////////////////////////////////// /// @startDocuBlock JSF_general_graph_common_properties /// -/// `general_graph._listCommonProperties(vertex1Example, vertex2Examples, +/// `general_graph._commonProperties(vertex1Example, vertex2Examples, /// options)` -/// *The general_graph._listCommonProperties function returns the vertices of +/// *The general_graph._commonProperties function returns the vertices of /// the graph that share common properties.* /// /// The function accepts an id, an example, a list of examples or even an empty @@ -2746,7 +2831,7 @@ Graph.prototype._amountCommonNeighbors = function(vertex1Example, vertex2Example /// * [{*key1* : *value1*}, {*key2* : *value2*}] : Returns the vertices that /// match one of the examples. /// -/// @EXAMPLES +/// *Examples* /// /// A route planner example, all locations with the same properties: /// @@ -2754,7 +2839,7 @@ Graph.prototype._amountCommonNeighbors = function(vertex1Example, vertex2Example /// ~ var db = require("internal").db; /// var examples = require("org/arangodb/graph-examples/example-graph.js"); /// var g = examples.loadGraph("routeplanner"); -/// g._listCommonProperties({}, {}); +/// g._commonProperties({}, {}); /// @END_EXAMPLE_ARANGOSH_OUTPUT /// /// A route planner example, all cities which share same properties except for population. @@ -2763,15 +2848,14 @@ Graph.prototype._amountCommonNeighbors = function(vertex1Example, vertex2Example /// ~ var db = require("internal").db; /// var examples = require("org/arangodb/graph-examples/example-graph.js"); /// var g = examples.loadGraph("routeplanner"); -/// |g._listCommonProperties({}, {}, {vertex1CollectionRestriction : 'city', -/// vertex2CollectionRestriction : 'city' ,ignoreProperties: 'population'}); +/// g._commonProperties({}, {}, {ignoreProperties: 'population'}); /// @END_EXAMPLE_ARANGOSH_OUTPUT /// /// @endDocuBlock // //////////////////////////////////////////////////////////////////////////////// -Graph.prototype._listCommonProperties = function(vertex1Example, vertex2Example, options) { +Graph.prototype._commonProperties = function(vertex1Example, vertex2Example, options) { var ex1 = transformExample(vertex1Example); var ex2 = transformExample(vertex2Example); @@ -2793,11 +2877,11 @@ Graph.prototype._listCommonProperties = function(vertex1Example, vertex2Example, }; //////////////////////////////////////////////////////////////////////////////// -/// @startDocuBlock JSF_general_graph_amount_common_properties +/// @startDocuBlock JSF_general_graph_count_common_properties /// -/// `general_graph._amountCommonProperties(vertex1Example, vertex2Examples, +/// `general_graph._countCommonProperties(vertex1Example, vertex2Examples, /// options)` -/// *The general_graph._amountCommonProperties function returns the amount of vertices of +/// *The general_graph._countCommonProperties function returns the amount of vertices of /// the graph that share common properties.* /// /// The function accepts an id, an example, a list of examples or even an empty @@ -2824,7 +2908,7 @@ Graph.prototype._listCommonProperties = function(vertex1Example, vertex2Example, /// * [{*key1* : *value1*}, {*key2* : *value2*}] : Returns the vertices that /// match one of the examples. /// -/// @EXAMPLES +/// *Examples* /// /// A route planner example, all locations with the same properties: /// @@ -2832,24 +2916,24 @@ Graph.prototype._listCommonProperties = function(vertex1Example, vertex2Example, /// ~ var db = require("internal").db; /// var examples = require("org/arangodb/graph-examples/example-graph.js"); /// var g = examples.loadGraph("routeplanner"); -/// g._amountCommonProperties({}, {}); +/// g._countCommonProperties({}, {}); /// @END_EXAMPLE_ARANGOSH_OUTPUT /// -/// A route planner example, all cities which share same properties except for population. +/// A route planner example, all german cities which share same properties except for population. /// /// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphModuleAmountProperties2} /// ~ var db = require("internal").db; /// var examples = require("org/arangodb/graph-examples/example-graph.js"); /// var g = examples.loadGraph("routeplanner"); -/// |g._amountCommonProperties({}, {}, {vertex1CollectionRestriction : 'city', -/// vertex2CollectionRestriction : 'city' ,ignoreProperties: 'population'}); +/// |g._countCommonProperties({}, {}, {vertex1CollectionRestriction : 'germanCity', +/// vertex2CollectionRestriction : 'germanCity' ,ignoreProperties: 'population'}); /// @END_EXAMPLE_ARANGOSH_OUTPUT /// /// @endDocuBlock // //////////////////////////////////////////////////////////////////////////////// -Graph.prototype._amountCommonProperties = function(vertex1Example, vertex2Example, options) { +Graph.prototype._countCommonProperties = function(vertex1Example, vertex2Example, options) { var ex1 = transformExample(vertex1Example); var ex2 = transformExample(vertex2Example); var query = "FOR e" @@ -2875,6 +2959,625 @@ Graph.prototype._amountCommonProperties = function(vertex1Example, vertex2Exampl }; +//////////////////////////////////////////////////////////////////////////////// +/// @startDocuBlock JSF_general_graph_absolute_eccentricity +/// +/// `general_graph._absoluteEccentricity(vertexExample, options)` +/// *The _absoluteEccentricity 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|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. +/// +/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphModuleAbsEccentricity1} +/// ~ var db = require("internal").db; +/// var examples = require("org/arangodb/graph-examples/example-graph.js"); +/// var g = examples.loadGraph("routeplanner"); +/// |db._query("RETURN GRAPH_ABSOLUTE_ECCENTRICITY(" +/// |+"'routeplanner', {})" +/// ).toArray(); +/// @END_EXAMPLE_ARANGOSH_OUTPUT +/// +/// A route planner example, the absolute eccentricity of all locations. +/// This considers the actual distances. +/// +/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphModuleAbsEccentricity2} +/// ~ var db = require("internal").db; +/// var examples = require("org/arangodb/graph-examples/example-graph.js"); +/// var g = examples.loadGraph("routeplanner"); +/// g._absoluteEccentricity({}, {weight : 'distance'}); +/// @END_EXAMPLE_ARANGOSH_OUTPUT +/// +/// A route planner example, the absolute eccentricity of all cities regarding only +/// outbound paths. +/// +/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphModuleAbsEccentricity3} +/// ~ var db = require("internal").db; +/// var examples = require("org/arangodb/graph-examples/example-graph.js"); +/// var g = examples.loadGraph("routeplanner"); +/// |g._absoluteEccentricity({}, {startVertexCollectionRestriction : 'city', +/// direction : 'outbound', weight : 'distance'}); +/// @END_EXAMPLE_ARANGOSH_OUTPUT +/// +/// @endDocuBlock +// +//////////////////////////////////////////////////////////////////////////////// +Graph.prototype._absoluteEccentricity = function(vertexExample, options) { + var ex1 = transformExample(vertexExample); + var query = "RETURN" + + " GRAPH_ABSOLUTE_ECCENTRICITY(@graphName" + + ',@ex1' + + ',@options' + + ')'; + options = options || {}; + var bindVars = { + "graphName": this.__name, + "options": options, + "ex1": ex1 + }; + var result = db._query(query, bindVars).toArray(), returnHash = []; + return result; +}; + + +//////////////////////////////////////////////////////////////////////////////// +/// @startDocuBlock JSF_general_graph_eccentricity +/// +/// `general_graph._eccentricity(vertexExample, options)` +/// *The _eccentricity function returns the normalized* +/// [eccentricity](http://en.wikipedia.org/wiki/Distance_%28graph_theory%29) +/// *of the vertices defined by the examples.* +/// +/// * 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. +/// +/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphModuleEccentricity2} +/// ~ var db = require("internal").db; +/// var examples = require("org/arangodb/graph-examples/example-graph.js"); +/// var g = examples.loadGraph("routeplanner"); +/// g._eccentricity(); +/// @END_EXAMPLE_ARANGOSH_OUTPUT +/// +/// A route planner example, the weighted eccentricity. +/// +/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphModuleEccentricity3} +/// ~ var db = require("internal").db; +/// var examples = require("org/arangodb/graph-examples/example-graph.js"); +/// var g = examples.loadGraph("routeplanner"); +/// g._eccentricity({weight : 'distance'}); +/// @END_EXAMPLE_ARANGOSH_OUTPUT +/// +/// @endDocuBlock +// +//////////////////////////////////////////////////////////////////////////////// +Graph.prototype._eccentricity = function(options) { + var query = "RETURN" + + " GRAPH_ECCENTRICITY(@graphName" + + ',@options' + + ')'; + options = options || {}; + var bindVars = { + "graphName": this.__name, + "options": options + }; + var result = db._query(query, bindVars).toArray(), returnHash = []; + return result; +}; + + + +//////////////////////////////////////////////////////////////////////////////// +/// @startDocuBlock JSF_general_graph_absolute_closeness +/// +/// `general_graph._absoluteCloseness(vertexExample, options)` +/// *The _absoluteCloseness 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|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. +/// +/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphModuleAbsCloseness1} +/// ~ var db = require("internal").db; +/// var examples = require("org/arangodb/graph-examples/example-graph.js"); +/// var g = examples.loadGraph("routeplanner"); +/// g._absoluteCloseness({}); +/// @END_EXAMPLE_ARANGOSH_OUTPUT +/// +/// A route planner example, the absolute closeness of all locations. +/// This considers the actual distances. +/// +/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphModuleAbsCloseness2} +/// ~ var db = require("internal").db; +/// var examples = require("org/arangodb/graph-examples/example-graph.js"); +/// var g = examples.loadGraph("routeplanner"); +/// g._absoluteCloseness({}, {weight : 'distance'}); +/// @END_EXAMPLE_ARANGOSH_OUTPUT +/// +/// A route planner example, the absolute closeness of all germanCities regarding only +/// outbound paths. +/// +/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphModuleAbsCloseness3} +/// ~ var db = require("internal").db; +/// var examples = require("org/arangodb/graph-examples/example-graph.js"); +/// var g = examples.loadGraph("routeplanner"); +/// |g._absoluteCloseness({}, {startVertexCollectionRestriction : 'germanCity', +/// direction : 'outbound', weight : 'distance'}); +/// @END_EXAMPLE_ARANGOSH_OUTPUT +/// +/// @endDocuBlock +// +//////////////////////////////////////////////////////////////////////////////// +Graph.prototype._absoluteCloseness = function(vertexExample, options) { + var ex1 = transformExample(vertexExample); + var query = "RETURN" + + " GRAPH_ABSOLUTE_CLOSENESS(@graphName" + + ',@ex1' + + ',@options' + + ')'; + options = options || {}; + var bindVars = { + "graphName": this.__name, + "options": options, + "ex1": ex1 + }; + var result = db._query(query, bindVars).toArray(), returnHash = []; + return result; +}; + +//////////////////////////////////////////////////////////////////////////////// +/// @startDocuBlock JSF_general_graph_closeness +/// +/// `general_graph._closeness(options)` +/// *The _closeness function returns the normalized* +/// [closeness](http://en.wikipedia.org/wiki/Centrality#Closeness_centrality) +/// *of graphs vertices.* +/// +/// * 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 normalized closeness of all locations. +/// +/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphModuleCloseness1} +/// ~ var db = require("internal").db; +/// var examples = require("org/arangodb/graph-examples/example-graph.js"); +/// var g = examples.loadGraph("routeplanner"); +/// g._closeness(); +/// @END_EXAMPLE_ARANGOSH_OUTPUT +/// +/// A route planner example, the closeness of all locations. +/// This considers the actual distances. +/// +/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphModuleCloseness2} +/// ~ var db = require("internal").db; +/// var examples = require("org/arangodb/graph-examples/example-graph.js"); +/// var g = examples.loadGraph("routeplanner"); +/// g._closeness({weight : 'distance'}); +/// @END_EXAMPLE_ARANGOSH_OUTPUT +/// +/// A route planner example, the closeness of all cities regarding only +/// outbound paths. +/// +/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphModuleCloseness3} +/// ~ var db = require("internal").db; +/// var examples = require("org/arangodb/graph-examples/example-graph.js"); +/// var g = examples.loadGraph("routeplanner"); +/// g._closeness({direction : 'outbound', weight : 'distance'}); +/// @END_EXAMPLE_ARANGOSH_OUTPUT +/// +/// @endDocuBlock +// +//////////////////////////////////////////////////////////////////////////////// +Graph.prototype._closeness = function(options) { + var query = "RETURN" + + " GRAPH_CLOSENESS(@graphName" + + ',@options' + + ')'; + options = options || {}; + var bindVars = { + "graphName": this.__name, + "options": options + }; + var result = db._query(query, bindVars).toArray(), returnHash = []; + return result; +}; + + + +//////////////////////////////////////////////////////////////////////////////// +/// @startDocuBlock JSF_general_graph_absolute_betweenness +/// +/// `general_graph._absoluteBetweenness(options)` +/// *The _absoluteBetweenness function returns the* +/// [betweenness](http://en.wikipedia.org/wiki/Betweenness_centrality) +/// *of all vertices in 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 betweenness can not be calculated. +/// +/// @EXAMPLES +/// +/// A route planner example, the absolute betweenness of all locations. +/// +/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphModuleAbsBetweenness1} +/// ~ var db = require("internal").db; +/// var examples = require("org/arangodb/graph-examples/example-graph.js"); +/// var g = examples.loadGraph("routeplanner"); +/// g._absoluteBetweenness({}); +/// @END_EXAMPLE_ARANGOSH_OUTPUT +/// +/// A route planner example, the absolute betweenness of all locations. +/// This considers the actual distances. +/// +/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphModuleAbsBetweenness2} +/// ~ var db = require("internal").db; +/// var examples = require("org/arangodb/graph-examples/example-graph.js"); +/// var g = examples.loadGraph("routeplanner"); +/// g._absoluteBetweenness({weight : 'distance'}); +/// @END_EXAMPLE_ARANGOSH_OUTPUT +/// +/// A route planner example, the absolute closeness of all cities regarding only +/// outbound paths. +/// +/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphModuleAbsBetweenness3} +/// ~ var db = require("internal").db; +/// var examples = require("org/arangodb/graph-examples/example-graph.js"); +/// var g = examples.loadGraph("routeplanner"); +/// g._absoluteBetweenness({direction : 'outbound', weight : 'distance'}); +/// @END_EXAMPLE_ARANGOSH_OUTPUT +/// +/// @endDocuBlock +// +//////////////////////////////////////////////////////////////////////////////// +Graph.prototype._absoluteBetweenness = function(options) { + + var query = "RETURN" + + " GRAPH_ABSOLUTE_BETWEENNESS(@graphName" + + ',@options' + + ')'; + options = options || {}; + var bindVars = { + "graphName": this.__name, + "options": options + }; + var result = db._query(query, bindVars).toArray(), returnHash = []; + return result; +}; + +//////////////////////////////////////////////////////////////////////////////// +/// @startDocuBlock JSF_general_graph_betweenness +/// +/// `general_graph._betweenness(options)` +/// *The _betweenness function returns the* +/// [betweenness](http://en.wikipedia.org/wiki/Betweenness_centrality) +/// *of graphs vertices.* +/// +/// * 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. +/// +/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphModuleBetweenness1} +/// ~ var db = require("internal").db; +/// var examples = require("org/arangodb/graph-examples/example-graph.js"); +/// var g = examples.loadGraph("routeplanner"); +/// g._betweenness(); +/// @END_EXAMPLE_ARANGOSH_OUTPUT +/// +/// A route planner example, the closeness of all locations. +/// This considers the actual distances. +/// +/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphModuleBetweenness2} +/// ~ var db = require("internal").db; +/// var examples = require("org/arangodb/graph-examples/example-graph.js"); +/// var g = examples.loadGraph("routeplanner"); +/// g._betweenness({weight : 'distance'}); +/// @END_EXAMPLE_ARANGOSH_OUTPUT +/// +/// A route planner example, the closeness of all cities regarding only +/// outbound paths. +/// +/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphModuleBetweenness3} +/// ~ var db = require("internal").db; +/// var examples = require("org/arangodb/graph-examples/example-graph.js"); +/// var g = examples.loadGraph("routeplanner"); +/// g._betweenness({direction : 'outbound', weight : 'distance'}); +/// @END_EXAMPLE_ARANGOSH_OUTPUT +/// +/// @endDocuBlock +// +//////////////////////////////////////////////////////////////////////////////// +Graph.prototype._betweenness = function(options) { + + var query = "RETURN" + + " GRAPH_BETWEENNESS(@graphName" + + ',@options' + + ')'; + options = options || {}; + var bindVars = { + "graphName": this.__name, + "options": options + }; + var result = db._query(query, bindVars).toArray(), returnHash = []; + return result; +}; + + + +//////////////////////////////////////////////////////////////////////////////// +/// @startDocuBlock JSF_general_graph_radius +/// +/// `general_graph._radius(options)` +/// *The _radius function returns the* +/// [radius](http://en.wikipedia.org/wiki/Eccentricity_%28graph_theory%29) +/// *of a 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{generalGraphModuleRadius1} +/// ~ var db = require("internal").db; +/// var examples = require("org/arangodb/graph-examples/example-graph.js"); +/// var g = examples.loadGraph("routeplanner"); +/// g._radius(); +/// @END_EXAMPLE_ARANGOSH_OUTPUT +/// +/// A route planner example, the radius of the graph. +/// This considers the actual distances. +/// +/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphModuleRadius2} +/// ~ var db = require("internal").db; +/// var examples = require("org/arangodb/graph-examples/example-graph.js"); +/// var g = examples.loadGraph("routeplanner"); +/// g._radius({weight : 'distance'}); +/// @END_EXAMPLE_ARANGOSH_OUTPUT +/// +/// A route planner example, the radius of the graph regarding only +/// outbound paths. +/// +/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphModuleRadius3} +/// ~ var db = require("internal").db; +/// var examples = require("org/arangodb/graph-examples/example-graph.js"); +/// var g = examples.loadGraph("routeplanner"); +/// g._radius({direction : 'outbound', weight : 'distance'}); +/// @END_EXAMPLE_ARANGOSH_OUTPUT +/// +/// @endDocuBlock +// +//////////////////////////////////////////////////////////////////////////////// +Graph.prototype._radius = function(options) { + + var query = "RETURN" + + " GRAPH_RADIUS(@graphName" + + ',@options' + + ')'; + options = options || {}; + var bindVars = { + "graphName": this.__name, + "options": options + }; + var result = db._query(query, bindVars).toArray(), returnHash = []; + return result; +}; + + + +//////////////////////////////////////////////////////////////////////////////// +/// @startDocuBlock JSF_general_graph_diameter +/// +/// `general_graph._diameter(graphName, options)` +/// *The _diameter function returns the* +/// [diameter](http://en.wikipedia.org/wiki/Eccentricity_%28graph_theory%29) +/// *of a 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{generalGraphModuleDiameter1} +/// ~ var db = require("internal").db; +/// var examples = require("org/arangodb/graph-examples/example-graph.js"); +/// var g = examples.loadGraph("routeplanner"); +/// g._diameter(); +/// @END_EXAMPLE_ARANGOSH_OUTPUT +/// +/// A route planner example, the diameter of the graph. +/// This considers the actual distances. +/// +/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphModuleDiameter2} +/// ~ var db = require("internal").db; +/// var examples = require("org/arangodb/graph-examples/example-graph.js"); +/// var g = examples.loadGraph("routeplanner"); +/// g._diameter({weight : 'distance'}); +/// @END_EXAMPLE_ARANGOSH_OUTPUT +/// +/// A route planner example, the diameter of the graph regarding only +/// outbound paths. +/// +/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphModuleDiameter3} +/// ~ var db = require("internal").db; +/// var examples = require("org/arangodb/graph-examples/example-graph.js"); +/// var g = examples.loadGraph("routeplanner"); +/// g._diameter({direction : 'outbound', weight : 'distance'}); +/// @END_EXAMPLE_ARANGOSH_OUTPUT +/// +/// @endDocuBlock +// +//////////////////////////////////////////////////////////////////////////////// +Graph.prototype._diameter = function(options) { + + var query = "RETURN" + + " GRAPH_DIAMETER(@graphName" + + ',@options' + + ')'; + options = options || {}; + var bindVars = { + "graphName": this.__name, + "options": options + }; + var result = db._query(query, bindVars).toArray(), returnHash = []; + return result; +}; + + + //////////////////////////////////////////////////////////////////////////////// /// @startDocuBlock JSF_general_graph__extendEdgeDefinitions diff --git a/js/common/modules/org/arangodb/general-graph.js b/js/common/modules/org/arangodb/general-graph.js index 5e0351c65e..49755e8888 100644 --- a/js/common/modules/org/arangodb/general-graph.js +++ b/js/common/modules/org/arangodb/general-graph.js @@ -177,6 +177,22 @@ var wrapCollection = function(col) { return wrapper; }; +//////////////////////////////////////////////////////////////////////////////// +/// @startDocuBlock JSF_general_graph_example_description +/// +/// For many of the following functions *examples* can be passed in as a parameter. +/// *Examples* are used to filter the result set for objects that match the conditions. +/// These *examples* can have the following values: +/// +/// * Empty, there is no matching executed all found results are valid. +/// * A string, only the result having this value as it's *_id* is returned. +/// * An example object, defining a set of attributes. +/// Only results having these attributes are matched. +/// * A list containing example objects and/or strings. +/// All results matching at least one of the elements in the list are returned. +/// +/// @endDocuBlock +//////////////////////////////////////////////////////////////////////////////// var transformExample = function(example) { if (example === undefined) { @@ -395,23 +411,16 @@ AQLGenerator.prototype._edges = function(edgeExample, options) { //////////////////////////////////////////////////////////////////////////////// /// @startDocuBlock JSF_general_graph_fluent_aql_edges -/// Select all edges for the vertices selected before. +/// `graph_query.edges(examples)` +/// *Select all edges for the vertices selected before.* /// -/// `graph-query.edges(examples)` /// /// Creates an AQL statement to select all edges for each of the vertices selected /// in the step before. /// This will include *inbound* as well as *outbound* edges. /// The resulting set of edges can be filtered by defining one or more *examples*. /// -/// *examples* can have the following values: -/// -/// * Empty, there is no matching executed all edges are valid. -/// * A string, only the edge having this value as it's id is returned. -/// * An example object, defining a set of attributes. -/// Only edges having these attributes are matched. -/// * A list containing example objects and/or strings. -/// All edges matching at least one of the elements in the list are returned. +/// * *examples*: See [Definition of examples](#definition_of_examples) /// /// *Examples* /// @@ -452,22 +461,15 @@ AQLGenerator.prototype.edges = function(example) { //////////////////////////////////////////////////////////////////////////////// /// @startDocuBlock JSF_general_graph_fluent_aql_outEdges -/// Select all outbound edges for the vertices selected before. +/// `graph_query.outEdges(examples)` +/// *Select all outbound edges for the vertices selected before.* /// -/// `graph-query.outEdges(examples)` /// /// Creates an AQL statement to select all *outbound* edges for each of the vertices selected /// in the step before. /// The resulting set of edges can be filtered by defining one or more *examples*. /// -/// *examples* can have the following values: -/// -/// * Empty, there is no matching executed all edges are valid. -/// * A string, only the edge having this value as it's id is returned. -/// * An example object, defining a set of attributes. -/// Only edges having these attributes are matched. -/// * A list containing example objects and/or strings. -/// All edges matching at least one of the elements in the list are returned. +/// * *examples*: See [Definition of examples](#definition_of_examples) /// /// *Examples* /// @@ -508,22 +510,15 @@ AQLGenerator.prototype.outEdges = function(example) { //////////////////////////////////////////////////////////////////////////////// /// @startDocuBlock JSF_general_graph_fluent_aql_inEdges -/// Select all inbound edges for the vertices selected before. +/// `graph_query.inEdges(examples)` +/// *Select all inbound edges for the vertices selected before.* /// -/// `graph-query.inEdges(examples)` /// /// Creates an AQL statement to select all *inbound* edges for each of the vertices selected /// in the step before. /// The resulting set of edges can be filtered by defining one or more *examples*. /// -/// *examples* can have the following values: -/// -/// * Empty, there is no matching executed all edges are valid. -/// * A string, only the edge having this value as it's id is returned. -/// * An example object, defining a set of attributes. -/// Only edges having these attributes are matched. -/// * A list containing example objects and/or strings. -/// All edges matching at least one of the elements in the list are returned. +/// * *examples*: See [Definition of examples](#definition_of_examples) /// /// *Examples* /// @@ -594,23 +589,16 @@ AQLGenerator.prototype._vertices = function(example, options) { //////////////////////////////////////////////////////////////////////////////// /// @startDocuBlock JSF_general_graph_fluent_aql_vertices -/// Select all vertices connected to the edges selected before. +/// `graph_query.vertices(examples)` +/// *Select all vertices connected to the edges selected before.* /// -/// `graph-query.vertices(examples)` /// /// Creates an AQL statement to select all vertices for each of the edges selected /// in the step before. /// This includes all vertices contained in *_from* as well as *_to* attribute of the edges. /// The resulting set of vertices can be filtered by defining one or more *examples*. /// -/// *examples* can have the following values: -/// -/// * Empty, there is no matching executed all vertices are valid. -/// * A string, only the vertex having this value as it's id is returned. -/// * An example object, defining a set of attributes. -/// Only vertices having these attributes are matched. -/// * A list containing example objects and/or strings. -/// All vertices matching at least one of the elements in the list are returned. +/// * *examples*: See [Definition of examples](#definition_of_examples) /// /// *Examples* /// @@ -664,23 +652,16 @@ AQLGenerator.prototype.vertices = function(example) { //////////////////////////////////////////////////////////////////////////////// /// @startDocuBlock JSF_general_graph_fluent_aql_fromVertices -/// Select all vertices where the edges selected before start. +/// `graph_query.vertices(examples)` +/// *Select all vertices where the edges selected before start.* /// -/// `graph-query.vertices(examples)` /// /// Creates an AQL statement to select the set of vertices where the edges selected /// in the step before start at. /// This includes all vertices contained in *_from* attribute of the edges. /// The resulting set of vertices can be filtered by defining one or more *examples*. /// -/// *examples* can have the following values: -/// -/// * Empty, there is no matching executed all vertices are valid. -/// * A string, only the vertex having this value as it's id is returned. -/// * An example object, defining a set of attributes. -/// Only vertices having these attributes are matched. -/// * A list containing example objects and/or strings. -/// All vertices matching at least one of the elements in the list are returned. +/// * *examples*: See [Definition of examples](#definition_of_examples) /// /// *Examples* /// @@ -732,23 +713,16 @@ AQLGenerator.prototype.fromVertices = function(example) { //////////////////////////////////////////////////////////////////////////////// /// @startDocuBlock JSF_general_graph_fluent_aql_toVertices -/// Select all vertices targeted by the edges selected before. +/// `graph_query.vertices(examples)` +/// *Select all vertices targeted by the edges selected before.* /// -/// `graph-query.vertices(examples)` /// /// Creates an AQL statement to select the set of vertices where the edges selected /// in the step before end in. /// This includes all vertices contained in *_to* attribute of the edges. /// The resulting set of vertices can be filtered by defining one or more *examples*. /// -/// *examples* can have the following values: -/// -/// * Empty, there is no matching executed all vertices are valid. -/// * A string, only the vertex having this value as it's id is returned. -/// * An example object, defining a set of attributes. -/// Only vertices having these attributes are matched. -/// * A list containing example objects and/or strings. -/// All vertices matching at least one of the elements in the list are returned. +/// * *examples*: See [Definition of examples](#definition_of_examples) /// /// *Examples* /// @@ -817,7 +791,8 @@ AQLGenerator.prototype.getLastVar = function() { //////////////////////////////////////////////////////////////////////////////// /// @startDocuBlock JSF_general_graph_fluent_aql_path -/// The result of the query is the path to all elements. +/// `graph_query.path()` +/// *The result of the query is the path to all elements.* /// /// By defaut the result of the generated AQL query is the set of elements passing the last matches. /// So having a `vertices()` query as the last step the result will be set of vertices. @@ -870,35 +845,25 @@ AQLGenerator.prototype.pathEdges = function() { //////////////////////////////////////////////////////////////////////////////// /// @startDocuBlock JSF_general_graph_fluent_aql_neighbors -/// Select all neighbors of the vertices selected in the step before. +/// `graph_query.neighbors(examples, options)` +/// *Select all neighbors of the vertices selected in the step before.* /// -/// `graph-query.neighbors(examples)` /// /// Creates an AQL statement to select all neighbors for each of the vertices selected /// in the step before. /// The resulting set of vertices can be filtered by defining one or more *examples*. /// -/// *examples* can have the following values: -/// -/// * Empty, there is no matching executed all vertices are valid. -/// * A string, only the vertex having this value as it's id is returned. -/// * An example object, defining a set of attributes. -/// Only vertices having these attributes are matched. -/// * A list containing example objects and/or strings. -/// All vertices matching at least one of the elements in the list are returned. -/// 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|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*: See [Definition of examples](#definition_of_examples) +/// * *options* (optional): An object defining further options. Can have the following values: +/// Possible options and their defaults: +/// * *direction*: The direction of the edges. Possible values are *outbound*, *inbound* and *any* (default). +/// * *edgeExamples*: See [Definition of examples](#definition_of_examples) +/// * *edgeCollectionRestriction* : One or a list of edge-collection names that should be +/// considered to be on the path. +/// * *vertexCollectionRestriction* : One or a list of vertex-collection names that should be +/// considered on the intermediate vertex steps. +/// * *minDepth*: Defines the minimal number of intermediate steps to neighbors (default is 1). +/// * *maxDepth*: Defines the maximal number of intermediate steps to neighbors (default is 1). /// /// *Examples* /// @@ -981,10 +946,10 @@ AQLGenerator.prototype._getLastRestrictableStatementInfo = function() { //////////////////////////////////////////////////////////////////////////////// /// @startDocuBlock JSF_general_graph_fluent_aql_restrict -/// Restricts the last statement in the chain to return -/// only elements of a specified set of collections +/// `graph_query.restrict(restrictions)` +/// *Restricts the last statement in the chain to return +/// only elements of a specified set of collections* /// -/// `graph-query.restrict(restrictions)` /// /// By default all collections in the graph are searched for matching elements /// whenever vertices and edges are requested. @@ -993,12 +958,8 @@ AQLGenerator.prototype._getLastRestrictableStatementInfo = function() { /// Restriction is only applied to this one part of the query. /// It does not effect earlier or later statements. /// -/// *restrictions* can have the following values: -/// -/// * A string defining the name of one specific collection in the graph. -/// Only elements from this collection are used for matching -/// * A list of strings defining a set of collection names. -/// Elements from all collections in this set are used for matching +/// * *restrictions*: Define either one or a list of collections in the graph. +/// Only elements from these collections are taken into account for the result. /// /// *Examples* /// @@ -1062,20 +1023,13 @@ AQLGenerator.prototype.restrict = function(restrictions) { //////////////////////////////////////////////////////////////////////////////// /// @startDocuBlock JSF_general_graph_fluent_aql_filter -/// Filter the result of the query -/// -/// `graph-query.filter(examples)` +/// `graph_query.filter(examples)` +/// *Filter the result of the query* /// /// This can be used to further specfiy the expected result of the query. /// The result set is reduced to the set of elements that matches the given *examples*. /// -/// *examples* can have the following values: -/// -/// * A string, only the elements having this value as it's id is returned. -/// * An example object, defining a set of attributes. -/// Only elements having these attributes are matched. -/// * A list containing example objects and/or strings. -/// All elements matching at least one of the elements in the list are returned. +/// * *examples*: See [Definition of examples](#definition_of_examples) /// /// *Examples* /// @@ -1159,9 +1113,9 @@ AQLGenerator.prototype.execute = function() { //////////////////////////////////////////////////////////////////////////////// /// @startDocuBlock JSF_general_graph_fluent_aql_toArray -/// Returns an array containing the complete result. -/// /// `graph-query.toArray()` +/// *Returns an array containing the complete result.* +/// /// /// This function executes the generated query and returns the /// entire result as one array.