1
0
Fork 0

Merge branch 'devel' of github.com:triAGENS/ArangoDB into devel

This commit is contained in:
Michael Hackstein 2014-06-20 13:02:06 +02:00
commit 44297f43c0
8 changed files with 1011 additions and 3751 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,88 +0,0 @@
!CHAPTER Graph operations
This chapter describe graph related aql functions.
!SUBSECTION Edges and Vertices related functions.
This section describes various AQL functions which can be used to recieve information about the graph's vertices, edges, neighbor relationship and shared properties.
!SUBSUBSECTION GRAPH_EDGES
<!-- @startDocuBlock JSF_ahuacatl_general_graph_edges -->
!SUBSUBSECTION GRAPH_VERTICES
<!-- @startDocuBlock JSF_ahuacatl_general_graph_vertices -->
!SUBSUBSECTION GRAPH_COMMON_NEIGHBORS
<!-- @startDocuBlock JSF_ahuacatl_general_graph_common_neighbors -->
!SUBSUBSECTION GRAPH_COMMON_PROPERTIES
<!-- @startDocuBlock JSF_ahuacatl_general_graph_common_properties -->
!SUBSUBSECTION GRAPH_NEIGHBORS
<!-- @startDocuBlock JSF_ahuacatl_general_graph_neighbors -->
!SUBSECTION Shortest Paths, distances and traversals.
This section describes AQL functions, that calculate pathes from a subset of vertices in a graph to another subset of vertices.
!SUBSUBSECTION GRAPH_PATHS
<!-- @startDocuBlock JSF_ahuacatl_general_graph_paths -->
!SUBSUBSECTION GRAPH_SHORTEST_PATH
<!-- @startDocuBlock JSF_ahuacatl_general_graph_shortest_paths -->
!SUBSUBSECTION GRAPH_TRAVERSAL
<!-- @startDocuBlock JSF_ahuacatl_general_graph_traversal -->
!SUBSUBSECTION GRAPH_TRAVERSAL_TREE
<!-- @startDocuBlock JSF_ahuacatl_general_graph_traversal_tree -->
!SUBSUBSECTION GRAPH_DISTANCE_TO
<!-- @startDocuBlock JSF_ahuacatl_general_graph_distance -->
!SUBSECTION Graph measurements.
This section describes AQL functions to calculate various graph related measurements as defined in the mathematical graph theory.
!SUBSUBSECTION GRAPH_ABSOLUTE_ECCENTRICITY
<!-- @startDocuBlock JSF_ahuacatl_general_graph_absolute_eccentricity -->
!SUBSUBSECTION GRAPH_ECCENTRICITY
<!-- @startDocuBlock JSF_ahuacatl_general_graph_eccentricity -->
!SUBSUBSECTION GRAPH_ABSOLUTE_CLOSENESS
<!-- @startDocuBlock JSF_ahuacatl_general_graph_absolute_closeness -->
!SUBSUBSECTION GRAPH_CLOSENESS
<!-- @startDocuBlock JSF_ahuacatl_general_graph_closeness -->
!SUBSUBSECTION GRAPH_ABSOLUTE_BETWEENNESS
<!-- @startDocuBlock JSF_ahuacatl_general_graph_absolute_betweenness -->
!SUBSUBSECTION GRAPH_BETWEENNESS
<!-- @startDocuBlock JSF_ahuacatl_general_graph_betweenness -->
!SUBSUBSECTION GRAPH_RADIUS
<!-- @startDocuBlock JSF_ahuacatl_general_graph_radius -->
!SUBSUBSECTION GRAPH_DIAMETER
<!-- @startDocuBlock JSF_ahuacatl_general_graph_diameter -->

View File

@ -6,562 +6,62 @@ This chapter describes various functions on a graph.
!SUBSECTION Get vertex *from* of an edge
Get the vertex of an edge defined as *_from*
<br />
`general-graph._getFromVertex(edgeId)`
<br />
Returns the vertex defined with the attribute *_from* of the edge with *edgeId* as its *_id*.
<br />
@EXAMPLES
<br />
```
arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js");
arangosh> var g = examples.loadGraph("social");
arangosh> g._getFromVertex("relation/aliceAndBob")
{
"name" : "Alice",
"_id" : "female/alice",
"_rev" : "236262839",
"_key" : "alice"
}
```
<br />
@startDocuBlock JSF_general_graph_getFromVertex
!SUBSECTION Get vertex *to* of an edge
Get the vertex of an edge defined as *_to*
<br />
`general-graph._getToVertex(edgeId)`
<br />
Returns the vertex defined with the attribute *_to* of the edge with *edgeId* as its *_id*.
<br />
@EXAMPLES
<br />
@startDocuBlock JSF_general_graph_getToVertex
```
arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js");
arangosh> var g = examples.loadGraph("social");
arangosh> g._getToVertex("relation/aliceAndBob")
{
"name" : "Bob",
"_id" : "male/bob",
"_rev" : "70784439",
"_key" : "bob"
}
```
<br />
!SECTION _neighbors
@startDocuBlock JSF_general_graph_neighbors
!SECTION _commonNeighbors
@startDocuBlock JSF_general_graph_common_neighbors
!SECTION _countCommonNeighbors
@startDocuBlock JSF_general_graph_count_common_neighbors
!SECTION _commonProperties
@startDocuBlock JSF_general_graph_common_properties
!SECTION _countCommonProperties
@startDocuBlock JSF_general_graph_count_common_properties
!SECTION _listCommonNeighbors
!SECTION _absoluteEccentricity
<br />
`general_graph._listCommonNeighbors(vertex1Example, vertex2Examples,
optionsVertex1, optionsVertex2)`
*The general_graph._listCommonNeighbors function returns all common neighbors
of the vertices defined by the examples.*
<br />
The function accepts an id, an example, a list of examples or even an empty
example as parameter for vertex1Example and vertex2Example.
<br />
* 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 *optionsVertex1* : Optional options, see below:
* Object *optionsVertex2* : Optional options, see below:
<br />
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).
<br />
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.
<br />
@EXAMPLES
<br />
A route planner example, all common neighbors of capitals.
<br />
@startDocuBlock JSF_general_graph_absolute_eccentricity
```
arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js");
arangosh> var g = examples.loadGraph("routeplanner");
arangosh> g._listCommonNeighbors({isCapital : true}, {isCapital : true});
[
{
"city/Berlin" : {
"city/Munich" : [
{
"_id" : "city/Cologne",
"_rev" : "339311159",
"_key" : "Cologne",
"isCapital" : false,
"population" : 1000000
},
{
"_id" : "village/Olpe",
"_rev" : "339966519",
"_key" : "Olpe",
"isCapital" : false,
"population" : 80000
},
{
"_id" : "village/Rosenheim",
"_rev" : "340163127",
"_key" : "Rosenheim",
"isCapital" : false,
"population" : 80000
}
]
}
},
{
"city/Munich" : {
"city/Berlin" : [
{
"_id" : "city/Cologne",
"_rev" : "339311159",
"_key" : "Cologne",
"isCapital" : false,
"population" : 1000000
},
{
"_id" : "village/Olpe",
"_rev" : "339966519",
"_key" : "Olpe",
"isCapital" : false,
"population" : 80000
},
{
"_id" : "village/Rosenheim",
"_rev" : "340163127",
"_key" : "Rosenheim",
"isCapital" : false,
"population" : 80000
}
]
}
}
]
```
<br />
A route planner example, all common outbound neighbors of munich with any other location
which have a maximal depth of 2 :
<br />
!SECTION _eccentricity
```
arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js");
arangosh> var g = examples.loadGraph("routeplanner");
arangosh> g._listCommonNeighbors('city/Munich', {}, {direction : 'outbound', maxDepth : 2},
........> {direction : 'outbound', maxDepth : 2});
[
{
"city/Munich" : {
"city/Berlin" : [
{
"_id" : "city/Cologne",
"_rev" : "424901175",
"_key" : "Cologne",
"isCapital" : false,
"population" : 1000000
},
{
"_id" : "village/Olpe",
"_rev" : "425556535",
"_key" : "Olpe",
"isCapital" : false,
"population" : 80000
},
{
"_id" : "village/Rosenheim",
"_rev" : "425753143",
"_key" : "Rosenheim",
"isCapital" : false,
"population" : 80000
}
],
"city/Cologne" : [
{
"_id" : "village/Olpe",
"_rev" : "425556535",
"_key" : "Olpe",
"isCapital" : false,
"population" : 80000
},
{
"_id" : "village/Rosenheim",
"_rev" : "425753143",
"_key" : "Rosenheim",
"isCapital" : false,
"population" : 80000
}
]
}
}
]
```
<br />
@startDocuBlock JSF_general_graph_eccentricity
!SECTION _absoluteCloseness
@startDocuBlock JSF_general_graph_absolute_closeness
!SECTION _amountCommonNeighbors
!SECTION _closeness
<br />
`general_graph._amountCommonNeighbors(vertex1Example, vertex2Examples,
optionsVertex1, optionsVertex2)`
*The general_graph._amountCommonNeighbors function returns the amount of
common neighbors of the vertices defined by the examples.*
<br />
The function accepts an id, an example, a list of examples or even an empty
example as parameter for vertex1Example and vertex2Example.
<br />
* 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 *optionsVertex1* : Optional options, see below:
* Object *optionsVertex2* : Optional options, see below:
<br />
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).
<br />
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.
<br />
@EXAMPLES
<br />
A route planner example, all common neighbors of capitals.
<br />
@startDocuBlock JSF_general_graph_closeness
```
arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js");
arangosh> var g = examples.loadGraph("routeplanner");
arangosh> g._amountCommonNeighbors({isCapital : true}, {isCapital : true});
[
{
"city/Berlin" : [
{
"city/Munich" : 3
}
]
},
{
"city/Munich" : [
{
"city/Berlin" : 3
}
]
}
]
```
<br />
A route planner example, all common outbound neighbors of munich with any other location
which have a maximal depth of 2 :
<br />
!SECTION _absoluteBetweenness
```
arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js");
arangosh> var g = examples.loadGraph("routeplanner");
arangosh> g._amountCommonNeighbors('city/Munich', {}, {direction : 'outbound', maxDepth : 2},
........> {direction : 'outbound', maxDepth : 2});
[
{
"city/Munich" : [
{
"city/Berlin" : 3
},
{
"city/Cologne" : 2
}
]
}
]
```
<br />
@startDocuBlock JSF_general_graph_absolute_betweenness
!SECTION _betweenness
@startDocuBlock JSF_general_graph_betweenness
!SECTION _listCommonProperties
!SECTION _radius
<br />
`general_graph._listCommonProperties(vertex1Example, vertex2Examples,
options)`
*The general_graph._listCommonProperties function returns the vertices of
the graph that share common properties.*
<br />
The function accepts an id, an example, a list of examples or even an empty
example as parameter for vertex1Example and vertex2Example.
<br />
* 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:
<br />
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.
<br />
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.
<br />
@EXAMPLES
<br />
A route planner example, all locations with the same properties:
<br />
@startDocuBlock JSF_general_graph_radius
```
arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js");
arangosh> var g = examples.loadGraph("routeplanner");
arangosh> g._listCommonProperties({}, {});
[
{
"city/Berlin" : [
{
"_id" : "city/Munich",
"_rev" : "174396855",
"_key" : "Munich",
"isCapital" : true,
"population" : 1000000
}
]
},
{
"city/Cologne" : [
{
"_id" : "village/Rosenheim",
"_rev" : "175052215",
"_key" : "Rosenheim",
"isCapital" : false,
"population" : 80000
},
{
"_id" : "village/Olpe",
"_rev" : "174855607",
"_key" : "Olpe",
"isCapital" : false,
"population" : 80000
},
{
"_id" : "city/Munich",
"_rev" : "174396855",
"_key" : "Munich",
"isCapital" : true,
"population" : 1000000
}
]
},
{
"city/Munich" : [
{
"_id" : "city/Berlin",
"_rev" : "174003639",
"_key" : "Berlin",
"isCapital" : true,
"population" : 3000000
},
{
"_id" : "city/Cologne",
"_rev" : "174200247",
"_key" : "Cologne",
"isCapital" : false,
"population" : 1000000
}
]
},
{
"village/Olpe" : [
{
"_id" : "city/Cologne",
"_rev" : "174200247",
"_key" : "Cologne",
"isCapital" : false,
"population" : 1000000
},
{
"_id" : "village/Rosenheim",
"_rev" : "175052215",
"_key" : "Rosenheim",
"isCapital" : false,
"population" : 80000
}
]
},
{
"village/Rosenheim" : [
{
"_id" : "city/Cologne",
"_rev" : "174200247",
"_key" : "Cologne",
"isCapital" : false,
"population" : 1000000
},
{
"_id" : "village/Olpe",
"_rev" : "174855607",
"_key" : "Olpe",
"isCapital" : false,
"population" : 80000
}
]
}
]
```
<br />
A route planner example, all cities which share same properties except for population.
<br />
!SECTION _diameter
```
arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js");
arangosh> var g = examples.loadGraph("routeplanner");
arangosh> g._listCommonProperties({}, {}, {vertex1CollectionRestriction : 'city',
........> vertex2CollectionRestriction : 'city' ,ignoreProperties: 'population'});
[
{
"city/Berlin" : [
{
"_id" : "city/Munich",
"_rev" : "179574199",
"_key" : "Munich",
"isCapital" : true,
"population" : 1000000
}
]
},
{
"city/Munich" : [
{
"_id" : "city/Berlin",
"_rev" : "179180983",
"_key" : "Berlin",
"isCapital" : true,
"population" : 3000000
}
]
}
]
```
<br />
!SECTION _amountCommonProperties
<br />
`general_graph._amountCommonProperties(vertex1Example, vertex2Examples,
options)`
*The general_graph._amountCommonProperties function returns the amount of vertices of
the graph that share common properties.*
<br />
The function accepts an id, an example, a list of examples or even an empty
example as parameter for vertex1Example and vertex2Example.
<br />
* 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:
<br />
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.
<br />
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.
<br />
@EXAMPLES
<br />
A route planner example, all locations with the same properties:
<br />
```
arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js");
arangosh> var g = examples.loadGraph("routeplanner");
arangosh> g._amountCommonProperties({}, {});
[
{
"city/Berlin" : 1
},
{
"city/Cologne" : 3
},
{
"city/Munich" : 2
},
{
"village/Olpe" : 2
},
{
"village/Rosenheim" : 2
}
]
```
<br />
A route planner example, all cities which share same properties except for population.
<br />
```
arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js");
arangosh> var g = examples.loadGraph("routeplanner");
arangosh> g._amountCommonProperties({}, {}, {vertex1CollectionRestriction : 'city',
........> vertex2CollectionRestriction : 'city' ,ignoreProperties: 'population'});
[
{
"city/Berlin" : 1
},
{
"city/Munich" : 1
}
]
```
<br />
@startDocuBlock JSF_general_graph_diameter

View File

@ -1,34 +0,0 @@
!CHAPTER Graph Functions
This chapter describes various functions on a graph.
!SECTION Get vertices from edges.
!SUBSECTION Get vertex *from* of an edge
<!-- @startDocuBlock JSF_general_graph_getFromVertex -->
!SUBSECTION Get vertex *to* of an edge
<!-- @startDocuBlock JSF_general_graph_getToVertex -->
!SECTION _listCommonNeighbors
<!-- @startDocuBlock JSF_general_graph_common_neighbors -->
!SECTION _amountCommonNeighbors
<!-- @startDocuBlock JSF_general_graph_amount_common_neighbors -->
!SECTION _listCommonProperties
<!-- @startDocuBlock JSF_general_graph_common_properties -->
!SECTION _amountCommonProperties
<!-- @startDocuBlock JSF_general_graph_amount_common_properties -->

View File

@ -886,6 +886,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*
///
@ -2519,22 +2532,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
@ -2561,24 +2570,81 @@ Graph.prototype._getVertexCollectionByName = function(name) {
///
/// *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.
///
/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphModuleCommonNeighbors1}
/// ~ 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',
/// | g._commonNeighbors(
/// | 'germanCity/Hamburg',
/// | {},
/// | {direction : 'outbound', maxDepth : 2},
/// {direction : 'outbound', maxDepth : 2});
@ -2588,7 +2654,7 @@ Graph.prototype._getVertexCollectionByName = function(name) {
//
////////////////////////////////////////////////////////////////////////////////
Graph.prototype._listCommonNeighbors = function(vertex1Example, vertex2Example, optionsVertex1, optionsVertex2) {
Graph.prototype._commonNeighbors = function(vertex1Example, vertex2Example, optionsVertex1, optionsVertex2) {
var ex1 = transformExample(vertex1Example);
var ex2 = transformExample(vertex2Example);
@ -2612,11 +2678,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
@ -2660,17 +2726,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
///
@ -2678,7 +2744,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"
@ -2719,9 +2785,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
@ -2756,7 +2822,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.
@ -2765,15 +2831,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);
@ -2795,11 +2860,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
@ -2834,24 +2899,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"
@ -2877,6 +2942,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

View File

@ -65,25 +65,31 @@
var createRoutePlannerGraph = function() {
var edgeDefinition = [];
edgeDefinition.push(Graph._directedRelation("highway", ["city"], ["city"]));
edgeDefinition.push(Graph._directedRelation(
"road", ["village", "city"], ["village", "city"])
"germanHighway", ["germanCity"], ["germanCity"])
);
edgeDefinition.push(
Graph._directedRelation("frenchHighway", ["frenchCity"], ["frenchCity"])
);
edgeDefinition.push(Graph._directedRelation(
"internationalHighway", ["frenchCity", "germanCity"], ["frenchCity", "germanCity"])
);
var g = Graph._create("routeplanner", edgeDefinition);
var berlin = g.city.save({_key: "Berlin", population : 3000000, isCapital : true});
var cologne = g.city.save({_key: "Cologne", population : 1000000, isCapital : false});
var munich = g.city.save({_key: "Munich", population : 1000000, isCapital : true});
var olpe = g.village.save({_key: "Olpe", population : 80000, isCapital : false});
var rosenheim = g.village.save({_key: "Rosenheim", population : 80000, isCapital : false});
g.highway.save(berlin._id, cologne._id, {distance: 850});
g.highway.save(berlin._id, munich._id, {distance: 600});
g.highway.save(munich._id, cologne._id, {distance: 650});
g.road.save(berlin._id, olpe._id, {distance: 700});
g.road.save(berlin._id, rosenheim._id, {distance: 800});
g.road.save(munich._id, rosenheim._id, {distance: 80});
g.road.save(munich._id, olpe._id, {distance: 600});
g.road.save(cologne._id, olpe._id, {distance: 100});
g.road.save(cologne._id, rosenheim._id, {distance: 750});
var berlin = g.germanCity.save({_key: "Berlin", population : 3000000, isCapital : true});
var cologne = g.germanCity.save({_key: "Cologne", population : 1000000, isCapital : false});
var hamburg = g.germanCity.save({_key: "Hamburg", population : 1000000, isCapital : false});
var lyon = g.frenchCity.save({_key: "Lyon", population : 80000, isCapital : false});
var paris = g.frenchCity.save({_key: "Paris", population : 4000000, isCapital : true});
g.germanHighway.save(berlin._id, cologne._id, {distance: 850});
g.germanHighway.save(berlin._id, hamburg._id, {distance: 400});
g.germanHighway.save(hamburg._id, cologne._id, {distance: 500});
g.frenchHighway.save(paris._id, lyon._id, {distance: 550});
g.internationalHighway.save(berlin._id, lyon._id, {distance: 1100});
g.internationalHighway.save(berlin._id, paris._id, {distance: 1200});
g.internationalHighway.save(hamburg._id, paris._id, {distance: 900});
g.internationalHighway.save(hamburg._id, lyon._id, {distance: 1300});
g.internationalHighway.save(cologne._id, lyon._id, {distance: 700});
g.internationalHighway.save(cologne._id, paris._id, {distance: 550});
return g;
};

View File

@ -2314,11 +2314,30 @@ function GeneralGraphCommonNeighborsSuite() {
/// @brief checks GRAPH_COMMON_NEIGHBORS() and GRAPH_COMMON_PROPERTIES()
////////////////////////////////////////////////////////////////////////////////
testNeighborsAnyV3: function () {
actual = testGraph._neighbors(v3);
assertTrue(actual[0]._id, v2);
assertTrue(actual[1]._id, v5);
assertTrue(actual[2]._id, v8);
assertTrue(actual[3]._id, v5);
assertTrue(actual[4]._id, v7);
},
testNeighborsAnyV6: function () {
actual = testGraph._neighbors(v6);
assertTrue(actual[0]._id, v2);
assertTrue(actual[1]._id, v7);
},
testCommonNeighborsAny: function () {
actual = testGraph._listCommonNeighbors(v3 , v6);
actual = testGraph._commonNeighbors(v3 , v6);
assertEqual(actual[0][v3][v6][0]._id , v2);
assertEqual(actual[0][v3][v6][1]._id , v7);
actual = testGraph._amountCommonNeighbors(v3 , v6);
actual = testGraph._countCommonNeighbors(v3 , v6);
assertEqual(actual[0][v3][0][v6] , 2);
},
////////////////////////////////////////////////////////////////////////////////
@ -2326,7 +2345,7 @@ function GeneralGraphCommonNeighborsSuite() {
////////////////////////////////////////////////////////////////////////////////
testCommonNeighborsIn: function () {
actual = testGraph._listCommonNeighbors({} , {}, {direction : 'inbound'}, {direction : 'inbound'});
actual = testGraph._commonNeighbors({} , {}, {direction : 'inbound'}, {direction : 'inbound'});
assertEqual(actual[0][v3][v6][0]._id, v2);
assertEqual(actual[1][v5][v8][0]._id, v3);
assertEqual(actual[1][v5][v7][0]._id, v3);
@ -2336,7 +2355,7 @@ function GeneralGraphCommonNeighborsSuite() {
assertEqual(actual[4][v8][v5][0]._id, v3);
assertEqual(actual[4][v8][v7][0]._id, v3);
actual = testGraph._amountCommonNeighbors({} , {}, {direction : 'inbound'}, {direction : 'inbound'});
actual = testGraph._countCommonNeighbors({} , {}, {direction : 'inbound'}, {direction : 'inbound'});
assertEqual(actual[0][v3][0][v6] , 1);
assertEqual(actual[1][v5][0][v8] , 1);
assertEqual(actual[1][v5][1][v7] , 1);
@ -2355,7 +2374,7 @@ function GeneralGraphCommonNeighborsSuite() {
////////////////////////////////////////////////////////////////////////////////
testCommonNeighborsOut: function () {
actual = testGraph._listCommonNeighbors(
actual = testGraph._commonNeighbors(
{hugo: true}, {heinz: 1},
{direction: 'outbound', minDepth: 1, maxDepth: 3},
{direction: 'outbound', minDepth: 1, maxDepth: 3}
@ -2372,7 +2391,7 @@ function GeneralGraphCommonNeighborsSuite() {
assertEqual(actual[0][Object.keys(actual[0])[0]][v3].length, 4);
assertEqual(actual[0][Object.keys(actual[0])[0]][v8].length, 3);
actual = testGraph._amountCommonNeighbors(
actual = testGraph._countCommonNeighbors(
{hugo: true }, {heinz: 1},
{direction: 'outbound', minDepth: 1, maxDepth: 3},
{direction: 'outbound', minDepth: 1, maxDepth: 3}
@ -2388,7 +2407,7 @@ function GeneralGraphCommonNeighborsSuite() {
////////////////////////////////////////////////////////////////////////////////
testCommonProperties: function () {
actual = testGraph._listCommonProperties({} ,{} ,{});
actual = testGraph._commonProperties({} ,{} ,{});
assertEqual(actual[0][v1][0]._id , v2);
assertEqual(actual[1][v2][0]._id , v1);
assertEqual(actual[2][v3][0]._id , v8);
@ -2408,7 +2427,7 @@ function GeneralGraphCommonNeighborsSuite() {
assertEqual(actual[7][v8][2]._id , v7);
assertEqual(actual[7][v8][3]._id , v3);
actual = testGraph._amountCommonProperties({} ,{} ,{});
actual = testGraph._countCommonProperties({} ,{} ,{});
assertEqual(actual, [
createKeyValueObject(v1, 1),
createKeyValueObject(v2, 1),
@ -2422,13 +2441,13 @@ function GeneralGraphCommonNeighborsSuite() {
},
testCommonPropertiesWithFilters: function () {
actual = testGraph._listCommonProperties({ageing : true} , {harald : 'meier'}, {});
actual = testGraph._commonProperties({ageing : true} , {harald : 'meier'}, {});
assertEqual(actual[0][v5][0]._id , v6);
assertEqual(actual[1][v6][0]._id , v4);
assertEqual(actual[1][v6][1]._id , v8);
assertEqual(actual[1][v6][2]._id , v7);
actual = testGraph._amountCommonProperties({ageing : true} , {harald : 'meier'}, {});
actual = testGraph._countCommonProperties({ageing : true} , {harald : 'meier'}, {});
assertEqual(actual, [
createKeyValueObject(v5, 1),
createKeyValueObject(v6, 3)
@ -2437,7 +2456,7 @@ function GeneralGraphCommonNeighborsSuite() {
},
testCommonPropertiesWithFiltersAndIgnoringKeyHarald: function () {
actual = testGraph._listCommonProperties( {} , {}, {ignoreProperties : 'harald'});
actual = testGraph._commonProperties( {} , {}, {ignoreProperties : 'harald'});
assertEqual(actual[0][v1][0]._id , v2);
assertEqual(actual[1][v2][0]._id , v1);
@ -2446,7 +2465,7 @@ function GeneralGraphCommonNeighborsSuite() {
assertEqual(actual[4][v6][0]._id , v5);
assertEqual(actual[5][v8][0]._id , v3);
actual = testGraph._amountCommonProperties({} , {}, {ignoreProperties : 'harald'});
actual = testGraph._countCommonProperties({} , {}, {ignoreProperties : 'harald'});
assertEqual(actual, [
createKeyValueObject(v1, 1),
createKeyValueObject(v2, 1),
@ -2581,6 +2600,142 @@ function OrphanCollectionSuite() {
}
function MeasurementsSuite() {
var g;
var vertexId1, vertexId2;
var unitTestGraphName = "unitTestGraph";
var ec1 = "unitTestEdgeCollection1";
var ec2 = "unitTestEdgeCollection2";
var vc1 = "unitTestVertexCollection1";
var vc2 = "unitTestVertexCollection2";
var vc3 = "unitTestVertexCollection3";
var vc4 = "unitTestVertexCollection4";
var fillCollections = function() {
var ids = {};
var vertex = g[vc1].save({first_name: "Tam"});
ids.vId11 = vertex._id;
vertex = g[vc1].save({first_name: "Tem"});
ids.vId12 = vertex._id;
vertex = g[vc1].save({first_name: "Tim"});
ids.vId13 = vertex._id;
vertex = g[vc1].save({first_name: "Tom"});
ids.vId14 = vertex._id;
vertex = g[vc1].save({first_name: "Tum"});
ids.vId15 = vertex._id;
vertex = g[vc3].save({first_name: "Tam"});
ids.vId31 = vertex._id;
vertex = g[vc3].save({first_name: "Tem"});
ids.vId32 = vertex._id;
vertex = g[vc3].save({first_name: "Tim"});
ids.vId33 = vertex._id;
vertex = g[vc3].save({first_name: "Tom"});
ids.vId34 = vertex._id;
vertex = g[vc3].save({first_name: "Tum"});
ids.vId35 = vertex._id;
var edge = g[ec1].save(ids.vId11, ids.vId12, {});
ids.eId11 = edge._id;
edge = g[ec1].save(ids.vId11, ids.vId13, {});
ids.eId12 = edge._id;
edge = g[ec1].save(ids.vId11, ids.vId14, {});
ids.eId13 = edge._id;
edge = g[ec1].save(ids.vId11, ids.vId15, {});
ids.eId14 = edge._id;
edge = g[ec1].save(ids.vId12, ids.vId11, {});
ids.eId15 = edge._id;
edge = g[ec1].save(ids.vId13, ids.vId11, {});
ids.eId16 = edge._id;
edge = g[ec1].save(ids.vId14, ids.vId11, {});
ids.eId17 = edge._id;
edge = g[ec1].save(ids.vId15, ids.vId11, {});
ids.eId18 = edge._id;
edge = g[ec2].save(ids.vId11, ids.vId31, {});
ids.eId21 = edge._id;
edge = g[ec2].save(ids.vId11, ids.vId32, {});
ids.eId22 = edge._id;
edge = g[ec2].save(ids.vId11, ids.vId33, {});
ids.eId23 = edge._id;
edge = g[ec2].save(ids.vId11, ids.vId34, {});
ids.eId24 = edge._id;
edge = g[ec2].save(ids.vId11, ids.vId35, {});
ids.eId25 = edge._id;
return ids;
};
return {
setUp : function() {
try {
arangodb.db._collection("_graphs").remove(unitTestGraphName);
} catch (ignore) {
}
g = graph._create(
unitTestGraphName,
graph._edgeDefinitions(
graph._undirectedRelationDefinition(ec1, vc1),
graph._directedRelationDefinition(ec2,
[vc1, vc2], [vc3, vc4]
)
)
);
fillCollections();
},
tearDown : function() {
graph._drop(unitTestGraphName);
try {db[vc1].drop()} catch (e) {}
try {db[vc2].drop()} catch (e) {}
try {db[vc3].drop()} catch (e) {}
try {db[vc4].drop()} catch (e) {}
try {db[ec1].drop()} catch (e) {}
try {db[ec2].drop()} catch (e) {}
},
test_absoluteEccentricity : function () {
var a = g._absoluteEccentricity({});
assertEqual(Object.keys(a[0]).length , 10);
},
test_eccentricity : function () {
var a = g._eccentricity({});
assertEqual(Object.keys(a[0]).length , 10);
},
test_absoluteCloseness : function () {
var a = g._absoluteCloseness({});
assertEqual(Object.keys(a[0]).length , 10);
},
test_closeness : function () {
var a = g._closeness({});
assertEqual(Object.keys(a[0]).length , 10);
},
test_absoluteBetweenness : function () {
var a = g._absoluteBetweenness({});
assertEqual(Object.keys(a[0]).length , 10);
},
test_betweenness : function () {
var a = g._betweenness({});
assertEqual(Object.keys(a[0]).length , 10);
},
test_radius : function () {
var a = g._radius({});
assertEqual(a[0] , 1);
},
test_diameter : function () {
var a = g._diameter({});
assertEqual(a[0] , 2);
}
};
}
// -----------------------------------------------------------------------------
// --SECTION-- main
@ -2596,6 +2751,7 @@ jsunity.run(EdgesAndVerticesSuite);
jsunity.run(GeneralGraphCreationSuite);
jsunity.run(ChainedFluentAQLResultsSuite);
jsunity.run(OrphanCollectionSuite);
jsunity.run(MeasurementsSuite);
return jsunity.done();

View File

@ -4557,11 +4557,6 @@ function DOCUMENTS_BY_EXAMPLE (collectionList, example) {
function RESOLVE_GRAPH_TO_DOCUMENTS (graphname, options) {
// check graph exists and load edgeDefintions
/*if (ResolvedGraphCache[graphname + JSON.stringify(options)]) {
require("internal").print("resolved from cache");
return ResolvedGraphCache[graphname + JSON.stringify(options)];
}*/
var graph = DOCUMENT_HANDLE("_graphs/" + graphname);
if (! graph) {
THROW(INTERNAL.errors.ERROR_GRAPH_INVALID_GRAPH, "GRAPH_EDGES");
@ -5083,27 +5078,29 @@ function IS_EXAMPLE_SET (example) {
///
/// *Examples*
///
/// A route planner example, shortest distance from all villages to other cities:
/// A route planner example, shortest distance from all german to all french cities:
///
/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphShortestPaths1}
/// ~ 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_SHORTEST_PATH("
/// |+"'routeplanner', {}, {}, {weight : 'distance', endVertexCollectionRestriction : 'city', " +
/// |"startVertexCollectionRestriction : 'village'}) RETURN [e.startVertex, e.vertex._id, " +
/// | + "'routeplanner', {}, {}, {" +
/// | "weight : 'distance', endVertexCollectionRestriction : 'frenchCity', " +
/// | "startVertexCollectionRestriction : 'germanCity'}) RETURN [e.startVertex, e.vertex._id, " +
/// | "e.distance, LENGTH(e.paths)]"
/// ).toArray();
/// @END_EXAMPLE_ARANGOSH_OUTPUT
///
/// A route planner example, shortest distance from Munich and Cologne to Olpe:
/// A route planner example, shortest distance from Hamburg and Cologne to Lyon:
///
/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphShortestPaths2}
/// ~ 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_SHORTEST_PATH("
/// |+"'routeplanner', [{_id: 'city/Cologne'},{_id: 'city/Munich'}], 'village/Olpe', " +
/// |+"'routeplanner', [{_id: 'germanCity/Cologne'},{_id: 'germanCity/Munich'}], " +
/// | "'frenchCity/Lyon', " +
/// | "{weight : 'distance'}) RETURN [e.startVertex, e.vertex._id, e.distance, LENGTH(e.paths)]"
/// ).toArray();
/// @END_EXAMPLE_ARANGOSH_OUTPUT
@ -5184,25 +5181,25 @@ function GRAPH_TRAVERSAL (vertexCollection,
///
/// *Examples*
///
/// A route planner example, start a traversal from Munich :
/// A route planner example, start a traversal from Hamburg :
///
/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphTraversal1}
/// ~ 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_TRAVERSAL('routeplanner', 'city/Munich'," +
/// |db._query("FOR e IN GRAPH_TRAVERSAL('routeplanner', 'germanCity/Hamburg'," +
/// | " 'outbound') RETURN e"
/// ).toArray();
/// @END_EXAMPLE_ARANGOSH_OUTPUT
///
/// A route planner example, start a traversal from Munich with a max depth of 1
/// so only the direct neighbors of munich are returned:
/// A route planner example, start a traversal from Hamburg with a max depth of 1
/// so only the direct neighbors of Hamburg are returned:
///
/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphTraversal2}
/// ~ 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_TRAVERSAL('routeplanner', 'city/Munich'," +
/// |db._query("FOR e IN GRAPH_TRAVERSAL('routeplanner', 'germanCity/Hamburg'," +
/// |" 'outbound', {maxDepth : 1}) RETURN e"
/// ).toArray();
/// @END_EXAMPLE_ARANGOSH_OUTPUT
@ -5289,27 +5286,29 @@ function GRAPH_TRAVERSAL_TREE (vertexCollection,
///
/// *Examples*
///
/// A route planner example, distance from all villages to other cities:
/// A route planner example, distance from all french to all german cities:
///
/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphDistanceTo1}
/// ~ 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_DISTANCE_TO("
/// |+"'routeplanner', {}, {}, {weight : 'distance', endVertexCollectionRestriction : 'city', " +
/// |"startVertexCollectionRestriction : 'village'}) RETURN [e.startVertex, e.vertex._id, " +
/// |+"'routeplanner', {}, {}, { " +
/// | " weight : 'distance', endVertexCollectionRestriction : 'germanCity', " +
/// |"startVertexCollectionRestriction : 'frenchCity'}) RETURN [e.startVertex, e.vertex._id, " +
/// | "e.distance]"
/// ).toArray();
/// @END_EXAMPLE_ARANGOSH_OUTPUT
///
/// A route planner example, distance from Munich and Cologne to Olpe:
/// A route planner example, distance from Hambug and Cologne to Lyon:
///
/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphDistanceTo2}
/// ~ 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_DISTANCE_TO("
/// |+"'routeplanner', [{_id: 'city/Cologne'},{_id: 'city/Munich'}], 'village/Olpe', " +
/// | + "'routeplanner', [{_id: 'germanCity/Cologne'},{_id: 'germanCity/Hamburg'}], " +
/// | "'frenchCity/Lyon', " +
/// | "{weight : 'distance'}) RETURN [e.startVertex, e.vertex._id, e.distance]"
/// ).toArray();
/// @END_EXAMPLE_ARANGOSH_OUTPUT
@ -5362,25 +5361,25 @@ function GENERAL_GRAPH_DISTANCE_TO (graphName,
///
/// *Examples*
///
/// A route planner example, start a traversal from Munich :
/// A route planner example, start a traversal from Hamburg :
///
/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphTraversalTree1}
/// ~ 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_TRAVERSAL_TREE('routeplanner', 'city/Munich'," +
/// |db._query("FOR e IN GRAPH_TRAVERSAL_TREE('routeplanner', 'germanCity/Hamburg'," +
/// | " 'outbound', 'connnection') RETURN e"
/// ).toArray();
/// @END_EXAMPLE_ARANGOSH_OUTPUT
///
/// A route planner example, start a traversal from Munich with a max depth of 1 so
/// only the direct neighbors of munich are returned:
/// A route planner example, start a traversal from Hamburg with a max depth of 1 so
/// only the direct neighbors of Hamburg are returned:
///
/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphTraversalTree2}
/// ~ 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_TRAVERSAL_TREE('routeplanner', 'city/Munich',"+
/// |db._query("FOR e IN GRAPH_TRAVERSAL_TREE('routeplanner', 'germanCity/Hamburg',"+
/// | " 'outbound', 'connnection', {maxDepth : 1}) RETURN e"
/// ).toArray();
/// @END_EXAMPLE_ARANGOSH_OUTPUT
@ -5549,14 +5548,14 @@ function GRAPH_NEIGHBORS (vertexCollection,
/// ).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 outbound neighbors of Hamburg with a maximal depth of 2 :
///
/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphNeighbors2}
/// ~ 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_NEIGHBORS("
/// |+"'routeplanner', 'city/Munich', {direction : 'outbound', maxDepth : 2}) RETURN e"
/// |+"'routeplanner', 'germanCity/Hamburg', {direction : 'outbound', maxDepth : 2}) RETURN e"
/// ).toArray();
/// @END_EXAMPLE_ARANGOSH_OUTPUT
///
@ -5671,14 +5670,14 @@ function GENERAL_GRAPH_NEIGHBORS (graphName,
/// ).toArray();
/// @END_EXAMPLE_ARANGOSH_OUTPUT
///
/// A route planner example, all outbound edges of munich with a maximal depth of 2 :
/// A route planner example, all outbound edges of Hamburg with a maximal depth of 2 :
///
/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphEdges2}
/// ~ 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_EDGES("
/// |+"'routeplanner', 'city/Munich', {direction : 'outbound', maxDepth : 2}) RETURN e"
/// |+"'routeplanner', 'germanCity/Hamburg', {direction : 'outbound', maxDepth : 2}) RETURN e"
/// ).toArray();
/// @END_EXAMPLE_ARANGOSH_OUTPUT
///
@ -5746,7 +5745,7 @@ function GENERAL_GRAPH_EDGES (
/// ).toArray();
/// @END_EXAMPLE_ARANGOSH_OUTPUT
///
/// A route planner example, all vertices from collection *city*.
/// A route planner example, all vertices from collection *germanCity*.
///
/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphVertices2}
/// ~ var db = require("internal").db;
@ -5754,7 +5753,7 @@ function GENERAL_GRAPH_EDGES (
/// var g = examples.loadGraph("routeplanner");
/// |db._query("FOR e IN GRAPH_VERTICES("
/// |+"'routeplanner', {}, {direction : 'any', vertexCollectionRestriction" +
/// |" : 'city'}) RETURN e"
/// |" : 'germanCity'}) RETURN e"
/// ).toArray();
/// @END_EXAMPLE_ARANGOSH_OUTPUT
///
@ -5817,36 +5816,9 @@ function TRANSFER_GENERAL_GRAPH_NEIGHBORS_RESULT (result) {
/// 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 *optionsVertex1* : Optional options, see below:
/// * Object *optionsVertex2* : 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 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.
/// This function returns the intersection of *GRAPH_NEIGHBORS(vertex1Example, optionsVertex1)*
/// and *GRAPH_NEIGHBORS(vertex2Example, optionsVertex2)*.
/// For parameter documentation read the documentation of *GRAPH_NEIGHORS*.
///
/// *Examples*
///
@ -5861,7 +5833,7 @@ function TRANSFER_GENERAL_GRAPH_NEIGHBORS_RESULT (result) {
/// ).toArray();
/// @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{generalGraphCommonNeighbors2}
@ -5869,7 +5841,7 @@ function TRANSFER_GENERAL_GRAPH_NEIGHBORS_RESULT (result) {
/// var examples = require("org/arangodb/graph-examples/example-graph.js");
/// var g = examples.loadGraph("routeplanner");
/// |db._query("FOR e IN GRAPH_COMMON_NEIGHBORS("
/// |+"'routeplanner', 'city/Munich', {}, {direction : 'outbound', maxDepth : 2}, "+
/// |+"'routeplanner', 'germanCity/Hamburg', {}, {direction : 'outbound', maxDepth : 2}, "+
/// | "{direction : 'outbound', maxDepth : 2}) RETURN e"
/// ).toArray();
/// @END_EXAMPLE_ARANGOSH_OUTPUT
@ -5985,9 +5957,7 @@ function GENERAL_GRAPH_COMMON_NEIGHBORS (
/// var examples = require("org/arangodb/graph-examples/example-graph.js");
/// var g = examples.loadGraph("routeplanner");
/// |db._query("FOR e IN GRAPH_COMMON_PROPERTIES("
/// |+"'routeplanner', {}, {}, {vertex1CollectionRestriction : 'city', " +
/// | "vertex2CollectionRestriction : 'city'" +
/// |" ,ignoreProperties: 'population'}) RETURN e"
/// |+"'routeplanner', {}, {}, {ignoreProperties: 'population'}) RETURN e"
/// ).toArray();
/// @END_EXAMPLE_ARANGOSH_OUTPUT
///
@ -6143,7 +6113,7 @@ function GENERAL_GRAPH_COMMON_PROPERTIES (
/// ).toArray();
/// @END_EXAMPLE_ARANGOSH_OUTPUT
///
/// A route planner example, the absolute eccentricity of all cities regarding only
/// A route planner example, the absolute eccentricity of all german cities regarding only
/// outbound paths.
///
/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphAbsEccentricity3}
@ -6151,7 +6121,7 @@ function GENERAL_GRAPH_COMMON_PROPERTIES (
/// var examples = require("org/arangodb/graph-examples/example-graph.js");
/// var g = examples.loadGraph("routeplanner");
/// |db._query("RETURN GRAPH_ABSOLUTE_ECCENTRICITY("
/// | + "'routeplanner', {}, {startVertexCollectionRestriction : 'city', " +
/// | + "'routeplanner', {}, {startVertexCollectionRestriction : 'germanCity', " +
/// | "direction : 'outbound', weight : 'distance'})"
/// ).toArray();
/// @END_EXAMPLE_ARANGOSH_OUTPUT
@ -6162,7 +6132,6 @@ function GENERAL_GRAPH_COMMON_PROPERTIES (
function GENERAL_GRAPH_ABSOLUTE_ECCENTRICITY (graphName, vertexExample, options) {
"use strict";
if (! options) {
options = { };
}
@ -6332,7 +6301,7 @@ function GENERAL_GRAPH_ECCENTRICITY (graphName, options) {
/// ).toArray();
/// @END_EXAMPLE_ARANGOSH_OUTPUT
///
/// A route planner example, the absolute closeness of all cities regarding only
/// A route planner example, the absolute closeness of all german cities regarding only
/// outbound paths.
///
/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphAbsCloseness3}
@ -6340,7 +6309,7 @@ function GENERAL_GRAPH_ECCENTRICITY (graphName, options) {
/// var examples = require("org/arangodb/graph-examples/example-graph.js");
/// var g = examples.loadGraph("routeplanner");
/// |db._query("RETURN GRAPH_ABSOLUTE_CLOSENESS("
/// | + "'routeplanner', {}, {startVertexCollectionRestriction : 'city', " +
/// | + "'routeplanner', {}, {startVertexCollectionRestriction : 'germanCity', " +
/// | "direction : 'outbound', weight : 'distance'})"
/// ).toArray();
/// @END_EXAMPLE_ARANGOSH_OUTPUT
@ -6489,7 +6458,7 @@ function GENERAL_GRAPH_CLOSENESS (graphName, options) {
/// 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.
/// hence the betweenness can not be calculated.
///
/// *Examples*
///
@ -6516,7 +6485,7 @@ function GENERAL_GRAPH_CLOSENESS (graphName, options) {
/// ).toArray();
/// @END_EXAMPLE_ARANGOSH_OUTPUT
///
/// A route planner example, the absolute closeness of all cities regarding only
/// A route planner example, the absolute closeness regarding only
/// outbound paths.
///
/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphAbsBetweenness3}
@ -6612,7 +6581,7 @@ function GENERAL_GRAPH_ABSOLUTE_BETWEENNESS (graphName, options) {
/// ).toArray();
/// @END_EXAMPLE_ARANGOSH_OUTPUT
///
/// A route planner example, the closeness of all locations.
/// A route planner example, the betweenness of all locations.
/// This considers the actual distances.
///
/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphBetweenness2}
@ -6624,7 +6593,7 @@ function GENERAL_GRAPH_ABSOLUTE_BETWEENNESS (graphName, options) {
/// ).toArray();
/// @END_EXAMPLE_ARANGOSH_OUTPUT
///
/// A route planner example, the closeness of all cities regarding only
/// A route planner example, the betweenness regarding only
/// outbound paths.
///
/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphBetweenness3}
@ -6711,7 +6680,7 @@ function GENERAL_GRAPH_BETWEENNESS (graphName, options) {
/// ).toArray();
/// @END_EXAMPLE_ARANGOSH_OUTPUT
///
/// A route planner example, the cradius of the graph regarding only
/// A route planner example, the radius of the graph regarding only
/// outbound paths.
///
/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphRadius3}