mirror of https://gitee.com/bigwinds/arangodb
66 lines
2.4 KiB
Markdown
66 lines
2.4 KiB
Markdown
|
|
|
|
|
|
`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 default
|
|
is used as length.
|
|
If no default is supplied the default would be positive Infinity so the path and
|
|
hence the eccentricity can not be calculated.
|
|
|
|
@EXAMPLES
|
|
|
|
A route planner example, the closeness of all locations.
|
|
|
|
@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
|
|
|
|
A route planner example, the closeness of all locations.
|
|
This considers the actual distances.
|
|
|
|
@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
|
|
|
|
A route planner example, the absolute closeness of all cities regarding only
|
|
outbound paths.
|
|
|
|
@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
|
|
|
|
|