Graph Functions
This chapter describes various functions on a graph.A lot of these accept a vertex (or edge) example as parameter as defined in the next section.
Examples will explain the API on the the city graph:
Definition of examples
For many of the following functions examples can be passed in as a parameter.Examples are used to filter the result set for objects that match the conditions.These examples can have the following values:
- null, there is no matching executed all found results are valid.
- A string, only results are returned, which _id equal the value of the string
- An example object, defining a set of attributes. Only results having these attributes are matched.
- A list containing example objects and/or strings. All results matching at least one of the elements in the list are returned.
Get vertices from edges.
Get vertex from of an edge
Get the source vertex of an edge
graph._fromVertex(edgeId)
Returns the vertex defined with the attribute from of the edge with _edgeId as its id_.
Parameters
- edgeId (required) _id attribute of the edge
Examples
- arangosh> var examples = require("@arangodb/graph-examples/example-graph.js");
- arangosh> var graph = examples.loadGraph("social");
- arangosh> var any = require("@arangodb").db.relation.any();
- arangosh> graph._fromVertex("relation/" + any._key);
Show execution results
Hide execution results
- {
- "_key" : "alice",
- "_id" : "female/alice",
- "_rev" : "_Z2KDQUG---",
- "name" : "Alice"
- }
Get vertex to of an edge
Get the target vertex of an edge
graph._toVertex(edgeId)
Returns the vertex defined with the attribute to of the edge with _edgeId as its id_.
Parameters
- edgeId (required) _id attribute of the edge
Examples
- arangosh> var examples = require("@arangodb/graph-examples/example-graph.js");
- arangosh> var graph = examples.loadGraph("social");
- arangosh> var any = require("@arangodb").db.relation.any();
- arangosh> graph._toVertex("relation/" + any._key);
Show execution results
Hide execution results
- {
- "_key" : "charly",
- "_id" : "male/charly",
- "_rev" : "_Z2KDQVG---",
- "name" : "Charly"
- }
_neighbors
Get all neighbors of the vertices defined by the example
graph._neighbors(vertexExample, options)
The function accepts an id, an example, a list of examples or even an emptyexample as parameter for vertexExample.The complexity of this method is O(n*m^x) with n being the vertices defined by theparameter 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
- vertexExample (optional) See Definition of examples
- options (optional) An object defining further options. Can have the following values:
- direction: The direction of the edges. Possible values are outbound, inbound and any (default).
- edgeExamples: Filter the edges, see Definition of examples
- neighborExamples: Filter the neighbor vertices, see Definition of examples
- edgeCollectionRestriction : One or a list of edge-collection names that should beconsidered to be on the path.
- vertexCollectionRestriction : One or a list of vertex-collection names that should beconsidered on the intermediate vertex steps.
- minDepth: Defines the minimal number of intermediate steps to neighbors (default is 1).
- maxDepth: Defines the maximal number of intermediate steps to neighbors (default is 1).
Examples
A route planner example, all neighbors of capitals.
- arangosh> var examples = require("@arangodb/graph-examples/example-graph.js");
- arangosh> var graph = examples.loadGraph("routeplanner");
- arangosh> graph._neighbors({isCapital : true});
Show execution results
Hide execution results
- [
- "frenchCity/Lyon",
- "germanCity/Berlin",
- "germanCity/Hamburg",
- "germanCity/Cologne",
- "frenchCity/Paris"
- ]
A route planner example, all outbound neighbors of Hamburg.
- arangosh> var examples = require("@arangodb/graph-examples/example-graph.js");
- arangosh> var graph = examples.loadGraph("routeplanner");
- arangosh> graph._neighbors('germanCity/Hamburg', {direction : 'outbound', maxDepth : 2});
Show execution results
Hide execution results
- [
- "germanCity/Cologne",
- "frenchCity/Paris",
- "frenchCity/Lyon"
- ]
_commonNeighbors
Get all common neighbors of the vertices defined by the examples.
graph._commonNeighbors(vertex1Example, vertex2Examples, optionsVertex1, optionsVertex2)
This function returns the intersection of graph_module._neighbors(vertex1Example, optionsVertex1)_and _graph_module._neighbors(vertex2Example, optionsVertex2).For parameter documentation see _neighbors.
The complexity of this method is O(n*m^x) with n being the maximal amount of verticesdefined by the parameters vertexExamples, m the average amount of neighbors and x themaximal depths.Hence the default call would have a complexity of O(n*m);
Examples
A route planner example, all common neighbors of capitals.
- arangosh> var examples = require("@arangodb/graph-examples/example-graph.js");
- arangosh> var graph = examples.loadGraph("routeplanner");
- arangosh> graph._commonNeighbors({isCapital : true}, {isCapital : true});
Show execution results
Hide execution results
- [
- {
- "left" : "frenchCity/Paris",
- "right" : "germanCity/Berlin",
- "neighbors" : [
- "germanCity/Cologne",
- "germanCity/Hamburg",
- "frenchCity/Lyon"
- ]
- },
- {
- "left" : "germanCity/Berlin",
- "right" : "frenchCity/Paris",
- "neighbors" : [
- "frenchCity/Lyon",
- "germanCity/Hamburg",
- "germanCity/Cologne"
- ]
- }
- ]
A route planner example, all common outbound neighbors of Hamburg with any other locationwhich have a maximal depth of 2 :
- arangosh> var examples = require("@arangodb/graph-examples/example-graph.js");
- arangosh> var graph = examples.loadGraph("routeplanner");
- arangosh> graph._commonNeighbors(
- ........> 'germanCity/Hamburg',
- ........> {},
- ........> {direction : 'outbound', maxDepth : 2},
- ........> {direction : 'outbound', maxDepth : 2});
Show execution results
Hide execution results
- [
- {
- "left" : "germanCity/Hamburg",
- "right" : "frenchCity/Paris",
- "neighbors" : [
- "frenchCity/Lyon"
- ]
- },
- {
- "left" : "germanCity/Hamburg",
- "right" : "germanCity/Berlin",
- "neighbors" : [
- "frenchCity/Lyon",
- "frenchCity/Paris",
- "germanCity/Cologne"
- ]
- },
- {
- "left" : "germanCity/Hamburg",
- "right" : "germanCity/Cologne",
- "neighbors" : [
- "frenchCity/Lyon",
- "frenchCity/Paris"
- ]
- }
- ]
_countCommonNeighbors
Get the amount of common neighbors of the vertices defined by the examples.
graph._countCommonNeighbors(vertex1Example, vertex2Examples, optionsVertex1, optionsVertex2)
Similar to _commonNeighbors but returns count instead of the elements.
Examples
A route planner example, all common neighbors of capitals.
- arangosh> var examples = require("@arangodb/graph-examples/example-graph.js");
- arangosh> var graph = examples.loadGraph("routeplanner");
- arangosh> var example = { isCapital: true };
- arangosh> var options = { includeData: true };
- arangosh> graph._countCommonNeighbors(example, example, options, options);
Show execution results
Hide execution results
- [
- {
- "frenchCity/Paris" : [
- {
- "germanCity/Berlin" : 3
- }
- ]
- },
- {
- "germanCity/Berlin" : [
- {
- "frenchCity/Paris" : 3
- }
- ]
- }
- ]
A route planner example, all common outbound neighbors of Hamburg with any other locationwhich have a maximal depth of 2 :
- arangosh> var examples = require("@arangodb/graph-examples/example-graph.js");
- arangosh> var graph = examples.loadGraph("routeplanner");
- arangosh> var options = { direction: 'outbound', maxDepth: 2, includeData: true };
- arangosh> graph._countCommonNeighbors('germanCity/Hamburg', {}, options, options);
Show execution results
Hide execution results
- [
- {
- "germanCity/Hamburg" : [
- {
- "frenchCity/Paris" : 1
- },
- {
- "germanCity/Berlin" : 3
- },
- {
- "germanCity/Cologne" : 2
- }
- ]
- }
- ]
_commonProperties
Get the vertices of the graph that share common properties.
graph._commonProperties(vertex1Example, vertex2Examples, options)
The function accepts an id, an example, a list of examples or even an emptyexample as parameter for vertex1Example and vertex2Example.
The complexity of this method is O(n) with n being the maximal amount of verticesdefined by the parameters vertexExamples.
Parameters
vertex1Examples (optional) Filter the set of source vertices, see Definition of examples
vertex2Examples (optional) Filter the set of vertices compared to, see Definition of examples
- options (optional) An object defining further options. Can have the following values:
- vertex1CollectionRestriction : One or a list of vertex-collection names that should besearched for source vertices.
- vertex2CollectionRestriction : One or a list of vertex-collection names that should besearched for compare vertices.
- ignoreProperties : One or a list of attribute names of a document that should be ignored.
Examples
A route planner example, all locations with the same properties:
- arangosh> var examples = require("@arangodb/graph-examples/example-graph.js");
- arangosh> var graph = examples.loadGraph("routeplanner");
- arangosh> graph._commonProperties({}, {});
Show execution results
Hide execution results
- [
- {
- "frenchCity/Lyon" : [
- {
- "_id" : "germanCity/Cologne",
- "isCapital" : false
- },
- {
- "_id" : "germanCity/Hamburg",
- "isCapital" : false
- }
- ]
- },
- {
- "frenchCity/Paris" : [
- {
- "_id" : "germanCity/Berlin",
- "isCapital" : true
- }
- ]
- },
- {
- "germanCity/Berlin" : [
- {
- "_id" : "frenchCity/Paris",
- "isCapital" : true
- }
- ]
- },
- {
- "germanCity/Cologne" : [
- {
- "_id" : "frenchCity/Lyon",
- "isCapital" : false
- },
- {
- "_id" : "germanCity/Hamburg",
- "isCapital" : false,
- "population" : 1000000
- }
- ]
- },
- {
- "germanCity/Hamburg" : [
- {
- "_id" : "frenchCity/Lyon",
- "isCapital" : false
- },
- {
- "_id" : "germanCity/Cologne",
- "isCapital" : false,
- "population" : 1000000
- }
- ]
- }
- ]
A route planner example, all cities which share same properties except for population.
- arangosh> var examples = require("@arangodb/graph-examples/example-graph.js");
- arangosh> var graph = examples.loadGraph("routeplanner");
- arangosh> graph._commonProperties({}, {}, {ignoreProperties: 'population'});
Show execution results
Hide execution results
- [
- {
- "frenchCity/Lyon" : [
- {
- "_id" : "germanCity/Cologne",
- "isCapital" : false
- },
- {
- "_id" : "germanCity/Hamburg",
- "isCapital" : false
- }
- ]
- },
- {
- "frenchCity/Paris" : [
- {
- "_id" : "germanCity/Berlin",
- "isCapital" : true
- }
- ]
- },
- {
- "germanCity/Berlin" : [
- {
- "_id" : "frenchCity/Paris",
- "isCapital" : true
- }
- ]
- },
- {
- "germanCity/Cologne" : [
- {
- "_id" : "frenchCity/Lyon",
- "isCapital" : false
- },
- {
- "_id" : "germanCity/Hamburg",
- "isCapital" : false
- }
- ]
- },
- {
- "germanCity/Hamburg" : [
- {
- "_id" : "frenchCity/Lyon",
- "isCapital" : false
- },
- {
- "_id" : "germanCity/Cologne",
- "isCapital" : false
- }
- ]
- }
- ]
_countCommonProperties
Get the amount of vertices of the graph that share common properties.
graph._countCommonProperties(vertex1Example, vertex2Examples, options)
Similar to _commonProperties but returns count instead ofthe objects.
Examples
A route planner example, all locations with the same properties:
- arangosh> var examples = require("@arangodb/graph-examples/example-graph.js");
- arangosh> var graph = examples.loadGraph("routeplanner");
- arangosh> graph._countCommonProperties({}, {});
Show execution results
Hide execution results
- [
- {
- "frenchCity/Lyon" : 2
- },
- {
- "frenchCity/Paris" : 1
- },
- {
- "germanCity/Berlin" : 1
- },
- {
- "germanCity/Cologne" : 2
- },
- {
- "germanCity/Hamburg" : 2
- }
- ]
A route planner example, all German cities which share same properties except for population.
- arangosh> var examples = require("@arangodb/graph-examples/example-graph.js");
- arangosh> var graph = examples.loadGraph("routeplanner");
- arangosh> graph._countCommonProperties({}, {}, {vertex1CollectionRestriction : 'germanCity',
- ........> vertex2CollectionRestriction : 'germanCity' ,ignoreProperties: 'population'});
Show execution results
Hide execution results
- [
- {
- "frenchCity/Lyon" : 2
- },
- {
- "frenchCity/Paris" : 1
- },
- {
- "germanCity/Berlin" : 1
- },
- {
- "germanCity/Cologne" : 2
- },
- {
- "germanCity/Hamburg" : 2
- }
- ]
_paths
The _paths function returns all paths of a graph.
graph._paths(options)
This function determines all available paths in a graph.
The complexity of this method is O(nnm) with n being the amount of vertices inthe graph and m the average amount of connected edges;
Parameters
- options (optional) An object containing options, see below:
- 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 musthave 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”:
- arangosh> var examples = require("@arangodb/graph-examples/example-graph.js");
- arangosh> var g = examples.loadGraph("social");
- arangosh> g._paths();
Show execution results
Hide execution results
- [
- {
- "source" : {
- "_key" : "alice",
- "_id" : "female/alice",
- "_rev" : "_Z2KDRF6---",
- "name" : "Alice"
- },
- "destination" : {
- "_key" : "alice",
- "_id" : "female/alice",
- "_rev" : "_Z2KDRF6---",
- "name" : "Alice"
- },
- "edges" : [ ],
- "vertice" : [
- {
- "_key" : "alice",
- "_id" : "female/alice",
- "_rev" : "_Z2KDRF6---",
- "name" : "Alice"
- }
- ]
- },
- {
- "source" : {
- "_key" : "alice",
- "_id" : "female/alice",
- "_rev" : "_Z2KDRF6---",
- "name" : "Alice"
- },
- "destination" : {
- "_key" : "bob",
- "_id" : "male/bob",
- "_rev" : "_Z2KDRG----",
- "name" : "Bob"
- },
- "edges" : [
- {
- "_key" : "77883",
- "_id" : "relation/77883",
- "_from" : "female/alice",
- "_to" : "male/bob",
- "_rev" : "_Z2KDRGC---",
- "type" : "married",
- "vertex" : "alice"
- }
- ],
- "vertice" : [
- {
- "_key" : "alice",
- "_id" : "female/alice",
- "_rev" : "_Z2KDRF6---",
- "name" : "Alice"
- },
- {
- "_key" : "bob",
- "_id" : "male/bob",
- "_rev" : "_Z2KDRG----",
- "name" : "Bob"
- }
- ]
- },
- {
- "source" : {
- "_key" : "alice",
- "_id" : "female/alice",
- "_rev" : "_Z2KDRF6---",
- "name" : "Alice"
- },
- "destination" : {
- "_key" : "diana",
- "_id" : "female/diana",
- "_rev" : "_Z2KDRG---C",
- "name" : "Diana"
- },
- "edges" : [
- {
- "_key" : "77883",
- "_id" : "relation/77883",
- "_from" : "female/alice",
- "_to" : "male/bob",
- "_rev" : "_Z2KDRGC---",
- "type" : "married",
- "vertex" : "alice"
- },
- {
- "_key" : "77889",
- "_id" : "relation/77889",
- "_from" : "male/bob",
- "_to" : "female/diana",
- "_rev" : "_Z2KDRGG--A",
- "type" : "friend",
- "vertex" : "bob"
- }
- ],
- "vertice" : [
- {
- "_key" : "alice",
- "_id" : "female/alice",
- "_rev" : "_Z2KDRF6---",
- "name" : "Alice"
- },
- {
- "_key" : "bob",
- "_id" : "male/bob",
- "_rev" : "_Z2KDRG----",
- "name" : "Bob"
- },
- {
- "_key" : "diana",
- "_id" : "female/diana",
- "_rev" : "_Z2KDRG---C",
- "name" : "Diana"
- }
- ]
- },
- {
- "source" : {
- "_key" : "alice",
- "_id" : "female/alice",
- "_rev" : "_Z2KDRF6---",
- "name" : "Alice"
- },
- "destination" : {
- "_key" : "charly",
- "_id" : "male/charly",
- "_rev" : "_Z2KDRG---A",
- "name" : "Charly"
- },
- "edges" : [
- {
- "_key" : "77885",
- "_id" : "relation/77885",
- "_from" : "female/alice",
- "_to" : "male/charly",
- "_rev" : "_Z2KDRGC--A",
- "type" : "friend",
- "vertex" : "alice"
- }
- ],
- "vertice" : [
- {
- "_key" : "alice",
- "_id" : "female/alice",
- "_rev" : "_Z2KDRF6---",
- "name" : "Alice"
- },
- {
- "_key" : "charly",
- "_id" : "male/charly",
- "_rev" : "_Z2KDRG---A",
- "name" : "Charly"
- }
- ]
- },
- {
- "source" : {
- "_key" : "alice",
- "_id" : "female/alice",
- "_rev" : "_Z2KDRF6---",
- "name" : "Alice"
- },
- "destination" : {
- "_key" : "diana",
- "_id" : "female/diana",
- "_rev" : "_Z2KDRG---C",
- "name" : "Diana"
- },
- "edges" : [
- {
- "_key" : "77885",
- "_id" : "relation/77885",
- "_from" : "female/alice",
- "_to" : "male/charly",
- "_rev" : "_Z2KDRGC--A",
- "type" : "friend",
- "vertex" : "alice"
- },
- {
- "_key" : "77887",
- "_id" : "relation/77887",
- "_from" : "male/charly",
- "_to" : "female/diana",
- "_rev" : "_Z2KDRGG---",
- "type" : "married",
- "vertex" : "charly"
- }
- ],
- "vertice" : [
- {
- "_key" : "alice",
- "_id" : "female/alice",
- "_rev" : "_Z2KDRF6---",
- "name" : "Alice"
- },
- {
- "_key" : "charly",
- "_id" : "male/charly",
- "_rev" : "_Z2KDRG---A",
- "name" : "Charly"
- },
- {
- "_key" : "diana",
- "_id" : "female/diana",
- "_rev" : "_Z2KDRG---C",
- "name" : "Diana"
- }
- ]
- },
- {
- "source" : {
- "_key" : "diana",
- "_id" : "female/diana",
- "_rev" : "_Z2KDRG---C",
- "name" : "Diana"
- },
- "destination" : {
- "_key" : "diana",
- "_id" : "female/diana",
- "_rev" : "_Z2KDRG---C",
- "name" : "Diana"
- },
- "edges" : [ ],
- "vertice" : [
- {
- "_key" : "diana",
- "_id" : "female/diana",
- "_rev" : "_Z2KDRG---C",
- "name" : "Diana"
- }
- ]
- },
- {
- "source" : {
- "_key" : "bob",
- "_id" : "male/bob",
- "_rev" : "_Z2KDRG----",
- "name" : "Bob"
- },
- "destination" : {
- "_key" : "bob",
- "_id" : "male/bob",
- "_rev" : "_Z2KDRG----",
- "name" : "Bob"
- },
- "edges" : [ ],
- "vertice" : [
- {
- "_key" : "bob",
- "_id" : "male/bob",
- "_rev" : "_Z2KDRG----",
- "name" : "Bob"
- }
- ]
- },
- {
- "source" : {
- "_key" : "bob",
- "_id" : "male/bob",
- "_rev" : "_Z2KDRG----",
- "name" : "Bob"
- },
- "destination" : {
- "_key" : "diana",
- "_id" : "female/diana",
- "_rev" : "_Z2KDRG---C",
- "name" : "Diana"
- },
- "edges" : [
- {
- "_key" : "77889",
- "_id" : "relation/77889",
- "_from" : "male/bob",
- "_to" : "female/diana",
- "_rev" : "_Z2KDRGG--A",
- "type" : "friend",
- "vertex" : "bob"
- }
- ],
- "vertice" : [
- {
- "_key" : "bob",
- "_id" : "male/bob",
- "_rev" : "_Z2KDRG----",
- "name" : "Bob"
- },
- {
- "_key" : "diana",
- "_id" : "female/diana",
- "_rev" : "_Z2KDRG---C",
- "name" : "Diana"
- }
- ]
- },
- {
- "source" : {
- "_key" : "charly",
- "_id" : "male/charly",
- "_rev" : "_Z2KDRG---A",
- "name" : "Charly"
- },
- "destination" : {
- "_key" : "charly",
- "_id" : "male/charly",
- "_rev" : "_Z2KDRG---A",
- "name" : "Charly"
- },
- "edges" : [ ],
- "vertice" : [
- {
- "_key" : "charly",
- "_id" : "male/charly",
- "_rev" : "_Z2KDRG---A",
- "name" : "Charly"
- }
- ]
- },
- {
- "source" : {
- "_key" : "charly",
- "_id" : "male/charly",
- "_rev" : "_Z2KDRG---A",
- "name" : "Charly"
- },
- "destination" : {
- "_key" : "diana",
- "_id" : "female/diana",
- "_rev" : "_Z2KDRG---C",
- "name" : "Diana"
- },
- "edges" : [
- {
- "_key" : "77887",
- "_id" : "relation/77887",
- "_from" : "male/charly",
- "_to" : "female/diana",
- "_rev" : "_Z2KDRGG---",
- "type" : "married",
- "vertex" : "charly"
- }
- ],
- "vertice" : [
- {
- "_key" : "charly",
- "_id" : "male/charly",
- "_rev" : "_Z2KDRG---A",
- "name" : "Charly"
- },
- {
- "_key" : "diana",
- "_id" : "female/diana",
- "_rev" : "_Z2KDRG---C",
- "name" : "Diana"
- }
- ]
- }
- ]
Return all inbound paths of the graph “social” with a maximallength of 1 and a minimal length of 2:
- arangosh> var examples = require("@arangodb/graph-examples/example-graph.js");
- arangosh> var g = examples.loadGraph("social");
- arangosh> g._paths({direction : 'inbound', minLength : 1, maxLength : 2});
Show execution results
Hide execution results
- [
- {
- "source" : {
- "_key" : "diana",
- "_id" : "female/diana",
- "_rev" : "_Z2KDRH6---",
- "name" : "Diana"
- },
- "destination" : {
- "_key" : "charly",
- "_id" : "male/charly",
- "_rev" : "_Z2KDRH2--A",
- "name" : "Charly"
- },
- "edges" : [
- {
- "_key" : "77933",
- "_id" : "relation/77933",
- "_from" : "male/charly",
- "_to" : "female/diana",
- "_rev" : "_Z2KDRI---A",
- "type" : "married",
- "vertex" : "charly"
- }
- ],
- "vertice" : [
- {
- "_key" : "diana",
- "_id" : "female/diana",
- "_rev" : "_Z2KDRH6---",
- "name" : "Diana"
- },
- {
- "_key" : "charly",
- "_id" : "male/charly",
- "_rev" : "_Z2KDRH2--A",
- "name" : "Charly"
- }
- ]
- },
- {
- "source" : {
- "_key" : "diana",
- "_id" : "female/diana",
- "_rev" : "_Z2KDRH6---",
- "name" : "Diana"
- },
- "destination" : {
- "_key" : "alice",
- "_id" : "female/alice",
- "_rev" : "_Z2KDRHy---",
- "name" : "Alice"
- },
- "edges" : [
- {
- "_key" : "77933",
- "_id" : "relation/77933",
- "_from" : "male/charly",
- "_to" : "female/diana",
- "_rev" : "_Z2KDRI---A",
- "type" : "married",
- "vertex" : "charly"
- },
- {
- "_key" : "77931",
- "_id" : "relation/77931",
- "_from" : "female/alice",
- "_to" : "male/charly",
- "_rev" : "_Z2KDRI----",
- "type" : "friend",
- "vertex" : "alice"
- }
- ],
- "vertice" : [
- {
- "_key" : "diana",
- "_id" : "female/diana",
- "_rev" : "_Z2KDRH6---",
- "name" : "Diana"
- },
- {
- "_key" : "charly",
- "_id" : "male/charly",
- "_rev" : "_Z2KDRH2--A",
- "name" : "Charly"
- },
- {
- "_key" : "alice",
- "_id" : "female/alice",
- "_rev" : "_Z2KDRHy---",
- "name" : "Alice"
- }
- ]
- },
- {
- "source" : {
- "_key" : "diana",
- "_id" : "female/diana",
- "_rev" : "_Z2KDRH6---",
- "name" : "Diana"
- },
- "destination" : {
- "_key" : "bob",
- "_id" : "male/bob",
- "_rev" : "_Z2KDRH2---",
- "name" : "Bob"
- },
- "edges" : [
- {
- "_key" : "77935",
- "_id" : "relation/77935",
- "_from" : "male/bob",
- "_to" : "female/diana",
- "_rev" : "_Z2KDRIC---",
- "type" : "friend",
- "vertex" : "bob"
- }
- ],
- "vertice" : [
- {
- "_key" : "diana",
- "_id" : "female/diana",
- "_rev" : "_Z2KDRH6---",
- "name" : "Diana"
- },
- {
- "_key" : "bob",
- "_id" : "male/bob",
- "_rev" : "_Z2KDRH2---",
- "name" : "Bob"
- }
- ]
- },
- {
- "source" : {
- "_key" : "diana",
- "_id" : "female/diana",
- "_rev" : "_Z2KDRH6---",
- "name" : "Diana"
- },
- "destination" : {
- "_key" : "alice",
- "_id" : "female/alice",
- "_rev" : "_Z2KDRHy---",
- "name" : "Alice"
- },
- "edges" : [
- {
- "_key" : "77935",
- "_id" : "relation/77935",
- "_from" : "male/bob",
- "_to" : "female/diana",
- "_rev" : "_Z2KDRIC---",
- "type" : "friend",
- "vertex" : "bob"
- },
- {
- "_key" : "77929",
- "_id" : "relation/77929",
- "_from" : "female/alice",
- "_to" : "male/bob",
- "_rev" : "_Z2KDRH6--A",
- "type" : "married",
- "vertex" : "alice"
- }
- ],
- "vertice" : [
- {
- "_key" : "diana",
- "_id" : "female/diana",
- "_rev" : "_Z2KDRH6---",
- "name" : "Diana"
- },
- {
- "_key" : "bob",
- "_id" : "male/bob",
- "_rev" : "_Z2KDRH2---",
- "name" : "Bob"
- },
- {
- "_key" : "alice",
- "_id" : "female/alice",
- "_rev" : "_Z2KDRHy---",
- "name" : "Alice"
- }
- ]
- },
- {
- "source" : {
- "_key" : "bob",
- "_id" : "male/bob",
- "_rev" : "_Z2KDRH2---",
- "name" : "Bob"
- },
- "destination" : {
- "_key" : "alice",
- "_id" : "female/alice",
- "_rev" : "_Z2KDRHy---",
- "name" : "Alice"
- },
- "edges" : [
- {
- "_key" : "77929",
- "_id" : "relation/77929",
- "_from" : "female/alice",
- "_to" : "male/bob",
- "_rev" : "_Z2KDRH6--A",
- "type" : "married",
- "vertex" : "alice"
- }
- ],
- "vertice" : [
- {
- "_key" : "bob",
- "_id" : "male/bob",
- "_rev" : "_Z2KDRH2---",
- "name" : "Bob"
- },
- {
- "_key" : "alice",
- "_id" : "female/alice",
- "_rev" : "_Z2KDRHy---",
- "name" : "Alice"
- }
- ]
- },
- {
- "source" : {
- "_key" : "charly",
- "_id" : "male/charly",
- "_rev" : "_Z2KDRH2--A",
- "name" : "Charly"
- },
- "destination" : {
- "_key" : "alice",
- "_id" : "female/alice",
- "_rev" : "_Z2KDRHy---",
- "name" : "Alice"
- },
- "edges" : [
- {
- "_key" : "77931",
- "_id" : "relation/77931",
- "_from" : "female/alice",
- "_to" : "male/charly",
- "_rev" : "_Z2KDRI----",
- "type" : "friend",
- "vertex" : "alice"
- }
- ],
- "vertice" : [
- {
- "_key" : "charly",
- "_id" : "male/charly",
- "_rev" : "_Z2KDRH2--A",
- "name" : "Charly"
- },
- {
- "_key" : "alice",
- "_id" : "female/alice",
- "_rev" : "_Z2KDRHy---",
- "name" : "Alice"
- }
- ]
- }
- ]
_shortestPath
The _shortestPath function returns all shortest paths of a graph.
graph._shortestPath(startVertexExample, endVertexExample, options)
This function determines all shortest paths in a graph.The function accepts an id, an example, a list of examplesor even an empty example as parameter forstart and end vertex.The length of a path is by default the amount of edges from one start vertex toan end vertex. The option weight allows the user to define an edge attributerepresenting the length.
Parameters
- startVertexExample (optional) An example for the desired start Vertices (see Definition of examples).
- endVertexExample (optional) An example for the desired end Vertices (see Definition of examples).
- options (optional) An object containing options, see below:
- direction: The direction of the edges as a string.Possible values are outbound, inbound and any (default).
- edgeCollectionRestriction: One or multiple edgecollection names. Only edges from these collections will be considered for the path.
- startVertexCollectionRestriction: One or multiple vertexcollection names. Only vertices from these collections will be considered asstart vertex of a path.
- endVertexCollectionRestriction: One or multiple vertexcollection names. Only vertices from these collections will be considered asend vertex of a path.
- weight: The name of the attribute ofthe 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 defaultis used as length.If no default is supplied the default would be positive Infinity so the path couldnot be calculated.
Examples
A route planner example, shortest path from all german to all french cities:
- arangosh> var examples = require("@arangodb/graph-examples/example-graph.js");
- arangosh> var g = examples.loadGraph("routeplanner");
- arangosh> g._shortestPath({}, {}, {weight : 'distance', endVertexCollectionRestriction : 'frenchCity',
- ........> startVertexCollectionRestriction : 'germanCity'});
Show execution results
Hide execution results
- [
- {
- "vertices" : [
- "frenchCity/Lyon",
- "frenchCity/Paris"
- ],
- "edges" : [
- {
- "_key" : "78373",
- "_id" : "frenchHighway/78373",
- "_from" : "frenchCity/Paris",
- "_to" : "frenchCity/Lyon",
- "_rev" : "_Z2KDRR6---",
- "distance" : 550
- }
- ],
- "distance" : 1
- },
- {
- "vertices" : [
- "frenchCity/Lyon",
- "germanCity/Berlin"
- ],
- "edges" : [
- {
- "_key" : "78375",
- "_id" : "internationalHighway/78375",
- "_from" : "germanCity/Berlin",
- "_to" : "frenchCity/Lyon",
- "_rev" : "_Z2KDRR6--A",
- "distance" : 1100
- }
- ],
- "distance" : 1
- },
- {
- "vertices" : [
- "frenchCity/Lyon",
- "germanCity/Cologne"
- ],
- "edges" : [
- {
- "_key" : "78383",
- "_id" : "internationalHighway/78383",
- "_from" : "germanCity/Cologne",
- "_to" : "frenchCity/Lyon",
- "_rev" : "_Z2KDRSC--A",
- "distance" : 700
- }
- ],
- "distance" : 1
- },
- {
- "vertices" : [
- "frenchCity/Lyon",
- "germanCity/Hamburg"
- ],
- "edges" : [
- {
- "_key" : "78381",
- "_id" : "internationalHighway/78381",
- "_from" : "germanCity/Hamburg",
- "_to" : "frenchCity/Lyon",
- "_rev" : "_Z2KDRSC---",
- "distance" : 1300
- }
- ],
- "distance" : 1
- },
- {
- "vertices" : [
- "frenchCity/Paris",
- "frenchCity/Lyon"
- ],
- "edges" : [
- {
- "_key" : "78373",
- "_id" : "frenchHighway/78373",
- "_from" : "frenchCity/Paris",
- "_to" : "frenchCity/Lyon",
- "_rev" : "_Z2KDRR6---",
- "distance" : 550
- }
- ],
- "distance" : 1
- },
- {
- "vertices" : [
- "frenchCity/Paris",
- "germanCity/Berlin"
- ],
- "edges" : [
- {
- "_key" : "78377",
- "_id" : "internationalHighway/78377",
- "_from" : "germanCity/Berlin",
- "_to" : "frenchCity/Paris",
- "_rev" : "_Z2KDRS----",
- "distance" : 1200
- }
- ],
- "distance" : 1
- },
- {
- "vertices" : [
- "frenchCity/Paris",
- "germanCity/Cologne"
- ],
- "edges" : [
- {
- "_key" : "78385",
- "_id" : "internationalHighway/78385",
- "_from" : "germanCity/Cologne",
- "_to" : "frenchCity/Paris",
- "_rev" : "_Z2KDRSG---",
- "distance" : 550
- }
- ],
- "distance" : 1
- },
- {
- "vertices" : [
- "frenchCity/Paris",
- "germanCity/Hamburg"
- ],
- "edges" : [
- {
- "_key" : "78379",
- "_id" : "internationalHighway/78379",
- "_from" : "germanCity/Hamburg",
- "_to" : "frenchCity/Paris",
- "_rev" : "_Z2KDRS---A",
- "distance" : 900
- }
- ],
- "distance" : 1
- },
- {
- "vertices" : [
- "germanCity/Berlin",
- "frenchCity/Lyon"
- ],
- "edges" : [
- {
- "_key" : "78375",
- "_id" : "internationalHighway/78375",
- "_from" : "germanCity/Berlin",
- "_to" : "frenchCity/Lyon",
- "_rev" : "_Z2KDRR6--A",
- "distance" : 1100
- }
- ],
- "distance" : 1
- },
- {
- "vertices" : [
- "germanCity/Berlin",
- "frenchCity/Paris"
- ],
- "edges" : [
- {
- "_key" : "78377",
- "_id" : "internationalHighway/78377",
- "_from" : "germanCity/Berlin",
- "_to" : "frenchCity/Paris",
- "_rev" : "_Z2KDRS----",
- "distance" : 1200
- }
- ],
- "distance" : 1
- },
- {
- "vertices" : [
- "germanCity/Berlin",
- "germanCity/Cologne"
- ],
- "edges" : [
- {
- "_key" : "78367",
- "_id" : "germanHighway/78367",
- "_from" : "germanCity/Berlin",
- "_to" : "germanCity/Cologne",
- "_rev" : "_Z2KDRRy--_",
- "distance" : 850
- }
- ],
- "distance" : 1
- },
- {
- "vertices" : [
- "germanCity/Berlin",
- "germanCity/Hamburg"
- ],
- "edges" : [
- {
- "_key" : "78369",
- "_id" : "germanHighway/78369",
- "_from" : "germanCity/Berlin",
- "_to" : "germanCity/Hamburg",
- "_rev" : "_Z2KDRR2---",
- "distance" : 400
- }
- ],
- "distance" : 1
- },
- {
- "vertices" : [
- "germanCity/Cologne",
- "frenchCity/Lyon"
- ],
- "edges" : [
- {
- "_key" : "78383",
- "_id" : "internationalHighway/78383",
- "_from" : "germanCity/Cologne",
- "_to" : "frenchCity/Lyon",
- "_rev" : "_Z2KDRSC--A",
- "distance" : 700
- }
- ],
- "distance" : 1
- },
- {
- "vertices" : [
- "germanCity/Cologne",
- "frenchCity/Paris"
- ],
- "edges" : [
- {
- "_key" : "78385",
- "_id" : "internationalHighway/78385",
- "_from" : "germanCity/Cologne",
- "_to" : "frenchCity/Paris",
- "_rev" : "_Z2KDRSG---",
- "distance" : 550
- }
- ],
- "distance" : 1
- },
- {
- "vertices" : [
- "germanCity/Cologne",
- "germanCity/Berlin"
- ],
- "edges" : [
- {
- "_key" : "78367",
- "_id" : "germanHighway/78367",
- "_from" : "germanCity/Berlin",
- "_to" : "germanCity/Cologne",
- "_rev" : "_Z2KDRRy--_",
- "distance" : 850
- }
- ],
- "distance" : 1
- },
- {
- "vertices" : [
- "germanCity/Cologne",
- "germanCity/Hamburg"
- ],
- "edges" : [
- {
- "_key" : "78371",
- "_id" : "germanHighway/78371",
- "_from" : "germanCity/Hamburg",
- "_to" : "germanCity/Cologne",
- "_rev" : "_Z2KDRR2--A",
- "distance" : 500
- }
- ],
- "distance" : 1
- },
- {
- "vertices" : [
- "germanCity/Hamburg",
- "frenchCity/Lyon"
- ],
- "edges" : [
- {
- "_key" : "78381",
- "_id" : "internationalHighway/78381",
- "_from" : "germanCity/Hamburg",
- "_to" : "frenchCity/Lyon",
- "_rev" : "_Z2KDRSC---",
- "distance" : 1300
- }
- ],
- "distance" : 1
- },
- {
- "vertices" : [
- "germanCity/Hamburg",
- "frenchCity/Paris"
- ],
- "edges" : [
- {
- "_key" : "78379",
- "_id" : "internationalHighway/78379",
- "_from" : "germanCity/Hamburg",
- "_to" : "frenchCity/Paris",
- "_rev" : "_Z2KDRS---A",
- "distance" : 900
- }
- ],
- "distance" : 1
- },
- {
- "vertices" : [
- "germanCity/Hamburg",
- "germanCity/Berlin"
- ],
- "edges" : [
- {
- "_key" : "78369",
- "_id" : "germanHighway/78369",
- "_from" : "germanCity/Berlin",
- "_to" : "germanCity/Hamburg",
- "_rev" : "_Z2KDRR2---",
- "distance" : 400
- }
- ],
- "distance" : 1
- },
- {
- "vertices" : [
- "germanCity/Hamburg",
- "germanCity/Cologne"
- ],
- "edges" : [
- {
- "_key" : "78371",
- "_id" : "germanHighway/78371",
- "_from" : "germanCity/Hamburg",
- "_to" : "germanCity/Cologne",
- "_rev" : "_Z2KDRR2--A",
- "distance" : 500
- }
- ],
- "distance" : 1
- }
- ]
A route planner example, shortest path from Hamburg and Cologne to Lyon:
- arangosh> var examples = require("@arangodb/graph-examples/example-graph.js");
- arangosh> var g = examples.loadGraph("routeplanner");
- arangosh> g._shortestPath([{_id: 'germanCity/Cologne'},{_id: 'germanCity/Munich'}], 'frenchCity/Lyon',
- ........> {weight : 'distance'});
Show execution results
Hide execution results
- [
- {
- "vertices" : [
- "germanCity/Cologne",
- "frenchCity/Lyon"
- ],
- "edges" : [
- {
- "_key" : "78459",
- "_id" : "internationalHighway/78459",
- "_from" : "germanCity/Cologne",
- "_to" : "frenchCity/Lyon",
- "_rev" : "_Z2KDRUW---",
- "distance" : 700
- }
- ],
- "distance" : 1
- }
- ]
_distanceTo
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:
- arangosh> var examples = require("@arangodb/graph-examples/example-graph.js");
- arangosh> var g = examples.loadGraph("routeplanner");
- arangosh> g._distanceTo({}, {}, {weight : 'distance', endVertexCollectionRestriction : 'frenchCity',
- ........> startVertexCollectionRestriction : 'germanCity'});
Show execution results
Hide execution results
- [
- {
- "startVertex" : "frenchCity/Lyon",
- "vertex" : "frenchCity/Paris",
- "distance" : 1
- },
- {
- "startVertex" : "frenchCity/Lyon",
- "vertex" : "germanCity/Berlin",
- "distance" : 1
- },
- {
- "startVertex" : "frenchCity/Lyon",
- "vertex" : "germanCity/Cologne",
- "distance" : 1
- },
- {
- "startVertex" : "frenchCity/Lyon",
- "vertex" : "germanCity/Hamburg",
- "distance" : 1
- },
- {
- "startVertex" : "frenchCity/Paris",
- "vertex" : "frenchCity/Lyon",
- "distance" : 1
- },
- {
- "startVertex" : "frenchCity/Paris",
- "vertex" : "germanCity/Berlin",
- "distance" : 1
- },
- {
- "startVertex" : "frenchCity/Paris",
- "vertex" : "germanCity/Cologne",
- "distance" : 1
- },
- {
- "startVertex" : "frenchCity/Paris",
- "vertex" : "germanCity/Hamburg",
- "distance" : 1
- },
- {
- "startVertex" : "germanCity/Berlin",
- "vertex" : "frenchCity/Lyon",
- "distance" : 1
- },
- {
- "startVertex" : "germanCity/Berlin",
- "vertex" : "frenchCity/Paris",
- "distance" : 1
- },
- {
- "startVertex" : "germanCity/Berlin",
- "vertex" : "germanCity/Cologne",
- "distance" : 1
- },
- {
- "startVertex" : "germanCity/Berlin",
- "vertex" : "germanCity/Hamburg",
- "distance" : 1
- },
- {
- "startVertex" : "germanCity/Cologne",
- "vertex" : "frenchCity/Lyon",
- "distance" : 1
- },
- {
- "startVertex" : "germanCity/Cologne",
- "vertex" : "frenchCity/Paris",
- "distance" : 1
- },
- {
- "startVertex" : "germanCity/Cologne",
- "vertex" : "germanCity/Berlin",
- "distance" : 1
- },
- {
- "startVertex" : "germanCity/Cologne",
- "vertex" : "germanCity/Hamburg",
- "distance" : 1
- },
- {
- "startVertex" : "germanCity/Hamburg",
- "vertex" : "frenchCity/Lyon",
- "distance" : 1
- },
- {
- "startVertex" : "germanCity/Hamburg",
- "vertex" : "frenchCity/Paris",
- "distance" : 1
- },
- {
- "startVertex" : "germanCity/Hamburg",
- "vertex" : "germanCity/Berlin",
- "distance" : 1
- },
- {
- "startVertex" : "germanCity/Hamburg",
- "vertex" : "germanCity/Cologne",
- "distance" : 1
- }
- ]
A route planner example, shortest distance from Hamburg and Cologne to Lyon:
- arangosh> var examples = require("@arangodb/graph-examples/example-graph.js");
- arangosh> var g = examples.loadGraph("routeplanner");
- arangosh> g._distanceTo([{_id: 'germanCity/Cologne'},{_id: 'germanCity/Munich'}], 'frenchCity/Lyon',
- ........> {weight : 'distance'});
Show execution results
Hide execution results
- [
- {
- "startVertex" : "germanCity/Cologne",
- "vertex" : "frenchCity/Lyon",
- "distance" : 1
- }
- ]
_absoluteEccentricity
Get theeccentricityof the vertices defined by the examples.
graph._absoluteEccentricity(vertexExample, options)
The function accepts an id, an example, a list of examples or even an emptyexample as parameter for vertexExample.
Parameters
- vertexExample (optional) Filter the vertices, see Definition of examples
- options (optional) An object defining further options. Can have the following values:
- direction: The direction of the edges. Possible values are outbound, inbound and any (default).
- edgeCollectionRestriction : One or a list of edge-collection names that should beconsidered to be on the path.
- startVertexCollectionRestriction : One or a list of vertex-collection names that should beconsidered for source vertices.
- endVertexCollectionRestriction : One or a list of vertex-collection names that should beconsidered for target vertices.
- weight: The name of the attribute of the edges containing the weight.
- 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 weight.If no default is supplied the default would be positive infinity so the path andhence the eccentricity can not be calculated.
Examples
A route planner example, the absolute eccentricity of all locations.
- arangosh> var examples = require("@arangodb/graph-examples/example-graph.js");
- arangosh> var graph = examples.loadGraph("routeplanner");
- arangosh> graph._absoluteEccentricity({});
Show execution results
Hide execution results
- {
- "frenchCity/Lyon" : 1,
- "frenchCity/Paris" : 1,
- "germanCity/Berlin" : 1,
- "germanCity/Cologne" : 1,
- "germanCity/Hamburg" : 1
- }
A route planner example, the absolute eccentricity of all locations.This considers the actual distances.
- arangosh> var examples = require("@arangodb/graph-examples/example-graph.js");
- arangosh> var graph = examples.loadGraph("routeplanner");
- arangosh> graph._absoluteEccentricity({}, {weight : 'distance'});
Show execution results
Hide execution results
- {
- "frenchCity/Lyon" : 1,
- "frenchCity/Paris" : 1,
- "germanCity/Berlin" : 1,
- "germanCity/Cologne" : 1,
- "germanCity/Hamburg" : 1
- }
A route planner example, the absolute eccentricity of all cities regarding onlyoutbound paths.
- arangosh> var examples = require("@arangodb/graph-examples/example-graph.js");
- arangosh> var graph = examples.loadGraph("routeplanner");
- arangosh> graph._absoluteEccentricity({}, {startVertexCollectionRestriction : 'germanCity',
- ........> direction : 'outbound', weight : 'distance'});
Show execution results
Hide execution results
- {
- "frenchCity/Lyon" : 0,
- "frenchCity/Paris" : 1,
- "germanCity/Berlin" : 1,
- "germanCity/Cologne" : 1,
- "germanCity/Hamburg" : 1
- }
_eccentricity
Get the normalizedeccentricityof the vertices defined by the examples.
graph._eccentricity(vertexExample, options)
Similar to _absoluteEccentricity but returns a normalized result.
Examples
A route planner example, the eccentricity of all locations.
- arangosh> var examples = require("@arangodb/graph-examples/example-graph.js");
- arangosh> var graph = examples.loadGraph("routeplanner");
- arangosh> graph._eccentricity();
Show execution results
Hide execution results
- {
- "frenchCity/Lyon" : 1,
- "frenchCity/Paris" : 1,
- "germanCity/Berlin" : 1,
- "germanCity/Cologne" : 1,
- "germanCity/Hamburg" : 1
- }
A route planner example, the weighted eccentricity.
- arangosh> var examples = require("@arangodb/graph-examples/example-graph.js");
- arangosh> var graph = examples.loadGraph("routeplanner");
- arangosh> graph._eccentricity({weight : 'distance'});
Show execution results
Hide execution results
- {
- "frenchCity/Lyon" : 1,
- "frenchCity/Paris" : 1,
- "germanCity/Berlin" : 1,
- "germanCity/Cologne" : 1,
- "germanCity/Hamburg" : 1
- }
_absoluteCloseness
Get theclosenessof the vertices defined by the examples.
graph._absoluteCloseness(vertexExample, options)
The function accepts an id, an example, a list of examples or even an emptyexample as parameter for vertexExample.
Parameters
- vertexExample (optional) Filter the vertices, see Definition of examples
- options (optional) An object defining further options. Can have the following values:
- direction: The direction of the edges. Possible values are outbound, inbound and any (default).
- edgeCollectionRestriction : One or a list of edge-collection names that should beconsidered to be on the path.
- startVertexCollectionRestriction : One or a list of vertex-collection names that should beconsidered for source vertices.
- endVertexCollectionRestriction : One or a list of vertex-collection names that should beconsidered for target vertices.
- weight: The name of the attribute of the edges containing the weight.
- 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 weight.If no default is supplied the default would be positive infinity so the path andhence the closeness can not be calculated.
Examples
A route planner example, the absolute closeness of all locations.
- arangosh> var examples = require("@arangodb/graph-examples/example-graph.js");
- arangosh> var graph = examples.loadGraph("routeplanner");
- arangosh> graph._absoluteCloseness({});
Show execution results
Hide execution results
- {
- "frenchCity/Lyon" : 4,
- "frenchCity/Paris" : 4,
- "germanCity/Berlin" : 4,
- "germanCity/Cologne" : 4,
- "germanCity/Hamburg" : 4
- }
A route planner example, the absolute closeness of all locations.This considers the actual distances.
- arangosh> var examples = require("@arangodb/graph-examples/example-graph.js");
- arangosh> var graph = examples.loadGraph("routeplanner");
- arangosh> graph._absoluteCloseness({}, {weight : 'distance'});
Show execution results
Hide execution results
- {
- "frenchCity/Lyon" : 4,
- "frenchCity/Paris" : 4,
- "germanCity/Berlin" : 4,
- "germanCity/Cologne" : 4,
- "germanCity/Hamburg" : 4
- }
A route planner example, the absolute closeness of all German Cities regarding onlyoutbound paths.
- arangosh> var examples = require("@arangodb/graph-examples/example-graph.js");
- arangosh> var graph = examples.loadGraph("routeplanner");
- arangosh> graph._absoluteCloseness({}, {startVertexCollectionRestriction : 'germanCity',
- ........> direction : 'outbound', weight : 'distance'});
Show execution results
Hide execution results
- {
- "frenchCity/Lyon" : 0,
- "frenchCity/Paris" : 1,
- "germanCity/Berlin" : 4,
- "germanCity/Cologne" : 2,
- "germanCity/Hamburg" : 3
- }
_closeness
Get the normalizedclosenessof graphs vertices.
graph._closeness(options)
Similar to _absoluteCloseness but returns a normalized value.
Examples
A route planner example, the normalized closeness of all locations.
- arangosh> var examples = require("@arangodb/graph-examples/example-graph.js");
- arangosh> var graph = examples.loadGraph("routeplanner");
- arangosh> graph._closeness();
Show execution results
Hide execution results
- {
- "frenchCity/Lyon" : 1,
- "frenchCity/Paris" : 1,
- "germanCity/Berlin" : 1,
- "germanCity/Cologne" : 1,
- "germanCity/Hamburg" : 1
- }
A route planner example, the closeness of all locations.This considers the actual distances.
- arangosh> var examples = require("@arangodb/graph-examples/example-graph.js");
- arangosh> var graph = examples.loadGraph("routeplanner");
- arangosh> graph._closeness({weight : 'distance'});
Show execution results
Hide execution results
- {
- "frenchCity/Lyon" : 1,
- "frenchCity/Paris" : 1,
- "germanCity/Berlin" : 1,
- "germanCity/Cologne" : 1,
- "germanCity/Hamburg" : 1
- }
A route planner example, the closeness of all cities regarding onlyoutbound paths.
- arangosh> var examples = require("@arangodb/graph-examples/example-graph.js");
- arangosh> var graph = examples.loadGraph("routeplanner");
- arangosh> graph._closeness({direction : 'outbound', weight : 'distance'});
Show execution results
Hide execution results
- {
- "frenchCity/Lyon" : 0,
- "frenchCity/Paris" : 1,
- "germanCity/Berlin" : 0.25,
- "germanCity/Cologne" : 0.5,
- "germanCity/Hamburg" : 0.3333333333333333
- }
_absoluteBetweenness
Get thebetweennessof all vertices in the graph.
graph._absoluteBetweenness(vertexExample, options)
Parameters
- vertexExample (optional) Filter the vertices, see Definition of examples
- options (optional) An object defining further options. Can have the following values:
- 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 weight.
- 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 weight.If no default is supplied the default would be positive infinity so the path andhence the betweenness can not be calculated.
Examples
A route planner example, the absolute betweenness of all locations.
- arangosh> var examples = require("@arangodb/graph-examples/example-graph.js");
- arangosh> var graph = examples.loadGraph("routeplanner");
- arangosh> graph._absoluteBetweenness({});
Show execution results
Hide execution results
- {
- "frenchCity/Lyon" : 0,
- "frenchCity/Paris" : 0,
- "germanCity/Berlin" : 0,
- "germanCity/Cologne" : 0,
- "germanCity/Hamburg" : 0
- }
A route planner example, the absolute betweenness of all locations.This considers the actual distances.
- arangosh> var examples = require("@arangodb/graph-examples/example-graph.js");
- arangosh> var graph = examples.loadGraph("routeplanner");
- arangosh> graph._absoluteBetweenness({weight : 'distance'});
Show execution results
Hide execution results
- {
- }
A route planner example, the absolute betweenness of all cities regarding onlyoutbound paths.
- arangosh> var examples = require("@arangodb/graph-examples/example-graph.js");
- arangosh> var graph = examples.loadGraph("routeplanner");
- arangosh> graph._absoluteBetweenness({direction : 'outbound', weight : 'distance'});
Show execution results
Hide execution results
- {
- }
_betweenness
Get the normalizedbetweennessof graphs vertices.
graph_module._betweenness(options)
Similar to _absoluteBetweenness but returns normalized values.
Examples
A route planner example, the betweenness of all locations.
- arangosh> var examples = require("@arangodb/graph-examples/example-graph.js");
- arangosh> var graph = examples.loadGraph("routeplanner");
- arangosh> graph._betweenness();
Show execution results
Hide execution results
- {
- "frenchCity/Lyon" : 0,
- "frenchCity/Paris" : 0,
- "germanCity/Berlin" : 0,
- "germanCity/Cologne" : 0,
- "germanCity/Hamburg" : 0
- }
A route planner example, the betweenness of all locations.This considers the actual distances.
- arangosh> var examples = require("@arangodb/graph-examples/example-graph.js");
- arangosh> var graph = examples.loadGraph("routeplanner");
- arangosh> graph._betweenness({weight : 'distance'});
Show execution results
Hide execution results
- {
- "frenchCity/Lyon" : 0,
- "frenchCity/Paris" : 0,
- "germanCity/Berlin" : 0,
- "germanCity/Cologne" : 0,
- "germanCity/Hamburg" : 0
- }
A route planner example, the betweenness of all cities regarding onlyoutbound paths.
- arangosh> var examples = require("@arangodb/graph-examples/example-graph.js");
- arangosh> var graph = examples.loadGraph("routeplanner");
- arangosh> graph._betweenness({direction : 'outbound', weight : 'distance'});
Show execution results
Hide execution results
- {
- "frenchCity/Lyon" : 0,
- "frenchCity/Paris" : 0,
- "germanCity/Berlin" : 0,
- "germanCity/Cologne" : 0,
- "germanCity/Hamburg" : 0
- }
_radius
Get theradiusof a graph.
`
Parameters
- options (optional) An object defining further options. Can have the following values:
- 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 weight.
- 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 weight.If no default is supplied the default would be positive infinity so the path andhence the radius can not be calculated.
Examples
A route planner example, the radius of the graph.
- arangosh> var examples = require("@arangodb/graph-examples/example-graph.js");
- arangosh> var graph = examples.loadGraph("routeplanner");
- arangosh> graph._radius();
Show execution results
Hide execution results
- 1
A route planner example, the radius of the graph.This considers the actual distances.
- arangosh> var examples = require("@arangodb/graph-examples/example-graph.js");
- arangosh> var graph = examples.loadGraph("routeplanner");
- arangosh> graph._radius({weight : 'distance'});
Show execution results
Hide execution results
- 1
A route planner example, the radius of the graph regarding onlyoutbound paths.
- arangosh> var examples = require("@arangodb/graph-examples/example-graph.js");
- arangosh> var graph = examples.loadGraph("routeplanner");
- arangosh> graph._radius({direction : 'outbound', weight : 'distance'});
Show execution results
Hide execution results
- 1
_diameter
Get thediameterof a graph.
graph._diameter(graphName, options)
Parameters
- options (optional) An object defining further options. Can have the following values:
- 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 weight.
- 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 weight.If no default is supplied the default would be positive infinity so the path andhence the radius can not be calculated.
Examples
A route planner example, the diameter of the graph.
- arangosh> var examples = require("@arangodb/graph-examples/example-graph.js");
- arangosh> var graph = examples.loadGraph("routeplanner");
- arangosh> graph._diameter();
Show execution results
Hide execution results
- 1
A route planner example, the diameter of the graph.This considers the actual distances.
- arangosh> var examples = require("@arangodb/graph-examples/example-graph.js");
- arangosh> var graph = examples.loadGraph("routeplanner");
- arangosh> graph._diameter({weight : 'distance'});
Show execution results
Hide execution results
- 1
A route planner example, the diameter of the graph regarding onlyoutbound paths.
- arangosh> var examples = require("@arangodb/graph-examples/example-graph.js");
- arangosh> var graph = examples.loadGraph("routeplanner");
- arangosh> graph._diameter({direction : 'outbound', weight : 'distance'});
Show execution results
Hide execution results
- 1