mirror of https://gitee.com/bigwinds/arangodb
33 lines
1.2 KiB
Markdown
33 lines
1.2 KiB
Markdown
|
|
|
|
@brief The _distanceTo function returns all paths and there distance within a graph.
|
|
|
|
`graph._distanceTo(startVertexExample, endVertexExample, options)`
|
|
|
|
This function is a wrapper of [graph._shortestPath](#shortestpath).
|
|
It does not return the actual path but only the distance between two vertices.
|
|
|
|
@EXAMPLES
|
|
|
|
A route planner example, shortest distance from all german to all french cities:
|
|
|
|
@EXAMPLE_ARANGOSH_OUTPUT{generalGraphModuleDistanceTo1}
|
|
var examples = require("@arangodb/graph-examples/example-graph.js");
|
|
var g = examples.loadGraph("routeplanner");
|
|
| g._distanceTo({}, {}, {weight : 'distance', endVertexCollectionRestriction : 'frenchCity',
|
|
startVertexCollectionRestriction : 'germanCity'});
|
|
~ examples.dropGraph("routeplanner");
|
|
@END_EXAMPLE_ARANGOSH_OUTPUT
|
|
|
|
A route planner example, shortest distance from Hamburg and Cologne to Lyon:
|
|
|
|
@EXAMPLE_ARANGOSH_OUTPUT{generalGraphModuleDistanceTo2}
|
|
var examples = require("@arangodb/graph-examples/example-graph.js");
|
|
var g = examples.loadGraph("routeplanner");
|
|
| g._distanceTo([{_id: 'germanCity/Cologne'},{_id: 'germanCity/Munich'}], 'frenchCity/Lyon',
|
|
{weight : 'distance'});
|
|
~ examples.dropGraph("routeplanner");
|
|
@END_EXAMPLE_ARANGOSH_OUTPUT
|
|
|
|
|