mirror of https://gitee.com/bigwinds/arangodb
1244 lines
57 KiB
Plaintext
1244 lines
57 KiB
Plaintext
!CHAPTER Graph operations
|
|
|
|
This chapter describes graph related AQL functions.
|
|
|
|
!SUBSECTION Short explanation of the example parameter
|
|
|
|
A lot of the following functions accept a vertex (or edge) example as parameter. This can contain the following:
|
|
|
|
* {} : Returns all possible vertices for this graph
|
|
* *idString* : Returns the vertex/edge with the id *idString*
|
|
* [*idString1*, *idString2* ...] : Returns the vertices/edges with the ids matching the given strings.
|
|
* {*key1* : *value1*, *key2* : *value2*} : Returns the vertices/edges that match this example, which means that both have *key1* and *key2* with the corresponding attributes
|
|
* {*key1.key2* : *value1*, *key3* : *value2*} : It is possible to chain keys, which means that a document *{key1 : {key2 : value1}, key3 : value2}* would be a match
|
|
* [{*key1* : *value1*}, {*key2* : *value2*}] : Returns the vertices/edges that match one of the examples, which means that either *key1* or *key2* are set with the corresponding value
|
|
|
|
!SUBSECTION The complexity of the shortest path algorithms
|
|
|
|
Most of the functions described in this chapter calculate the shortest paths for subsets of the graphs vertices.
|
|
Hence the complexity of these functions depends of the chosen algorithm for this task. For
|
|
[Floyd-Warshall](http://en.wikipedia.org/wiki/Floyd%E2%80%93Warshall_algorithm) it is **O(n^3)**
|
|
with *n* being the amount of vertices in the graph. For
|
|
[Dijkstra](http://en.wikipedia.org/wiki/Dijkstra's_algorithm) it would be **O(x\*y\*n^2)** with *n* being
|
|
the amount of vertices in the graph, *x* the amount of start vertices and *y* the amount of
|
|
target vertices. Hence a suggestion may be to use Dijkstra when x\*y < n and the functions supports choosing your algorithm.
|
|
|
|
!SUBSECTION Example Graph
|
|
All examples in this chapter will use [this simple city graph](../Graphs/README.md#the-city-graph):
|
|
|
|

|
|
|
|
!SUBSECTION Edges and Vertices related functions
|
|
|
|
This section describes various AQL functions which can be used to receive information about the graph's vertices, edges, neighbor relationship and shared properties.
|
|
|
|
!SUBSECTION GRAPH_EDGES
|
|
<!-- js/server/modules/@arangodb/aql.js -->
|
|
|
|
|
|
`GRAPH_EDGES (graphName, vertexExample, options)`
|
|
|
|
The GRAPH\_EDGES function returns all edges of the graph connected to the vertices
|
|
defined by the example.
|
|
|
|
The complexity of this method is **O(n\*m^x)** with *n* being the vertices defined by the
|
|
parameter vertexExamplex, *m* the average amount of edges of a vertex and *x* the maximal
|
|
depths.
|
|
Hence the default call would have a complexity of **O(n\*m)**;
|
|
|
|
*Parameters*
|
|
|
|
* *graphName* : The name of the graph as a string.
|
|
* *vertexExample* : An example for the desired
|
|
vertices (see [example](#short-explanation-of-the-example-parameter)).
|
|
* *options* (optional) : An object containing the following options:
|
|
* *direction* : The direction of the edges as a string. Possible values are *outbound*, *inbound* and *any* (default).
|
|
* *edgeCollectionRestriction* : One or multiple edge collection names. Only edges from these collections will be considered for the path.
|
|
* *startVertexCollectionRestriction* : One or multiple vertex collection names. Only vertices from these collections will be considered as
|
|
start vertex of a path.
|
|
* *endVertexCollectionRestriction* : One or multiple vertex collection names. Only vertices from these collections will be considered as end vertex of a path.
|
|
* *edgeExamples* : A filter example for the edges (see [example](#short-explanation-of-the-example-parameter)).
|
|
* *minDepth* : Defines the minimal length of a path from an edge to a vertex
|
|
(default is 1, which means only the edges directly connected to a vertex would be returned).
|
|
* *maxDepth* : Defines the maximal length of a path from an edge
|
|
to a vertex (default is 1, which means only the edges directly connected to a vertex would be returned).
|
|
* *maxIterations*: the maximum number of iterations that the traversal is allowed to perform. It is sensible to set this number so unbounded traversals will terminate.
|
|
* *includeData*: Defines if the result should contain only ids (false) or if all documents
|
|
should be fully extracted (true). By default this parameter is set to false, so only ids
|
|
will be returned.
|
|
|
|
@EXAMPLES
|
|
|
|
A route planner example, all edges to locations with a distance of either 700 or 600.:
|
|
|
|
@startDocuBlockInline generalGraphEdges1
|
|
@EXAMPLE_ARANGOSH_OUTPUT{generalGraphEdges1}
|
|
var examples = require("@arangodb/graph-examples/example-graph.js");
|
|
var g = examples.loadGraph("routeplanner");
|
|
| db._query("FOR e IN GRAPH_EDGES("
|
|
| +"'routeplanner', {}, {edgeExamples : [{distance: 600}, {distance: 700}]}) RETURN e"
|
|
).toArray();
|
|
~ examples.dropGraph("routeplanner");
|
|
@END_EXAMPLE_ARANGOSH_OUTPUT
|
|
@endDocuBlock generalGraphEdges1
|
|
|
|
A route planner example, all outbound edges of Hamburg with a maximal depth of 2 :
|
|
|
|
@startDocuBlockInline generalGraphEdges2
|
|
@EXAMPLE_ARANGOSH_OUTPUT{generalGraphEdges2}
|
|
var examples = require("@arangodb/graph-examples/example-graph.js");
|
|
var g = examples.loadGraph("routeplanner");
|
|
| db._query("FOR e IN GRAPH_EDGES("
|
|
| +"'routeplanner', 'germanCity/Hamburg', {direction : 'outbound', maxDepth : 2}) RETURN e"
|
|
).toArray();
|
|
~ examples.dropGraph("routeplanner");
|
|
@END_EXAMPLE_ARANGOSH_OUTPUT
|
|
@endDocuBlock generalGraphEdges2
|
|
|
|
Including the data:
|
|
|
|
@startDocuBlockInline generalGraphEdges3
|
|
@EXAMPLE_ARANGOSH_OUTPUT{generalGraphEdges3}
|
|
var examples = require("@arangodb/graph-examples/example-graph.js");
|
|
var g = examples.loadGraph("routeplanner");
|
|
| db._query("FOR e IN GRAPH_EDGES("
|
|
| + "'routeplanner', 'germanCity/Hamburg', {direction : 'outbound',"
|
|
| + "maxDepth : 2, includeData: true}) RETURN e"
|
|
).toArray();
|
|
~ examples.dropGraph("routeplanner");
|
|
@END_EXAMPLE_ARANGOSH_OUTPUT
|
|
@endDocuBlock generalGraphEdges3
|
|
|
|
|
|
!SUBSECTION GRAPH_VERTICES
|
|
<!-- js/server/modules/@arangodb/aql.js -->
|
|
|
|
|
|
|
|
The GRAPH\_VERTICES function returns all vertices.
|
|
|
|
`GRAPH_VERTICES (graphName, vertexExample, options)`
|
|
|
|
According to the optional filters it will only return vertices that have
|
|
outbound, inbound or any (default) edges.
|
|
|
|
*Parameters*
|
|
|
|
* *graphName* : The name of the graph as a string.
|
|
* *vertexExample* : An example for the desired vertices (see [example](#short-explanation-of-the-example-parameter)).
|
|
* *options* (optional) : An object containing the following options:
|
|
* *direction* : The direction of the edges as a string. Possible values are *outbound*, *inbound* and *any* (default).
|
|
* *vertexCollectionRestriction* : One or multiple vertex collections that should be considered.
|
|
|
|
@EXAMPLES
|
|
|
|
A route planner example, all vertices of the graph
|
|
|
|
@startDocuBlockInline generalGraphVertices1
|
|
@EXAMPLE_ARANGOSH_OUTPUT{generalGraphVertices1}
|
|
var examples = require("@arangodb/graph-examples/example-graph.js");
|
|
var g = examples.loadGraph("routeplanner");
|
|
| db._query("FOR e IN GRAPH_VERTICES("
|
|
+"'routeplanner', {}) RETURN e").toArray();
|
|
~ examples.dropGraph("routeplanner");
|
|
@END_EXAMPLE_ARANGOSH_OUTPUT
|
|
@endDocuBlock generalGraphVertices1
|
|
|
|
A route planner example, all vertices from collection *germanCity*.
|
|
|
|
@startDocuBlockInline generalGraphVertices2
|
|
@EXAMPLE_ARANGOSH_OUTPUT{generalGraphVertices2}
|
|
var examples = require("@arangodb/graph-examples/example-graph.js");
|
|
var g = examples.loadGraph("routeplanner");
|
|
| db._query("FOR e IN GRAPH_VERTICES("
|
|
| +"'routeplanner', {}, {direction : 'any', vertexCollectionRestriction" +
|
|
" : 'germanCity'}) RETURN e").toArray();
|
|
~ examples.dropGraph("routeplanner");
|
|
@END_EXAMPLE_ARANGOSH_OUTPUT
|
|
@endDocuBlock generalGraphVertices2
|
|
|
|
|
|
|
|
!SUBSECTION GRAPH_NEIGHBORS
|
|
<!-- js/server/modules/@arangodb/aql.js -->
|
|
|
|
|
|
|
|
The GRAPH\_NEIGHBORS function returns all neighbors of vertices.
|
|
|
|
`GRAPH_NEIGHBORS (graphName, vertexExample, options)`
|
|
|
|
By default only the direct neighbors (path length equals 1) are returned, but one can define
|
|
the range of the path length to the neighbors with the options *minDepth* and *maxDepth*.
|
|
The complexity of this method is **O(n\*m^x)** with *n* being the vertices defined by the
|
|
parameter vertexExamplex, *m* the average amount of neighbors and *x* the maximal depths.
|
|
Hence the default call would have a complexity of **O(n\*m)**;
|
|
|
|
*Parameters*
|
|
|
|
* *graphName* : The name of the graph as a string.
|
|
* *vertexExample* : An example for the desired vertices (see [example](#short-explanation-of-the-example-parameter)).
|
|
* *options* : An object containing the following options:
|
|
* *direction* : The direction of the edges. Possible values are *outbound*, *inbound* and *any* (default).
|
|
* *edgeExamples* : A filter example for the edges to the neighbors (see [example](#short-explanation-of-the-example-parameter)).
|
|
* *neighborExamples* : An example for the desired neighbors (see [example](#short-explanation-of-the-example-parameter)).
|
|
* *edgeCollectionRestriction* : One or multiple edge collection names. Only edges from these collections will be considered for the path.
|
|
* *vertexCollectionRestriction* : One or multiple vertex collection names. Only vertices from these collections will be contained in the
|
|
result. This does not effect vertices on the path.
|
|
* *minDepth* : Defines the minimal depth a path to a neighbor must have to be returned (default is 1).
|
|
* *maxDepth* : Defines the maximal depth a path to a neighbor must have to be returned (default is 1).
|
|
* *maxIterations*: the maximum number of iterations that the traversal is
|
|
allowed to perform. It is sensible to set this number so unbounded traversals
|
|
will terminate at some point.
|
|
* *includeData* is a boolean value to define if the returned documents should be extracted
|
|
instead of returning their ids only. The default is *false*.
|
|
|
|
Note: in ArangoDB versions prior to 2.6 *NEIGHBORS* returned the array of neighbor vertices with
|
|
all attributes and not just the vertex ids. To return to the same behavior, set the *includeData*
|
|
option to *true* in 2.6 and above.
|
|
|
|
@EXAMPLES
|
|
|
|
A route planner example, all neighbors of locations with a distance of either
|
|
700 or 600.:
|
|
|
|
@startDocuBlockInline generalGraphNeighbors1
|
|
@EXAMPLE_ARANGOSH_OUTPUT{generalGraphNeighbors1}
|
|
var examples = require("@arangodb/graph-examples/example-graph.js");
|
|
var g = examples.loadGraph("routeplanner");
|
|
| db._query("FOR e IN GRAPH_NEIGHBORS("
|
|
| +"'routeplanner', {}, {edgeExamples : [{distance: 600}, {distance: 700}]}) RETURN e"
|
|
).toArray();
|
|
~ examples.dropGraph("routeplanner");
|
|
@END_EXAMPLE_ARANGOSH_OUTPUT
|
|
@endDocuBlock generalGraphNeighbors1
|
|
|
|
A route planner example, all outbound neighbors of Hamburg with a maximal depth of 2 :
|
|
|
|
@startDocuBlockInline generalGraphNeighbors2
|
|
@EXAMPLE_ARANGOSH_OUTPUT{generalGraphNeighbors2}
|
|
var examples = require("@arangodb/graph-examples/example-graph.js");
|
|
var g = examples.loadGraph("routeplanner");
|
|
| db._query("FOR e IN GRAPH_NEIGHBORS("
|
|
| +"'routeplanner', 'germanCity/Hamburg', {direction : 'outbound', maxDepth : 2}) RETURN e"
|
|
).toArray();
|
|
~ examples.dropGraph("routeplanner");
|
|
@END_EXAMPLE_ARANGOSH_OUTPUT
|
|
@endDocuBlock generalGraphNeighbors2
|
|
|
|
|
|
|
|
!SUBSECTION GRAPH_COMMON_NEIGHBORS
|
|
<!-- js/server/modules/@arangodb/aql.js -->
|
|
|
|
|
|
|
|
The GRAPH\_COMMON\_NEIGHBORS function returns all common neighbors of the vertices
|
|
defined by the examples.
|
|
|
|
`GRAPH_COMMON_NEIGHBORS (graphName, vertex1Example, vertex2Examples,
|
|
optionsVertex1, optionsVertex2)`
|
|
|
|
This function returns the intersection of *GRAPH_NEIGHBORS(vertex1Example, optionsVertex1)*
|
|
and *GRAPH_NEIGHBORS(vertex2Example, optionsVertex2)*.
|
|
The complexity of this method is **O(n\*m^x)** with *n* being the maximal amount of vertices
|
|
defined by the parameters vertexExamples, *m* the average amount of neighbors and *x* the
|
|
maximal depths.
|
|
Hence the default call would have a complexity of **O(n\*m)**;
|
|
|
|
For parameter documentation read the documentation of
|
|
[GRAPH_NEIGHBORS](#graphneighbors).
|
|
|
|
@EXAMPLES
|
|
|
|
A route planner example, all common neighbors of capitals.
|
|
|
|
@startDocuBlockInline generalGraphCommonNeighbors1
|
|
@EXAMPLE_ARANGOSH_OUTPUT{generalGraphCommonNeighbors1}
|
|
var examples = require("@arangodb/graph-examples/example-graph.js");
|
|
var g = examples.loadGraph("routeplanner");
|
|
| db._query("FOR e IN GRAPH_COMMON_NEIGHBORS("
|
|
| +"'routeplanner', {isCapital : true}, {isCapital : true}) RETURN e"
|
|
).toArray();
|
|
~ examples.dropGraph("routeplanner");
|
|
@END_EXAMPLE_ARANGOSH_OUTPUT
|
|
@endDocuBlock generalGraphCommonNeighbors1
|
|
|
|
A route planner example, all common outbound neighbors of Hamburg with any other location
|
|
which have a maximal depth of 2:
|
|
|
|
@startDocuBlockInline generalGraphCommonNeighbors2
|
|
@EXAMPLE_ARANGOSH_OUTPUT{generalGraphCommonNeighbors2}
|
|
var examples = require("@arangodb/graph-examples/example-graph.js");
|
|
var g = examples.loadGraph("routeplanner");
|
|
| db._query("FOR e IN GRAPH_COMMON_NEIGHBORS("
|
|
| +"'routeplanner', 'germanCity/Hamburg', {}, {direction : 'outbound', maxDepth : 2}, "+
|
|
| "{direction : 'outbound', maxDepth : 2}) RETURN e"
|
|
).toArray();
|
|
~ examples.dropGraph("routeplanner");
|
|
@END_EXAMPLE_ARANGOSH_OUTPUT
|
|
@endDocuBlock generalGraphCommonNeighbors2
|
|
|
|
|
|
|
|
!SUBSECTION GRAPH_COMMON_PROPERTIES
|
|
<!-- js/server/modules/@arangodb/aql.js -->
|
|
|
|
|
|
|
|
|
|
`GRAPH_COMMON_PROPERTIES (graphName, vertex1Example, vertex2Examples, options)`
|
|
|
|
The GRAPH\_COMMON\_PROPERTIES function returns a list of objects which have the id of
|
|
the vertices defined by *vertex1Example* as keys and a list of vertices defined by
|
|
*vertex21Example*, that share common properties as value. Notice that only the
|
|
vertex id and the matching attributes are returned in the result.
|
|
|
|
The complexity of this method is **O(n)** with *n* being the maximal amount of vertices
|
|
defined by the parameters vertexExamples.
|
|
|
|
*Parameters*
|
|
|
|
* *graphName* : The name of the graph as a string.
|
|
* *vertex1Example* : An example for the desired vertices (see [example](#short-explanation-of-the-example-parameter)).
|
|
* *vertex2Example* : An example for the desired vertices (see [example](#short-explanation-of-the-example-parameter)).
|
|
* *options* (optional) : An object containing the following options:
|
|
* *vertex1CollectionRestriction* : One or multiple vertex collection names. Only vertices from these collections will be considered.
|
|
* *vertex2CollectionRestriction* : One or multiple vertex collection names. Only vertices from these collections will be considered.
|
|
* *ignoreProperties* : One or multiple attributes of a document that should be ignored, either a string or an array..
|
|
|
|
@EXAMPLES
|
|
|
|
A route planner example, all locations with the same properties:
|
|
|
|
@startDocuBlockInline generalGraphProperties1
|
|
@EXAMPLE_ARANGOSH_OUTPUT{generalGraphProperties1}
|
|
var examples = require("@arangodb/graph-examples/example-graph.js");
|
|
var g = examples.loadGraph("routeplanner");
|
|
| db._query("FOR e IN GRAPH_COMMON_PROPERTIES("
|
|
| +"'routeplanner', {}, {}) RETURN e"
|
|
).toArray();
|
|
~ examples.dropGraph("routeplanner");
|
|
@END_EXAMPLE_ARANGOSH_OUTPUT
|
|
@endDocuBlock generalGraphProperties1
|
|
|
|
A route planner example, all cities which share same properties except for population.
|
|
|
|
@startDocuBlockInline generalGraphProperties2
|
|
@EXAMPLE_ARANGOSH_OUTPUT{generalGraphProperties2}
|
|
var examples = require("@arangodb/graph-examples/example-graph.js");
|
|
var g = examples.loadGraph("routeplanner");
|
|
| db._query("FOR e IN GRAPH_COMMON_PROPERTIES("
|
|
| +"'routeplanner', {}, {}, {ignoreProperties: 'population'}) RETURN e"
|
|
).toArray();
|
|
~ examples.dropGraph("routeplanner");
|
|
@END_EXAMPLE_ARANGOSH_OUTPUT
|
|
@endDocuBlock generalGraphProperties2
|
|
|
|
|
|
|
|
!SUBSECTION Shortest Paths, distances and traversals.
|
|
<!-- js/server/modules/@arangodb/aql.js -->
|
|
|
|
This section describes AQL functions, that calculate paths from a subset of vertices in a graph to another subset of vertices.
|
|
|
|
!SUBSECTION GRAPH_PATHS
|
|
<!-- js/server/modules/@arangodb/aql.js -->
|
|
|
|
|
|
|
|
The GRAPH\_PATHS function returns all paths of a graph.
|
|
|
|
`GRAPH_PATHS (graphName, options)`
|
|
|
|
The complexity of this method is **O(n\*n\*m)** with *n* being the amount of vertices in
|
|
the graph and *m* the average amount of connected edges;
|
|
|
|
*Parameters*
|
|
|
|
* *graphName* : The name of the graph as a string.
|
|
* *options* : An object containing the following options:
|
|
* *direction* : The direction of the edges. Possible values are *any*, *inbound* and *outbound* (default).
|
|
* *followCycles* (optional) : If set to *true* the query follows cycles in the graph, default is false.
|
|
* *minLength* (optional) : Defines the minimal length a path must have to be returned (default is 0).
|
|
* *maxLength* (optional) : Defines the maximal length a path must have to be returned (default is 10).
|
|
|
|
@EXAMPLES
|
|
|
|
Return all paths of the graph "social":
|
|
|
|
@startDocuBlockInline generalGraphPaths
|
|
@EXAMPLE_ARANGOSH_OUTPUT{generalGraphPaths}
|
|
var examples = require("@arangodb/graph-examples/example-graph.js");
|
|
var g = examples.loadGraph("social");
|
|
db._query("RETURN GRAPH_PATHS('social')").toArray();
|
|
~ examples.dropGraph("social");
|
|
@END_EXAMPLE_ARANGOSH_OUTPUT
|
|
@endDocuBlock generalGraphPaths
|
|
|
|
Return all inbound paths of the graph "social" with a maximal
|
|
length of 1 and a minimal length of 2:
|
|
|
|
@startDocuBlockInline generalGraphPaths2
|
|
@EXAMPLE_ARANGOSH_OUTPUT{generalGraphPaths2}
|
|
var examples = require("@arangodb/graph-examples/example-graph.js");
|
|
var g = examples.loadGraph("social");
|
|
| db._query(
|
|
| "RETURN GRAPH_PATHS('social', {direction : 'inbound', minLength : 1, maxLength : 2})"
|
|
).toArray();
|
|
~ examples.dropGraph("social");
|
|
@END_EXAMPLE_ARANGOSH_OUTPUT
|
|
@endDocuBlock generalGraphPaths2
|
|
|
|
|
|
!SUBSECTION GRAPH_SHORTEST_PATH
|
|
<!-- js/server/modules/@arangodb/aql.js -->
|
|
|
|
|
|
|
|
The GRAPH\_SHORTEST\_PATH function returns all shortest paths of a graph.
|
|
|
|
`GRAPH_SHORTEST_PATH (graphName, startVertexExample, endVertexExample, options)`
|
|
|
|
This function determines all shortest paths in a graph identified by *graphName*.
|
|
If one wants to call this function to receive nearly all shortest paths for a
|
|
graph the option *algorithm* should be set to
|
|
[Floyd-Warshall](http://en.wikipedia.org/wiki/Floyd%E2%80%93Warshall_algorithm) to
|
|
increase performance.
|
|
If no algorithm is provided in the options the function chooses the appropriate
|
|
one (either [Floyd-Warshall](http://en.wikipedia.org/wiki/Floyd%E2%80%93Warshall_algorithm)
|
|
or [Dijkstra](http://en.wikipedia.org/wiki/Dijkstra's_algorithm)) according to its parameters.
|
|
The length of a path is by default the amount of edges from one start vertex to
|
|
an end vertex. The option weight allows the user to define an edge attribute
|
|
representing the length.
|
|
|
|
The complexity of the function is described
|
|
[here](#the-complexity-of-the-shortest-path-algorithms).
|
|
|
|
*Parameters*
|
|
|
|
* *graphName* : The name of the graph as a string.
|
|
* *startVertexExample* : An example for the desired start Vertices (see [example](#short-explanation-of-the-example-parameter)).
|
|
* *endVertexExample* : An example for the desired end Vertices (see [example](#short-explanation-of-the-example-parameter)).
|
|
* *options* (optional) : An object containing the following options:
|
|
* *direction* : The direction of the edges as a string. Possible values are *outbound*, *inbound* and *any* (default).
|
|
* *edgeCollectionRestriction* : One or multiple edge collection names. Only edges from these collections will be considered for the path.
|
|
* *startVertexCollectionRestriction* : One or multiple vertex collection names. Only vertices from these collections will be considered as
|
|
start vertex of a path.
|
|
* *endVertexCollectionRestriction* : One or multiple vertex collection names. Only vertices from these collections will be considered as
|
|
end vertex of a path.
|
|
* *edgeExamples* : A filter example for the edges in the shortest paths (see [example](#short-explanation-of-the-example-parameter)).
|
|
* *algorithm* : The algorithm to calculate
|
|
the shortest paths. If both start and end vertex examples are empty
|
|
[Floyd-Warshall](http://en.wikipedia.org/wiki/Floyd%E2%80%93Warshall_algorithm) is
|
|
used, otherwise the default is [Dijkstra](http://en.wikipedia.org/wiki/Dijkstra's_algorithm).
|
|
* *weight* : The name of the attribute of the edges containing the length as a string.
|
|
* *defaultWeight* : Only used with the option *weight*.
|
|
If an edge does not have the attribute named as defined in option *weight* this default is used as length.
|
|
If no default is supplied the default would be positive Infinity so the path could not be calculated.
|
|
* *stopAtFirstMatch* : Only useful if targetVertices is an example that matches
|
|
to more than one vertex. If so only the shortest path to
|
|
the closest of these target vertices is returned.
|
|
This flag is of special use if you have target pattern and
|
|
you want to know which vertex with this pattern is matched first.
|
|
* *includeData* : Triggers if only *_id*'s are returned (*false*, default)
|
|
or if data is included for all objects as well (*true*)
|
|
This will modify the content of *vertex*, *path.vertices* and *path.edges*.
|
|
|
|
NOTE: Since version 2.6 we have included a new optional parameter *includeData*.
|
|
This parameter triggers if the result contains the real data object *true* or
|
|
it just includes the *_id* values *false*.
|
|
The default value is *false* as it yields performance benefits.
|
|
|
|
@EXAMPLES
|
|
|
|
A route planner example, shortest distance from all german to all french cities:
|
|
|
|
@startDocuBlockInline generalGraphShortestPaths1
|
|
@EXAMPLE_ARANGOSH_OUTPUT{generalGraphShortestPaths1}
|
|
var examples = require("@arangodb/graph-examples/example-graph.js");
|
|
var g = examples.loadGraph("routeplanner");
|
|
| db._query("FOR e IN GRAPH_SHORTEST_PATH("
|
|
| + "'routeplanner', {}, {}, {" +
|
|
| "weight : 'distance', endVertexCollectionRestriction : 'frenchCity', " +
|
|
| "includeData: true, " +
|
|
| "startVertexCollectionRestriction : 'germanCity'}) RETURN [e.startVertex, e.vertex._id, " +
|
|
| "e.distance, LENGTH(e.paths)]"
|
|
).toArray();
|
|
~ examples.dropGraph("routeplanner");
|
|
@END_EXAMPLE_ARANGOSH_OUTPUT
|
|
@endDocuBlock generalGraphShortestPaths1
|
|
|
|
A route planner example, shortest distance from Hamburg and Cologne to Lyon:
|
|
|
|
@startDocuBlockInline generalGraphShortestPaths2
|
|
@EXAMPLE_ARANGOSH_OUTPUT{generalGraphShortestPaths2}
|
|
var examples = require("@arangodb/graph-examples/example-graph.js");
|
|
var g = examples.loadGraph("routeplanner");
|
|
| db._query("FOR e IN GRAPH_SHORTEST_PATH("
|
|
| +"'routeplanner', [{_id: 'germanCity/Cologne'},{_id: 'germanCity/Munich'}], " +
|
|
| "'frenchCity/Lyon', " +
|
|
| "{weight : 'distance'}) RETURN [e.startVertex, e.vertex, e.distance, LENGTH(e.paths)]"
|
|
).toArray();
|
|
~ examples.dropGraph("routeplanner");
|
|
@END_EXAMPLE_ARANGOSH_OUTPUT
|
|
@endDocuBlock generalGraphShortestPaths2
|
|
|
|
|
|
|
|
!SUBSECTION GRAPH_TRAVERSAL
|
|
<!-- js/server/modules/@arangodb/aql.js -->
|
|
|
|
|
|
|
|
The GRAPH\_TRAVERSAL function traverses through the graph.
|
|
|
|
`GRAPH_TRAVERSAL (graphName, startVertexExample, direction, options)`
|
|
|
|
This function performs traversals on the given graph.
|
|
|
|
The complexity of this function strongly depends on the usage.
|
|
|
|
*Parameters*
|
|
* *graphName* : The name of the graph as a string.
|
|
* *startVertexExample* : An example for the desired vertices (see [example](#short-explanation-of-the-example-parameter)).
|
|
* *direction* : The direction of the edges as a string. Possible values are *outbound*, *inbound* and *any* (default).
|
|
* *options*: Object containing optional options.
|
|
|
|
*Options*:
|
|
|
|
* *strategy*: determines the visitation strategy. Possible values are *depthfirst* and *breadthfirst*. Default is *breadthfirst*.
|
|
* *order*: determines the visitation order. Possible values are *preorder* and *postorder*.
|
|
* *itemOrder*: determines the order in which connections returned by the expander will be processed. Possible values are *forward* and *backward*.
|
|
* *maxDepth*: if set to a value greater than *0*, this will limit the traversal to this maximum depth.
|
|
* *minDepth*: if set to a value greater than *0*, all vertices found on a level below the *minDepth* level will not be included in the result.
|
|
* *maxIterations*: the maximum number of iterations that the traversal is allowed to perform. It is sensible to set this number so unbounded traversals
|
|
will terminate at some point.
|
|
* *uniqueness*: an object that defines how repeated visitations of vertices should
|
|
be handled. The *uniqueness* object can have a sub-attribute *vertices*, and a
|
|
sub-attribute *edges*. Each sub-attribute can have one of the following values:
|
|
* *"none"*: no uniqueness constraints
|
|
* *"path"*: element is excluded if it is already contained in the current path.
|
|
This setting may be sensible for graphs that contain cycles (e.g. A -> B -> C -> A).
|
|
* *"global"*: element is excluded if it was already found/visited at any point during the traversal.
|
|
* *filterVertices* An optional array of example vertex documents that the traversal will treat specially.
|
|
If no examples are given, the traversal will handle all encountered vertices equally.
|
|
If one or many vertex examples are given, the traversal will exclude any non-matching vertex from the
|
|
result and/or not descend into it. Optionally, filterVertices can contain a string containing the name
|
|
of a user-defined AQL function that should be responsible for filtering.
|
|
If so, the AQL function is expected to have the following signature:
|
|
|
|
`function (config, vertex, path)`
|
|
|
|
If a custom AQL function is used for filterVertices, it is expected to return one of the following values:
|
|
|
|
* [ ]: Include the vertex in the result and descend into its connected edges
|
|
* [ "prune" ]: Will include the vertex in the result but not descend into its connected edges
|
|
* [ "exclude" ]: Will not include the vertex in the result but descend into its connected edges
|
|
* [ "prune", "exclude" ]: Will completely ignore the vertex and its connected edges
|
|
|
|
* *vertexFilterMethod:* Only useful in conjunction with filterVertices and if no user-defined AQL function is used.
|
|
If specified, it will influence how vertices are handled that don't match the examples in filterVertices:
|
|
|
|
* [ "prune" ]: Will include non-matching vertices in the result but not descend into them
|
|
* [ "exclude" ]: Will not include non-matching vertices in the result but descend into them
|
|
* [ "prune", "exclude" ]: Will completely ignore the vertex and its connected edges
|
|
|
|
@EXAMPLES
|
|
|
|
A route planner example, start a traversal from Hamburg :
|
|
|
|
@startDocuBlockInline generalGraphTraversal1
|
|
@EXAMPLE_ARANGOSH_OUTPUT{generalGraphTraversal1}
|
|
var examples = require("@arangodb/graph-examples/example-graph.js");
|
|
var g = examples.loadGraph("routeplanner");
|
|
| db._query("FOR e IN GRAPH_TRAVERSAL('routeplanner', 'germanCity/Hamburg'," +
|
|
| " 'outbound') RETURN e"
|
|
).toArray();
|
|
~ examples.dropGraph("routeplanner");
|
|
@END_EXAMPLE_ARANGOSH_OUTPUT
|
|
@endDocuBlock generalGraphTraversal1
|
|
|
|
A route planner example, start a traversal from Hamburg with a max depth of 1
|
|
so only the direct neighbors of Hamburg are returned:
|
|
|
|
@startDocuBlockInline generalGraphTraversal2
|
|
@EXAMPLE_ARANGOSH_OUTPUT{generalGraphTraversal2}
|
|
var examples = require("@arangodb/graph-examples/example-graph.js");
|
|
var g = examples.loadGraph("routeplanner");
|
|
| db._query("FOR e IN GRAPH_TRAVERSAL('routeplanner', 'germanCity/Hamburg'," +
|
|
| " 'outbound', {maxDepth : 1}) RETURN e"
|
|
).toArray();
|
|
~ examples.dropGraph("routeplanner");
|
|
@END_EXAMPLE_ARANGOSH_OUTPUT
|
|
@endDocuBlock generalGraphTraversal2
|
|
|
|
|
|
|
|
!SUBSECTION GRAPH_TRAVERSAL_TREE
|
|
<!-- js/server/modules/@arangodb/aql.js -->
|
|
|
|
|
|
|
|
The GRAPH\_TRAVERSAL\_TREE function traverses through the graph.
|
|
|
|
`GRAPH_TRAVERSAL_TREE (graphName, startVertexExample, direction, connectName, options)`
|
|
This function creates a tree format from the result for a better visualization of the path.
|
|
This function performs traversals on the given graph.
|
|
|
|
The complexity of this function strongly depends on the usage.
|
|
|
|
*Parameters*
|
|
|
|
* *graphName* : The name of the graph as a string.
|
|
* *startVertexExample* : An example for the desired
|
|
vertices (see [example](#short-explanation-of-the-example-parameter)).
|
|
* *direction* : The direction of the edges as a string.
|
|
Possible values are *outbound*, *inbound* and *any* (default).
|
|
* *connectName* : The result attribute which
|
|
contains the connection.
|
|
* *options* (optional) : An object containing options, see
|
|
[Graph Traversals](../Aql/GraphOperations.md#graphtraversal):
|
|
|
|
@EXAMPLES
|
|
|
|
A route planner example, start a traversal from Hamburg :
|
|
|
|
@startDocuBlockInline generalGraphTraversalTree1
|
|
@EXAMPLE_ARANGOSH_OUTPUT{generalGraphTraversalTree1}
|
|
var examples = require("@arangodb/graph-examples/example-graph.js");
|
|
var g = examples.loadGraph("routeplanner");
|
|
| db._query("FOR e IN GRAPH_TRAVERSAL_TREE('routeplanner', 'germanCity/Hamburg'," +
|
|
| " 'outbound', 'connnection') RETURN e"
|
|
).toArray();
|
|
~ examples.dropGraph("routeplanner");
|
|
@END_EXAMPLE_ARANGOSH_OUTPUT
|
|
@endDocuBlock generalGraphTraversalTree1
|
|
|
|
A route planner example, start a traversal from Hamburg with a max depth of 1 so
|
|
only the direct neighbors of Hamburg are returned:
|
|
|
|
@startDocuBlockInline generalGraphTraversalTree2
|
|
@EXAMPLE_ARANGOSH_OUTPUT{generalGraphTraversalTree2}
|
|
var examples = require("@arangodb/graph-examples/example-graph.js");
|
|
var g = examples.loadGraph("routeplanner");
|
|
| db._query("FOR e IN GRAPH_TRAVERSAL_TREE('routeplanner', 'germanCity/Hamburg',"+
|
|
| " 'outbound', 'connnection', {maxDepth : 1}) RETURN e"
|
|
).toArray();
|
|
~ examples.dropGraph("routeplanner");
|
|
@END_EXAMPLE_ARANGOSH_OUTPUT
|
|
@endDocuBlock generalGraphTraversalTree2
|
|
|
|
|
|
|
|
!SUBSECTION GRAPH_DISTANCE_TO
|
|
<!-- js/server/modules/@arangodb/aql.js -->
|
|
|
|
|
|
|
|
The GRAPH\_DISTANCE\_TO function returns all paths and there distance within a graph.
|
|
|
|
`GRAPH_DISTANCE_TO (graphName, startVertexExample, endVertexExample, options)`
|
|
|
|
This function is a wrapper of [GRAPH\_SHORTEST\_PATH](#graphshortestpath).
|
|
It does not return the actual path but only the distance between two vertices.
|
|
|
|
@EXAMPLES
|
|
|
|
A route planner example, distance from all french to all german cities:
|
|
|
|
@startDocuBlockInline generalGraphDistanceTo1
|
|
@EXAMPLE_ARANGOSH_OUTPUT{generalGraphDistanceTo1}
|
|
var examples = require("@arangodb/graph-examples/example-graph.js");
|
|
var g = examples.loadGraph("routeplanner");
|
|
| db._query("FOR e IN GRAPH_DISTANCE_TO("
|
|
| +"'routeplanner', {}, {}, { " +
|
|
| " weight : 'distance', endVertexCollectionRestriction : 'germanCity', " +
|
|
| "startVertexCollectionRestriction : 'frenchCity'}) RETURN [e.startVertex, e.vertex, " +
|
|
| "e.distance]"
|
|
).toArray();
|
|
~ examples.dropGraph("routeplanner");
|
|
@END_EXAMPLE_ARANGOSH_OUTPUT
|
|
@endDocuBlock generalGraphDistanceTo1
|
|
|
|
A route planner example, distance from Hamburg and Cologne to Lyon:
|
|
|
|
@startDocuBlockInline generalGraphDistanceTo2
|
|
@EXAMPLE_ARANGOSH_OUTPUT{generalGraphDistanceTo2}
|
|
var examples = require("@arangodb/graph-examples/example-graph.js");
|
|
var g = examples.loadGraph("routeplanner");
|
|
| db._query("FOR e IN GRAPH_DISTANCE_TO("
|
|
| + "'routeplanner', [{_id: 'germanCity/Cologne'},{_id: 'germanCity/Hamburg'}], " +
|
|
| "'frenchCity/Lyon', " +
|
|
| "{weight : 'distance'}) RETURN [e.startVertex, e.vertex, e.distance]"
|
|
).toArray();
|
|
~ examples.dropGraph("routeplanner");
|
|
@END_EXAMPLE_ARANGOSH_OUTPUT
|
|
@endDocuBlock generalGraphDistanceTo2
|
|
|
|
|
|
|
|
!SUBSECTION Graph measurements.
|
|
<!-- js/server/modules/@arangodb/aql.js -->
|
|
|
|
This section describes AQL functions to calculate various graph related measurements as defined in the mathematical graph theory.
|
|
|
|
!SUBSECTION GRAPH_ABSOLUTE_ECCENTRICITY
|
|
<!-- js/server/modules/@arangodb/aql.js -->
|
|
|
|
|
|
|
|
|
|
`GRAPH_ABSOLUTE_ECCENTRICITY (graphName, vertexExample, options)`
|
|
|
|
The GRAPH\_ABSOLUTE\_ECCENTRICITY function returns the
|
|
[eccentricity](http://en.wikipedia.org/wiki/Distance_%28graph_theory%29)
|
|
of the vertices defined by the examples.
|
|
|
|
The complexity of the function is described
|
|
[here](#the-complexity-of-the-shortest-path-algorithms).
|
|
|
|
*Parameters*
|
|
|
|
* *graphName* : The name of the graph as a string.
|
|
* *vertexExample* : An example for the desired
|
|
vertices (see [example](#short-explanation-of-the-example-parameter)).
|
|
* *options* (optional) : An object containing the following options:
|
|
* *direction* : The direction of the edges as a string. Possible values are *outbound*, *inbound* and *any* (default).
|
|
* *edgeCollectionRestriction* : One or multiple edge collection names. Only edges from these collections will be considered for the path.
|
|
* *startVertexCollectionRestriction* : One or multiple vertex collection names. Only vertices from these collections will be considered as
|
|
start vertex of a path.
|
|
* *endVertexCollectionRestriction* : One or multiple vertex collection names. Only vertices from these collections will be considered as
|
|
end vertex of a path.
|
|
* *edgeExamples* : A filter example for the edges in the shortest paths (see [example](#short-explanation-of-the-example-parameter)).
|
|
* *algorithm* : The algorithm to calculate the shortest paths as a string. If vertex example is empty
|
|
[Floyd-Warshall](http://en.wikipedia.org/wiki/Floyd%E2%80%93Warshall_algorithm) is
|
|
used as default, otherwise the default is
|
|
[Dijkstra](http://en.wikipedia.org/wiki/Dijkstra's_algorithm)
|
|
* *weight* : The name of the attribute of the edges containing the length as a string.
|
|
* *defaultWeight* : Only used with the option *weight*.
|
|
|
|
If an edge does not have the attribute named as defined in option *weight* this default is used as length.
|
|
If no default is supplied the default would be positive Infinity so the path and hence the eccentricity can not be calculated.
|
|
|
|
@EXAMPLES
|
|
|
|
A route planner example, the absolute eccentricity of all locations.
|
|
|
|
@startDocuBlockInline generalGraphAbsEccentricity1
|
|
@EXAMPLE_ARANGOSH_OUTPUT{generalGraphAbsEccentricity1}
|
|
var examples = require("@arangodb/graph-examples/example-graph.js");
|
|
var g = examples.loadGraph("routeplanner");
|
|
db._query("RETURN GRAPH_ABSOLUTE_ECCENTRICITY('routeplanner', {})").toArray();
|
|
~ examples.dropGraph("routeplanner");
|
|
@END_EXAMPLE_ARANGOSH_OUTPUT
|
|
@endDocuBlock generalGraphAbsEccentricity1
|
|
|
|
A route planner example, the absolute eccentricity of all locations.
|
|
This considers the actual distances.
|
|
|
|
@startDocuBlockInline generalGraphAbsEccentricity2
|
|
@EXAMPLE_ARANGOSH_OUTPUT{generalGraphAbsEccentricity2}
|
|
var examples = require("@arangodb/graph-examples/example-graph.js");
|
|
var g = examples.loadGraph("routeplanner");
|
|
| db._query("RETURN GRAPH_ABSOLUTE_ECCENTRICITY("
|
|
+"'routeplanner', {}, {weight : 'distance'})").toArray();
|
|
~ examples.dropGraph("routeplanner");
|
|
@END_EXAMPLE_ARANGOSH_OUTPUT
|
|
@endDocuBlock generalGraphAbsEccentricity2
|
|
|
|
A route planner example, the absolute eccentricity of all German cities regarding only
|
|
outbound paths.
|
|
|
|
@startDocuBlockInline generalGraphAbsEccentricity3
|
|
@EXAMPLE_ARANGOSH_OUTPUT{generalGraphAbsEccentricity3}
|
|
var examples = require("@arangodb/graph-examples/example-graph.js");
|
|
var g = examples.loadGraph("routeplanner");
|
|
| db._query("RETURN GRAPH_ABSOLUTE_ECCENTRICITY("
|
|
| + "'routeplanner', {}, {startVertexCollectionRestriction : 'germanCity', " +
|
|
"direction : 'outbound', weight : 'distance'})").toArray();
|
|
~ examples.dropGraph("routeplanner");
|
|
@END_EXAMPLE_ARANGOSH_OUTPUT
|
|
@endDocuBlock generalGraphAbsEccentricity3
|
|
|
|
|
|
|
|
!SUBSECTION GRAPH_ECCENTRICITY
|
|
<!-- js/server/modules/@arangodb/aql.js -->
|
|
|
|
|
|
|
|
|
|
`GRAPH_ECCENTRICITY (graphName, options)`
|
|
|
|
The GRAPH\_ECCENTRICITY function returns the normalized
|
|
[eccentricity](http://en.wikipedia.org/wiki/Distance_%28graph_theory%29)
|
|
of the graphs vertices
|
|
|
|
The complexity of the function is described
|
|
[here](#the-complexity-of-the-shortest-path-algorithms).
|
|
|
|
*Parameters*
|
|
|
|
* *graphName* : The name of the graph as a string.
|
|
* *options* (optional) : An object containing the following options:
|
|
* *direction* : The direction of the edges as a string. Possible values are *outbound*, *inbound* and *any* (default).
|
|
* *algorithm* : The algorithm to calculate the shortest paths as a string. Possible
|
|
values are [Floyd-Warshall](http://en.wikipedia.org/wiki/Floyd%E2%80%93Warshall_algorithm)
|
|
(default) and [Dijkstra](http://en.wikipedia.org/wiki/Dijkstra's_algorithm).
|
|
* *weight* : The name of the attribute of the edges containing the length as a string.
|
|
* *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.
|
|
|
|
@startDocuBlockInline generalGraphEccentricity1
|
|
@EXAMPLE_ARANGOSH_OUTPUT{generalGraphEccentricity1}
|
|
var examples = require("@arangodb/graph-examples/example-graph.js");
|
|
var g = examples.loadGraph("routeplanner");
|
|
db._query("RETURN GRAPH_ECCENTRICITY('routeplanner')").toArray();
|
|
~ examples.dropGraph("routeplanner");
|
|
@END_EXAMPLE_ARANGOSH_OUTPUT
|
|
@endDocuBlock generalGraphEccentricity1
|
|
|
|
A route planner example, the eccentricity of all locations.
|
|
This considers the actual distances.
|
|
|
|
@startDocuBlockInline generalGraphEccentricity2
|
|
@EXAMPLE_ARANGOSH_OUTPUT{generalGraphEccentricity2}
|
|
var examples = require("@arangodb/graph-examples/example-graph.js");
|
|
var g = examples.loadGraph("routeplanner");
|
|
| db._query("RETURN GRAPH_ECCENTRICITY('routeplanner', {weight : 'distance'})"
|
|
).toArray();
|
|
~ examples.dropGraph("routeplanner");
|
|
@END_EXAMPLE_ARANGOSH_OUTPUT
|
|
@endDocuBlock generalGraphEccentricity2
|
|
|
|
|
|
|
|
!SUBSECTION GRAPH_ABSOLUTE_CLOSENESS
|
|
<!-- js/server/modules/@arangodb/aql.js -->
|
|
|
|
|
|
|
|
|
|
`GRAPH_ABSOLUTE_CLOSENESS (graphName, vertexExample, options)`
|
|
|
|
The GRAPH\_ABSOLUTE\_CLOSENESS function returns the
|
|
[closeness](http://en.wikipedia.org/wiki/Centrality#Closeness-centrality)
|
|
of the vertices defined by the examples.
|
|
|
|
The complexity of the function is described
|
|
[here](#the-complexity-of-the-shortest-path-algorithms).
|
|
|
|
*Parameters*
|
|
|
|
* *graphName* : The name of the graph as a string.
|
|
* *vertexExample* : An example for the desired
|
|
vertices (see [example](#short-explanation-of-the-example-parameter)).
|
|
* *options* : An object containing the following options:
|
|
* *direction* : The direction of the edges. Possible values are *outbound*, *inbound* and *any* (default).
|
|
* *edgeCollectionRestriction* : One or multiple edge collection names. Only edges from these collections will be considered for the path.
|
|
* *startVertexCollectionRestriction* : One or multiple vertex collection names. Only vertices from these collections will be considered as
|
|
start vertex of a path.
|
|
* *endVertexCollectionRestriction* : One or multiple vertex collection names. Only vertices from these collections will be considered as
|
|
end vertex of a path.
|
|
* *edgeExamples* : A filter example for the edges in the shortest paths (see [example](#short-explanation-of-the-example-parameter)).
|
|
* *algorithm* : The algorithm to calculate the shortest paths. Possible values are
|
|
[Floyd-Warshall](http://en.wikipedia.org/wiki/Floyd%E2%80%93Warshall_algorithm) (default)
|
|
and [Dijkstra](http://en.wikipedia.org/wiki/Dijkstra's_algorithm).
|
|
* *weight* : The name of the attribute of the edges containing the length.
|
|
* *defaultWeight* : Only used with the option *weight*.
|
|
If an edge does not have the attribute named as defined in option *weight* this default is used as length.
|
|
If no default is supplied the default would be positive Infinity so the path and
|
|
hence the eccentricity can not be calculated.
|
|
|
|
@EXAMPLES
|
|
|
|
A route planner example, the absolute closeness of all locations.
|
|
|
|
@startDocuBlockInline generalGraphAbsCloseness1
|
|
@EXAMPLE_ARANGOSH_OUTPUT{generalGraphAbsCloseness1}
|
|
var examples = require("@arangodb/graph-examples/example-graph.js");
|
|
var g = examples.loadGraph("routeplanner");
|
|
db._query("RETURN GRAPH_ABSOLUTE_CLOSENESS('routeplanner', {})").toArray();
|
|
~ examples.dropGraph("routeplanner");
|
|
@END_EXAMPLE_ARANGOSH_OUTPUT
|
|
@endDocuBlock generalGraphAbsCloseness1
|
|
|
|
A route planner example, the absolute closeness of all locations.
|
|
This considers the actual distances.
|
|
|
|
@startDocuBlockInline generalGraphAbsCloseness2
|
|
@EXAMPLE_ARANGOSH_OUTPUT{generalGraphAbsCloseness2}
|
|
var examples = require("@arangodb/graph-examples/example-graph.js");
|
|
var g = examples.loadGraph("routeplanner");
|
|
| db._query("RETURN GRAPH_ABSOLUTE_CLOSENESS("
|
|
+"'routeplanner', {}, {weight : 'distance'})").toArray();
|
|
~ examples.dropGraph("routeplanner");
|
|
@END_EXAMPLE_ARANGOSH_OUTPUT
|
|
@endDocuBlock generalGraphAbsCloseness2
|
|
|
|
A route planner example, the absolute closeness of all German cities regarding only
|
|
outbound paths.
|
|
|
|
@startDocuBlockInline generalGraphAbsCloseness3
|
|
@EXAMPLE_ARANGOSH_OUTPUT{generalGraphAbsCloseness3}
|
|
var examples = require("@arangodb/graph-examples/example-graph.js");
|
|
var g = examples.loadGraph("routeplanner");
|
|
| db._query("RETURN GRAPH_ABSOLUTE_CLOSENESS("
|
|
| + "'routeplanner', {}, {startVertexCollectionRestriction : 'germanCity', " +
|
|
"direction : 'outbound', weight : 'distance'})").toArray();
|
|
~ examples.dropGraph("routeplanner");
|
|
@END_EXAMPLE_ARANGOSH_OUTPUT
|
|
@endDocuBlock generalGraphAbsCloseness3
|
|
|
|
|
|
|
|
!SUBSECTION GRAPH_CLOSENESS
|
|
<!-- js/server/modules/@arangodb/aql.js -->
|
|
|
|
|
|
|
|
|
|
`GRAPH_CLOSENESS (graphName, options)`
|
|
|
|
The GRAPH\_CLOSENESS function returns the normalized
|
|
[closeness](http://en.wikipedia.org/wiki/Centrality#Closeness-centrality)
|
|
of graphs vertices.
|
|
|
|
The complexity of the function is described
|
|
[here](#the-complexity-of-the-shortest-path-algorithms).
|
|
|
|
*Parameters*
|
|
|
|
* *graphName* : The name of the graph as a string.
|
|
* *options* : An object containing the following options:
|
|
* *direction* : The direction of the edges. Possible values are *outbound*, *inbound* and *any* (default).
|
|
* *algorithm* : The algorithm to calculate the shortest paths. Possible values are
|
|
[Floyd-Warshall](http://en.wikipedia.org/wiki/Floyd%E2%80%93Warshall_algorithm) (default)
|
|
and [Dijkstra](http://en.wikipedia.org/wiki/Dijkstra's_algorithm).
|
|
* *weight* : The name of the attribute of the edges containing the length.
|
|
* *defaultWeight* : Only used with the option *weight*.
|
|
If an edge does not have the attribute named as defined in option *weight* this defaultis used as length.
|
|
If no default is supplied the default would be positive Infinity so the path and
|
|
hence the eccentricity can not be calculated.
|
|
|
|
@EXAMPLES
|
|
|
|
A route planner example, the closeness of all locations.
|
|
|
|
@startDocuBlockInline generalGraphCloseness1
|
|
@EXAMPLE_ARANGOSH_OUTPUT{generalGraphCloseness1}
|
|
var examples = require("@arangodb/graph-examples/example-graph.js");
|
|
var g = examples.loadGraph("routeplanner");
|
|
db._query("RETURN GRAPH_CLOSENESS('routeplanner')").toArray();
|
|
~ examples.dropGraph("routeplanner");
|
|
@END_EXAMPLE_ARANGOSH_OUTPUT
|
|
@endDocuBlock generalGraphCloseness1
|
|
|
|
A route planner example, the closeness of all locations.
|
|
This considers the actual distances.
|
|
|
|
@startDocuBlockInline generalGraphCloseness2
|
|
@EXAMPLE_ARANGOSH_OUTPUT{generalGraphCloseness2}
|
|
var examples = require("@arangodb/graph-examples/example-graph.js");
|
|
var g = examples.loadGraph("routeplanner");
|
|
| db._query("RETURN GRAPH_CLOSENESS("
|
|
+"'routeplanner', {weight : 'distance'})").toArray();
|
|
~ examples.dropGraph("routeplanner");
|
|
@END_EXAMPLE_ARANGOSH_OUTPUT
|
|
@endDocuBlock generalGraphCloseness2
|
|
|
|
A route planner example, the absolute closeness of all cities regarding only
|
|
outbound paths.
|
|
|
|
@startDocuBlockInline generalGraphCloseness3
|
|
@EXAMPLE_ARANGOSH_OUTPUT{generalGraphCloseness3}
|
|
var examples = require("@arangodb/graph-examples/example-graph.js");
|
|
var g = examples.loadGraph("routeplanner");
|
|
| db._query("RETURN GRAPH_CLOSENESS("
|
|
| + "'routeplanner',{direction : 'outbound', weight : 'distance'})"
|
|
).toArray();
|
|
~ examples.dropGraph("routeplanner");
|
|
@END_EXAMPLE_ARANGOSH_OUTPUT
|
|
@endDocuBlock generalGraphCloseness3
|
|
|
|
|
|
|
|
!SUBSECTION GRAPH_ABSOLUTE_BETWEENNESS
|
|
<!-- js/server/modules/@arangodb/aql.js -->
|
|
|
|
|
|
|
|
|
|
`GRAPH_ABSOLUTE_BETWEENNESS (graphName, options)`
|
|
|
|
The GRAPH\_ABSOLUTE\_BETWEENNESS function returns the
|
|
[betweenness](http://en.wikipedia.org/wiki/Betweenness_centrality)
|
|
of all vertices in the graph.
|
|
|
|
The complexity of the function is described
|
|
[here](#the-complexity-of-the-shortest-path-algorithms).
|
|
|
|
|
|
* *graphName* : The name of the graph as a string.
|
|
* *options* : An object containing the following options:
|
|
* *direction* : The direction of the edges. Possible values are *outbound*, *inbound* and *any* (default).
|
|
* *weight* : The name of the attribute of the edges containing the length.
|
|
* *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.
|
|
|
|
@startDocuBlockInline generalGraphAbsBetweenness1
|
|
@EXAMPLE_ARANGOSH_OUTPUT{generalGraphAbsBetweenness1}
|
|
var examples = require("@arangodb/graph-examples/example-graph.js");
|
|
var g = examples.loadGraph("routeplanner");
|
|
db._query("RETURN GRAPH_ABSOLUTE_BETWEENNESS('routeplanner', {})").toArray();
|
|
~ examples.dropGraph("routeplanner");
|
|
@END_EXAMPLE_ARANGOSH_OUTPUT
|
|
@endDocuBlock generalGraphAbsBetweenness1
|
|
|
|
A route planner example, the absolute betweenness of all locations.
|
|
This considers the actual distances.
|
|
|
|
@startDocuBlockInline generalGraphAbsBetweenness2
|
|
@EXAMPLE_ARANGOSH_OUTPUT{generalGraphAbsBetweenness2}
|
|
var examples = require("@arangodb/graph-examples/example-graph.js");
|
|
var g = examples.loadGraph("routeplanner");
|
|
| db._query("RETURN GRAPH_ABSOLUTE_BETWEENNESS("
|
|
+"'routeplanner', {weight : 'distance'})").toArray();
|
|
~ examples.dropGraph("routeplanner");
|
|
@END_EXAMPLE_ARANGOSH_OUTPUT
|
|
@endDocuBlock generalGraphAbsBetweenness2
|
|
|
|
A route planner example, the absolute closeness regarding only
|
|
outbound paths.
|
|
|
|
@startDocuBlockInline generalGraphAbsBetweenness3
|
|
@EXAMPLE_ARANGOSH_OUTPUT{generalGraphAbsBetweenness3}
|
|
var examples = require("@arangodb/graph-examples/example-graph.js");
|
|
var g = examples.loadGraph("routeplanner");
|
|
| db._query("RETURN GRAPH_ABSOLUTE_BETWEENNESS("
|
|
| + "'routeplanner', {direction : 'outbound', weight : 'distance'})"
|
|
).toArray();
|
|
~ examples.dropGraph("routeplanner");
|
|
@END_EXAMPLE_ARANGOSH_OUTPUT
|
|
@endDocuBlock generalGraphAbsBetweenness3
|
|
|
|
|
|
|
|
!SUBSECTION GRAPH_BETWEENNESS
|
|
<!-- js/server/modules/@arangodb/aql.js -->
|
|
|
|
|
|
|
|
|
|
`GRAPH_BETWEENNESS (graphName, options)`
|
|
|
|
The GRAPH\_BETWEENNESS function returns the
|
|
[betweenness](http://en.wikipedia.org/wiki/Betweenness_centrality)
|
|
of graphs vertices.
|
|
|
|
The complexity of the function is described
|
|
[here](#the-complexity-of-the-shortest-path-algorithms).
|
|
|
|
*Parameters*
|
|
|
|
* *graphName* : The name of the graph as a string.
|
|
* *options* : An object containing the following options:
|
|
* *direction* : The direction of the edges. Possible values are *outbound*, *inbound* and *any* (default).
|
|
* *weight* : The name of the attribute of the edges containing the length.
|
|
* *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.
|
|
|
|
@startDocuBlockInline generalGraphBetweenness1
|
|
@EXAMPLE_ARANGOSH_OUTPUT{generalGraphBetweenness1}
|
|
var examples = require("@arangodb/graph-examples/example-graph.js");
|
|
var g = examples.loadGraph("routeplanner");
|
|
db._query("RETURN GRAPH_BETWEENNESS('routeplanner')").toArray();
|
|
~ examples.dropGraph("routeplanner");
|
|
@END_EXAMPLE_ARANGOSH_OUTPUT
|
|
@endDocuBlock generalGraphBetweenness1
|
|
|
|
A route planner example, the betweenness of all locations.
|
|
This considers the actual distances.
|
|
|
|
@startDocuBlockInline generalGraphBetweenness2
|
|
@EXAMPLE_ARANGOSH_OUTPUT{generalGraphBetweenness2}
|
|
var examples = require("@arangodb/graph-examples/example-graph.js");
|
|
var g = examples.loadGraph("routeplanner");
|
|
db._query("RETURN GRAPH_BETWEENNESS('routeplanner', {weight : 'distance'})").toArray();
|
|
~ examples.dropGraph("routeplanner");
|
|
@END_EXAMPLE_ARANGOSH_OUTPUT
|
|
@endDocuBlock generalGraphBetweenness2
|
|
|
|
A route planner example, the betweenness regarding only
|
|
outbound paths.
|
|
|
|
@startDocuBlockInline generalGraphBetweenness3
|
|
@EXAMPLE_ARANGOSH_OUTPUT{generalGraphBetweenness3}
|
|
var examples = require("@arangodb/graph-examples/example-graph.js");
|
|
var g = examples.loadGraph("routeplanner");
|
|
| db._query("RETURN GRAPH_BETWEENNESS("
|
|
+ "'routeplanner', {direction : 'outbound', weight : 'distance'})").toArray();
|
|
~ examples.dropGraph("routeplanner");
|
|
@END_EXAMPLE_ARANGOSH_OUTPUT
|
|
@endDocuBlock generalGraphBetweenness3
|
|
|
|
|
|
|
|
!SUBSECTION GRAPH_RADIUS
|
|
<!-- js/server/modules/@arangodb/aql.js -->
|
|
|
|
|
|
|
|
|
|
`GRAPH_RADIUS (graphName, options)`
|
|
|
|
*The GRAPH\_RADIUS function returns the
|
|
[radius](http://en.wikipedia.org/wiki/Eccentricity_%28graph_theory%29)
|
|
of a graph.*
|
|
|
|
The complexity of the function is described
|
|
[here](#the-complexity-of-the-shortest-path-algorithms).
|
|
|
|
* *graphName* : The name of the graph as a string.
|
|
* *options* : An object containing the following options:
|
|
* *direction* : The direction of the edges. Possible values are *outbound*, *inbound* and *any* (default).
|
|
* *algorithm* : The algorithm to calculate the shortest paths as a string. Possible
|
|
values are [Floyd-Warshall](http://en.wikipedia.org/wiki/Floyd%E2%80%93Warshall_algorithm)
|
|
(default) and [Dijkstra](http://en.wikipedia.org/wiki/Dijkstra's_algorithm).
|
|
* *weight* : The name of the attribute of the edges containing the length.
|
|
* *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.
|
|
|
|
@startDocuBlockInline generalGraphRadius1
|
|
@EXAMPLE_ARANGOSH_OUTPUT{generalGraphRadius1}
|
|
var examples = require("@arangodb/graph-examples/example-graph.js");
|
|
var g = examples.loadGraph("routeplanner");
|
|
db._query("RETURN GRAPH_RADIUS('routeplanner')").toArray();
|
|
~ examples.dropGraph("routeplanner");
|
|
@END_EXAMPLE_ARANGOSH_OUTPUT
|
|
@endDocuBlock generalGraphRadius1
|
|
|
|
A route planner example, the radius of the graph.
|
|
This considers the actual distances.
|
|
|
|
@startDocuBlockInline generalGraphRadius2
|
|
@EXAMPLE_ARANGOSH_OUTPUT{generalGraphRadius2}
|
|
var examples = require("@arangodb/graph-examples/example-graph.js");
|
|
var g = examples.loadGraph("routeplanner");
|
|
db._query("RETURN GRAPH_RADIUS('routeplanner', {weight : 'distance'})").toArray();
|
|
~ examples.dropGraph("routeplanner");
|
|
@END_EXAMPLE_ARANGOSH_OUTPUT
|
|
@endDocuBlock generalGraphRadius2
|
|
|
|
A route planner example, the radius of the graph regarding only
|
|
outbound paths.
|
|
|
|
@startDocuBlockInline generalGraphRadius3
|
|
@EXAMPLE_ARANGOSH_OUTPUT{generalGraphRadius3}
|
|
var examples = require("@arangodb/graph-examples/example-graph.js");
|
|
var g = examples.loadGraph("routeplanner");
|
|
| db._query("RETURN GRAPH_RADIUS("
|
|
| + "'routeplanner', {direction : 'outbound', weight : 'distance'})"
|
|
).toArray();
|
|
~ examples.dropGraph("routeplanner");
|
|
@END_EXAMPLE_ARANGOSH_OUTPUT
|
|
@endDocuBlock generalGraphRadius3
|
|
|
|
|
|
|
|
!SUBSECTION GRAPH_DIAMETER
|
|
<!-- js/server/modules/@arangodb/aql.js -->
|
|
|
|
|
|
|
|
|
|
`GRAPH_DIAMETER (graphName, options)`
|
|
|
|
The GRAPH\_DIAMETER function returns the
|
|
[diameter](http://en.wikipedia.org/wiki/Eccentricity_%28graph_theory%29)
|
|
of a graph.
|
|
|
|
The complexity of the function is described
|
|
[here](#the-complexity-of-the-shortest-path-algorithms).
|
|
|
|
*Parameters*
|
|
|
|
* *graphName* : The name of the graph as a string.
|
|
* *options* : An object containing the following options:
|
|
* *direction* : The direction of the edges. Possible values are *outbound*, *inbound* and *any* (default).
|
|
* *algorithm* : The algorithm to calculate the shortest paths as a string. Possible
|
|
values are [Floyd-Warshall](http://en.wikipedia.org/wiki/Floyd%E2%80%93Warshall_algorithm)
|
|
(default) and [Dijkstra](http://en.wikipedia.org/wiki/Dijkstra's_algorithm).
|
|
* *weight* : The name of the attribute of the edges containing the length.
|
|
* *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.
|
|
|
|
@startDocuBlockInline generalGraphDiameter1
|
|
@EXAMPLE_ARANGOSH_OUTPUT{generalGraphDiameter1}
|
|
var examples = require("@arangodb/graph-examples/example-graph.js");
|
|
var g = examples.loadGraph("routeplanner");
|
|
db._query("RETURN GRAPH_DIAMETER('routeplanner')").toArray();
|
|
~ examples.dropGraph("routeplanner");
|
|
@END_EXAMPLE_ARANGOSH_OUTPUT
|
|
@endDocuBlock generalGraphDiameter1
|
|
|
|
A route planner example, the diameter of the graph.
|
|
This considers the actual distances.
|
|
|
|
@startDocuBlockInline generalGraphDiameter2
|
|
@EXAMPLE_ARANGOSH_OUTPUT{generalGraphDiameter2}
|
|
var examples = require("@arangodb/graph-examples/example-graph.js");
|
|
var g = examples.loadGraph("routeplanner");
|
|
db._query("RETURN GRAPH_DIAMETER('routeplanner', {weight : 'distance'})").toArray();
|
|
~ examples.dropGraph("routeplanner");
|
|
@END_EXAMPLE_ARANGOSH_OUTPUT
|
|
@endDocuBlock generalGraphDiameter2
|
|
|
|
A route planner example, the diameter of the graph regarding only
|
|
outbound paths.
|
|
|
|
@startDocuBlockInline generalGraphDiameter3
|
|
@EXAMPLE_ARANGOSH_OUTPUT{generalGraphDiameter3}
|
|
var examples = require("@arangodb/graph-examples/example-graph.js");
|
|
var g = examples.loadGraph("routeplanner");
|
|
| db._query("RETURN GRAPH_DIAMETER("
|
|
| + "'routeplanner', {direction : 'outbound', weight : 'distance'})"
|
|
).toArray();
|
|
~ examples.dropGraph("routeplanner");
|
|
@END_EXAMPLE_ARANGOSH_OUTPUT
|
|
@endDocuBlock generalGraphDiameter3
|
|
|
|
|
|
|