1
0
Fork 0
arangodb/Documentation/DocuBlocks/JSF_general_graph_distance_...

1.2 KiB

@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. 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