diff --git a/Documentation/Books/Users/Aql/GraphOperations.mdpp b/Documentation/Books/Users/Aql/GraphOperations.mdpp index bd825362cb..77446df407 100644 --- a/Documentation/Books/Users/Aql/GraphOperations.mdpp +++ b/Documentation/Books/Users/Aql/GraphOperations.mdpp @@ -8,1160 +8,23 @@ This section describes various AQL functions which can be used to recieve inform !SUBSUBSECTION GRAPH_EDGES -
-`GRAPH_EDGES (graphName, vertexExample, options)` -*The GRAPH\_EDGES function returns all edges of vertices.* -
-
-The function accepts an id, an example, a list of examples or even an empty -example as parameter for vertex. -
-* String *graphName* : The name of the graph. -* String|Object|Array *vertexExample* : An example for the desired -vertices (see below). -* Object *options* : Optional options, see below: -
-Possible options and there defaults: -* String *direction* : The direction -of the edges. Possible values are *outbound*, *inbound* and *any* (default). -* String|Array *edgeCollectionRestriction* : One or multiple -edge collections that should be considered. -* String|Array *startVertexCollectionRestriction* : One or multiple -vertex collections that should be considered. -* String|Array *endVertexCollectionRestriction* : One or multiple -vertex collections that should be considered. -* String|Object|Array *edgeExamples* : A filter example -for the edges (see below). -* String|Object|Array *neighborExamples* : An example for -the desired neighbors (see below). -* Number *minDepth* : Defines the minimal -depth a path to a neighbor must have to be returned (default is 1). -* Number *maxDepth* : Defines the maximal -depth a path to a neighbor must have to be returned (default is 1). -
-Examples for edgeExamples/neighborExamples: -* {} : Returns all possible edges/neighbors for this graph. -* *idString* : Returns the edge/vertex with the id *idString*. -* {*key* : *value*} : Returns the edges/vertices that match this example. -* [{*key1* : *value1*}, {*key2* : *value2*}] : Returns the edges/vertices that -match one of the examples. -
-@EXAMPLES -
-A route planner example, all edges to locations with a distance of either 700 or 600.: -
- -``` -arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); -arangosh> var g = examples.loadGraph("routeplanner"); -arangosh> db._query("FOR e IN GRAPH_EDGES(" -........> +"'routeplanner', {}, {edgeExamples : [{distance: 600}, {distance: 700}]}) RETURN e" -........> ).toArray(); -[ - { - "_id" : "highway/221256913", - "_rev" : "221256913", - "_key" : "221256913", - "_from" : "city/Berlin", - "_to" : "city/Munich", - "distance" : 600 - }, - { - "_id" : "road/221846737", - "_rev" : "221846737", - "_key" : "221846737", - "_from" : "city/Berlin", - "_to" : "village/Olpe", - "distance" : 700 - }, - { - "_id" : "highway/221256913", - "_rev" : "221256913", - "_key" : "221256913", - "_from" : "city/Berlin", - "_to" : "city/Munich", - "distance" : 600 - }, - { - "_id" : "road/222436561", - "_rev" : "222436561", - "_key" : "222436561", - "_from" : "city/Munich", - "_to" : "village/Olpe", - "distance" : 600 - }, - { - "_id" : "road/221846737", - "_rev" : "221846737", - "_key" : "221846737", - "_from" : "city/Berlin", - "_to" : "village/Olpe", - "distance" : 700 - }, - { - "_id" : "road/222436561", - "_rev" : "222436561", - "_key" : "222436561", - "_from" : "city/Munich", - "_to" : "village/Olpe", - "distance" : 600 - } -] -``` -
-A route planner example, all outbound edges of munich with a maximal depth of 2 : -
- -``` -arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); -arangosh> var g = examples.loadGraph("routeplanner"); -arangosh> db._query("FOR e IN GRAPH_EDGES(" -........> +"'routeplanner', 'city/Munich', {direction : 'outbound', maxDepth : 2}) RETURN e" -........> ).toArray(); -[ - { - "_id" : "highway/226630865", - "_rev" : "226630865", - "_key" : "226630865", - "_from" : "city/Munich", - "_to" : "city/Cologne", - "distance" : 650 - }, - { - "_id" : "highway/226630865", - "_rev" : "226630865", - "_key" : "226630865", - "_from" : "city/Munich", - "_to" : "city/Cologne", - "distance" : 650 - }, - { - "_id" : "road/227810513", - "_rev" : "227810513", - "_key" : "227810513", - "_from" : "city/Cologne", - "_to" : "village/Olpe", - "distance" : 100 - }, - { - "_id" : "highway/226630865", - "_rev" : "226630865", - "_key" : "226630865", - "_from" : "city/Munich", - "_to" : "city/Cologne", - "distance" : 650 - }, - { - "_id" : "road/228007121", - "_rev" : "228007121", - "_key" : "228007121", - "_from" : "city/Cologne", - "_to" : "village/Rosenheim", - "distance" : 750 - }, - { - "_id" : "road/227417297", - "_rev" : "227417297", - "_key" : "227417297", - "_from" : "city/Munich", - "_to" : "village/Rosenheim", - "distance" : 80 - }, - { - "_id" : "road/227613905", - "_rev" : "227613905", - "_key" : "227613905", - "_from" : "city/Munich", - "_to" : "village/Olpe", - "distance" : 600 - } -] -``` -
- +@startDocuBlock JSF_ahuacatl_general_graph_edges !SUBSUBSECTION GRAPH_VERTICES -
-`GRAPH_VERTICES (graphName, vertexExample, options)` -*The GRAPH\_VERTICES function returns all vertices.* -
-
-The function accepts an id, an example, a list of examples or even an empty -example as parameter for vertex. -According to the optional filters it will only return vertices that have -outbound, onbound or any (default) edges. -
-* String *graphName* : The name of the graph. -* String|Object|Array *vertexExample* : An example for the desired -vertices (see below). -* Object *options* : Optional options, see below: -
-Possible options and there defaults: -* String *direction* : The direction of the -edges. Possible values are *outbound*, *inbound* and *any* (default). -* String|Array *vertexCollectionRestriction* : One or multiple -vertex collections that should be considered. -
-Examples for vertexExample: -* {} : Returns all possible vertices for this graph. -* *idString* : Returns the vertex with the id *idString*. -* {*key* : *value*} : Returns the vertices that match this example. -* [{*key1* : *value1*}, {*key2* : *value2*}] : Returns the vertices that -match one of the examples. -
-@EXAMPLES -
-A route planner example, all vertices of the graph -
- -``` -arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); -arangosh> var g = examples.loadGraph("routeplanner"); -arangosh> db._query("FOR e IN GRAPH_VERTICES(" -........> +"'routeplanner', {}) RETURN e" -........> ).toArray(); -[ - { - "_id" : "city/Berlin", - "_rev" : "203824337", - "_key" : "Berlin", - "isCapital" : true, - "population" : 3000000 - }, - { - "_id" : "city/Cologne", - "_rev" : "204020945", - "_key" : "Cologne", - "isCapital" : false, - "population" : 1000000 - }, - { - "_id" : "city/Munich", - "_rev" : "204217553", - "_key" : "Munich", - "isCapital" : true, - "population" : 1000000 - }, - { - "_id" : "village/Rosenheim", - "_rev" : "204872913", - "_key" : "Rosenheim", - "isCapital" : false, - "population" : 80000 - }, - { - "_id" : "village/Olpe", - "_rev" : "204676305", - "_key" : "Olpe", - "isCapital" : false, - "population" : 80000 - } -] -``` -
-A route planner example, all vertices from collection *city*. -
- -``` -arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); -arangosh> var g = examples.loadGraph("routeplanner"); -arangosh> db._query("FOR e IN GRAPH_VERTICES(" -........> +"'routeplanner', {}, {direction : 'any', vertexCollectionRestriction" + -........> " : 'city'}) RETURN e" -........> ).toArray(); -[ - { - "_id" : "city/Berlin", - "_rev" : "198646993", - "_key" : "Berlin", - "isCapital" : true, - "population" : 3000000 - }, - { - "_id" : "city/Cologne", - "_rev" : "198843601", - "_key" : "Cologne", - "isCapital" : false, - "population" : 1000000 - }, - { - "_id" : "city/Munich", - "_rev" : "199040209", - "_key" : "Munich", - "isCapital" : true, - "population" : 1000000 - } -] -``` -
- +@startDocuBlock JSF_ahuacatl_general_graph_vertices !SUBSUBSECTION GRAPH_COMMON_NEIGHBORS -
-`GRAPH_COMMON_NEIGHBORS (graphName, vertex1Example, vertex2Examples, -optionsVertex1, optionsVertex2)` -*The GRAPH\_COMMON\_NEIGHBORS function returns all common neighbors of the vertices -defined by the examples.* -
-
-The function accepts an id, an example, a list of examples or even an empty -example as parameter for vertex1Example and vertex2Example. -
-* String *graphName* : The name of the graph. -* String|Object|Array *vertex1Example* : An example for the desired -vertices (see below). -* String|Object|Array *vertex2Example* : An example for the desired -vertices (see below). -* Object *optionsVertex1* : Optional options, see below: -* Object *optionsVertex2* : Optional options, see below: -
-Possible options and there defaults: -* String *direction* : The direction of the -edges. Possible values are *outbound*, *inbound* and *any* (default). -* String|Object|Array *edgeExamples* : A filter example -for the edges to the neighbors (see below). -* String|Object|Array *neighborExamples* : An example for -the desired neighbors (see below). -* String|Array *edgeCollectionRestriction* : One or multiple -edge collections that should be considered. -// * String|Array *vertexCollectionRestriction* : One or multiple -vertex collections that should be considered. -// / * Number *minDepth* : Defines the minimal -depth a path to a neighbor must have to be returned (default is 1). -* Number *maxDepth* : Defines the maximal -depth a path to a neighbor must have to be returned (default is 1). -
-Examples for vertexExample: -* {} : Returns all possible vertices for this graph. -* *idString* : Returns the vertex with the id *idString*. -* {*key* : *value*} : Returns the vertices that match this example. -* [{*key1* : *value1*}, {*key2* : *value2*}] : Returns the vertices that -match one of the examples. -
-@EXAMPLES -
-A route planner example, all common neighbors of capitals. -
- -``` -arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); -arangosh> var g = examples.loadGraph("routeplanner"); -arangosh> db._query("FOR e IN GRAPH_COMMON_NEIGHBORS(" -........> +"'routeplanner', {isCapital : true}, {isCapital : true}) RETURN e" -........> ).toArray(); -[ - { - "city/Berlin" : { - "city/Munich" : [ - { - "_id" : "city/Cologne", - "_rev" : "410852561", - "_key" : "Cologne", - "isCapital" : false, - "population" : 1000000 - }, - { - "_id" : "village/Olpe", - "_rev" : "411507921", - "_key" : "Olpe", - "isCapital" : false, - "population" : 80000 - }, - { - "_id" : "village/Rosenheim", - "_rev" : "411704529", - "_key" : "Rosenheim", - "isCapital" : false, - "population" : 80000 - } - ] - } - }, - { - "city/Munich" : { - "city/Berlin" : [ - { - "_id" : "city/Cologne", - "_rev" : "410852561", - "_key" : "Cologne", - "isCapital" : false, - "population" : 1000000 - }, - { - "_id" : "village/Olpe", - "_rev" : "411507921", - "_key" : "Olpe", - "isCapital" : false, - "population" : 80000 - }, - { - "_id" : "village/Rosenheim", - "_rev" : "411704529", - "_key" : "Rosenheim", - "isCapital" : false, - "population" : 80000 - } - ] - } - } -] -``` -
-A route planner example, all common outbound neighbors of munich with any other location -which have a maximal depth of 2 : -
- -``` -arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); -arangosh> var g = examples.loadGraph("routeplanner"); -arangosh> db._query("FOR e IN GRAPH_COMMON_NEIGHBORS(" -........> +"'routeplanner', 'city/Munich', {}, {direction : 'outbound', maxDepth : 2}, "+ -........> "{direction : 'outbound', maxDepth : 2}) RETURN e" -........> ).toArray(); -[ - { - "city/Munich" : { - "city/Berlin" : [ - { - "_id" : "city/Cologne", - "_rev" : "416029905", - "_key" : "Cologne", - "isCapital" : false, - "population" : 1000000 - }, - { - "_id" : "village/Olpe", - "_rev" : "416685265", - "_key" : "Olpe", - "isCapital" : false, - "population" : 80000 - }, - { - "_id" : "village/Rosenheim", - "_rev" : "416881873", - "_key" : "Rosenheim", - "isCapital" : false, - "population" : 80000 - } - ], - "city/Cologne" : [ - { - "_id" : "village/Olpe", - "_rev" : "416685265", - "_key" : "Olpe", - "isCapital" : false, - "population" : 80000 - }, - { - "_id" : "village/Rosenheim", - "_rev" : "416881873", - "_key" : "Rosenheim", - "isCapital" : false, - "population" : 80000 - } - ] - } - } -] -``` -
- +@startDocuBlock JSF_ahuacatl_general_graph_common_neighbors !SUBSUBSECTION GRAPH_COMMON_PROPERTIES -
-`GRAPH_COMMON_PROPERTIES (graphName, vertex1Example, vertex2Examples, options)` -*The GRAPH\_COMMON\_PROPERTIES function returns all vertices -defined by the examples that share common properties -
-
-The function accepts an id, an example, a list of examples or even an empty -example as parameter for vertex1Example and vertex2Example. -
-* String *graphName* : The name of the graph. -* String|Object|Array *vertex1Example* : An example for the desired -vertices (see below). -* String|Object|Array *vertex2Example* : An example for the desired -vertices (see below). -* Object *options* : Optional options, see below: -
-Possible options and there defaults: -// * String|Array *vertex1CollectionRestriction* : One or multiple -vertex collections that should be considered. -* String|Array *vertex2CollectionRestriction* : One or multiple -vertex collections that should be considered. -* String|Array *ignoreProperties* : One or multiple -attributes of a document that should be ignored. -
-Examples for vertexExample: -* {} : Returns all possible vertices for this graph. -* *idString* : Returns the vertex with the id *idString*. -* {*key* : *value*} : Returns the vertices that match this example. -* [{*key1* : *value1*}, {*key2* : *value2*}] : Returns the vertices that -match one of the examples. -
-@EXAMPLES -
-A route planner example, all locations with the same properties: -
- -``` -arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); -arangosh> var g = examples.loadGraph("routeplanner"); -arangosh> db._query("FOR e IN GRAPH_COMMON_PROPERTIES(" -........> +"'routeplanner', {}, {}) RETURN e" -........> ).toArray(); -[ - { - "city/Berlin" : [ - { - "_id" : "city/Munich", - "_rev" : "74652881", - "_key" : "Munich", - "isCapital" : true, - "population" : 1000000 - } - ] - }, - { - "city/Munich" : [ - { - "_id" : "city/Berlin", - "_rev" : "74259665", - "_key" : "Berlin", - "isCapital" : true, - "population" : 3000000 - }, - { - "_id" : "city/Cologne", - "_rev" : "74456273", - "_key" : "Cologne", - "isCapital" : false, - "population" : 1000000 - } - ] - }, - { - "city/Cologne" : [ - { - "_id" : "village/Rosenheim", - "_rev" : "75308241", - "_key" : "Rosenheim", - "isCapital" : false, - "population" : 80000 - }, - { - "_id" : "village/Olpe", - "_rev" : "75111633", - "_key" : "Olpe", - "isCapital" : false, - "population" : 80000 - }, - { - "_id" : "city/Munich", - "_rev" : "74652881", - "_key" : "Munich", - "isCapital" : true, - "population" : 1000000 - } - ] - }, - { - "village/Rosenheim" : [ - { - "_id" : "city/Cologne", - "_rev" : "74456273", - "_key" : "Cologne", - "isCapital" : false, - "population" : 1000000 - }, - { - "_id" : "village/Olpe", - "_rev" : "75111633", - "_key" : "Olpe", - "isCapital" : false, - "population" : 80000 - } - ] - }, - { - "village/Olpe" : [ - { - "_id" : "city/Cologne", - "_rev" : "74456273", - "_key" : "Cologne", - "isCapital" : false, - "population" : 1000000 - }, - { - "_id" : "village/Rosenheim", - "_rev" : "75308241", - "_key" : "Rosenheim", - "isCapital" : false, - "population" : 80000 - } - ] - } -] -``` -
-A route planner example, all cities which share same properties except for population. -
- -``` -arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); -arangosh> var g = examples.loadGraph("routeplanner"); -arangosh> db._query("FOR e IN GRAPH_COMMON_PROPERTIES(" -........> +"'routeplanner', {}, {}, {vertex1CollectionRestriction : 'city', " + -........> "vertex2CollectionRestriction : 'city'" + -........> " ,ignoreProperties: 'population'}) RETURN e" -........> ).toArray(); -[ - { - "city/Berlin" : [ - { - "_id" : "city/Munich", - "_rev" : "65871057", - "_key" : "Munich", - "isCapital" : true, - "population" : 1000000 - } - ] - }, - { - "city/Munich" : [ - { - "_id" : "city/Berlin", - "_rev" : "65477841", - "_key" : "Berlin", - "isCapital" : true, - "population" : 3000000 - } - ] - } -] -``` -
- +@startDocuBlock JSF_ahuacatl_general_graph_common_properties !SUBSUBSECTION GRAPH_NEIGHBORS -
-`GRAPH_NEIGHBORS (graphName, vertexExample, options)` -*The GRAPH\_NEIGHBORS function returns all neighbors of vertices.* -
-
-The function accepts an id, an example, a list of examples or even an empty -example as parameter for vertex. -
-* String *graphName* : The name of the graph. -* String|Object|Array *vertexExample* : An example for the desired -vertices (see below). -* Object *options* : Optional options, see below: -
-Possible options and there defaults: -* String *direction* : The direction -of the edges. Possible values are *outbound*, *inbound* and *any* (default). -* String|Object|Array *edgeExamples* : A filter example -for the edges to the neighbors (see below). -* String|Object|Array *neighborExamples* : An example for -the desired neighbors (see below). -* String|Array *edgeCollectionRestriction* : One or multiple -edge collections that should be considered. -* String|Array *vertexCollectionRestriction* : One or multiple -vertex collections that should be considered. -* Number *minDepth* : Defines the minimal -depth a path to a neighbor must have to be returned (default is 1). -* Number *maxDepth* : Defines the maximal -depth a path to a neighbor must have to be returned (default is 1). -
-Examples for edgeExamples/neighborExamples: -* {} : Returns all possible edges/neighbors for this graph. -* *idString* : Returns the edge/vertex with the id *idString*. -* {*key* : *value*} : Returns the edges/vertices that match this example. -* [{*key1* : *value1*}, {*key2* : *value2*}] : Returns the edges/vertices that -match one of the examples. -
-@EXAMPLES -
-A route planner example, all neighbors of locations with a distance of either -700 or 600.: -
- -``` -arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); -arangosh> var g = examples.loadGraph("routeplanner"); -arangosh> db._query("FOR e IN GRAPH_NEIGHBORS(" -........> +"'routeplanner', {}, {edgeExamples : [{distance: 600}, {distance: 700}]}) RETURN e" -........> ).toArray(); -[ - { - "vertex" : { - "_id" : "city/Munich", - "_rev" : "167517393", - "_key" : "Munich", - "isCapital" : true, - "population" : 1000000 - }, - "path" : { - "edges" : [ - { - "_id" : "highway/168762577", - "_rev" : "168762577", - "_key" : "168762577", - "_from" : "city/Berlin", - "_to" : "city/Munich", - "distance" : 600 - } - ], - "vertices" : [ - { - "_id" : "city/Berlin", - "_rev" : "167124177", - "_key" : "Berlin", - "isCapital" : true, - "population" : 3000000 - }, - { - "_id" : "city/Munich", - "_rev" : "167517393", - "_key" : "Munich", - "isCapital" : true, - "population" : 1000000 - } - ] - }, - "startVertex" : "city/Berlin" - }, - { - "vertex" : { - "_id" : "village/Olpe", - "_rev" : "167976145", - "_key" : "Olpe", - "isCapital" : false, - "population" : 80000 - }, - "path" : { - "edges" : [ - { - "_id" : "road/169352401", - "_rev" : "169352401", - "_key" : "169352401", - "_from" : "city/Berlin", - "_to" : "village/Olpe", - "distance" : 700 - } - ], - "vertices" : [ - { - "_id" : "city/Berlin", - "_rev" : "167124177", - "_key" : "Berlin", - "isCapital" : true, - "population" : 3000000 - }, - { - "_id" : "village/Olpe", - "_rev" : "167976145", - "_key" : "Olpe", - "isCapital" : false, - "population" : 80000 - } - ] - }, - "startVertex" : "city/Berlin" - }, - { - "vertex" : { - "_id" : "city/Berlin", - "_rev" : "167124177", - "_key" : "Berlin", - "isCapital" : true, - "population" : 3000000 - }, - "path" : { - "edges" : [ - { - "_id" : "highway/168762577", - "_rev" : "168762577", - "_key" : "168762577", - "_from" : "city/Berlin", - "_to" : "city/Munich", - "distance" : 600 - } - ], - "vertices" : [ - { - "_id" : "city/Munich", - "_rev" : "167517393", - "_key" : "Munich", - "isCapital" : true, - "population" : 1000000 - }, - { - "_id" : "city/Berlin", - "_rev" : "167124177", - "_key" : "Berlin", - "isCapital" : true, - "population" : 3000000 - } - ] - }, - "startVertex" : "city/Munich" - }, - { - "vertex" : { - "_id" : "village/Olpe", - "_rev" : "167976145", - "_key" : "Olpe", - "isCapital" : false, - "population" : 80000 - }, - "path" : { - "edges" : [ - { - "_id" : "road/169942225", - "_rev" : "169942225", - "_key" : "169942225", - "_from" : "city/Munich", - "_to" : "village/Olpe", - "distance" : 600 - } - ], - "vertices" : [ - { - "_id" : "city/Munich", - "_rev" : "167517393", - "_key" : "Munich", - "isCapital" : true, - "population" : 1000000 - }, - { - "_id" : "village/Olpe", - "_rev" : "167976145", - "_key" : "Olpe", - "isCapital" : false, - "population" : 80000 - } - ] - }, - "startVertex" : "city/Munich" - }, - { - "vertex" : { - "_id" : "city/Berlin", - "_rev" : "167124177", - "_key" : "Berlin", - "isCapital" : true, - "population" : 3000000 - }, - "path" : { - "edges" : [ - { - "_id" : "road/169352401", - "_rev" : "169352401", - "_key" : "169352401", - "_from" : "city/Berlin", - "_to" : "village/Olpe", - "distance" : 700 - } - ], - "vertices" : [ - { - "_id" : "village/Olpe", - "_rev" : "167976145", - "_key" : "Olpe", - "isCapital" : false, - "population" : 80000 - }, - { - "_id" : "city/Berlin", - "_rev" : "167124177", - "_key" : "Berlin", - "isCapital" : true, - "population" : 3000000 - } - ] - }, - "startVertex" : "village/Olpe" - }, - { - "vertex" : { - "_id" : "city/Munich", - "_rev" : "167517393", - "_key" : "Munich", - "isCapital" : true, - "population" : 1000000 - }, - "path" : { - "edges" : [ - { - "_id" : "road/169942225", - "_rev" : "169942225", - "_key" : "169942225", - "_from" : "city/Munich", - "_to" : "village/Olpe", - "distance" : 600 - } - ], - "vertices" : [ - { - "_id" : "village/Olpe", - "_rev" : "167976145", - "_key" : "Olpe", - "isCapital" : false, - "population" : 80000 - }, - { - "_id" : "city/Munich", - "_rev" : "167517393", - "_key" : "Munich", - "isCapital" : true, - "population" : 1000000 - } - ] - }, - "startVertex" : "village/Olpe" - } -] -``` -
-A route planner example, all outbound neighbors of munich with a maximal depth of 2 : -
- -``` -arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); -arangosh> var g = examples.loadGraph("routeplanner"); -arangosh> db._query("FOR e IN GRAPH_NEIGHBORS(" -........> +"'routeplanner', 'city/Munich', {direction : 'outbound', maxDepth : 2}) RETURN e" -........> ).toArray(); -[ - { - "vertex" : { - "_id" : "city/Cologne", - "_rev" : "172498129", - "_key" : "Cologne", - "isCapital" : false, - "population" : 1000000 - }, - "path" : { - "edges" : [ - { - "_id" : "highway/174136529", - "_rev" : "174136529", - "_key" : "174136529", - "_from" : "city/Munich", - "_to" : "city/Cologne", - "distance" : 650 - } - ], - "vertices" : [ - { - "_id" : "city/Munich", - "_rev" : "172694737", - "_key" : "Munich", - "isCapital" : true, - "population" : 1000000 - }, - { - "_id" : "city/Cologne", - "_rev" : "172498129", - "_key" : "Cologne", - "isCapital" : false, - "population" : 1000000 - } - ] - }, - "startVertex" : "city/Munich" - }, - { - "vertex" : { - "_id" : "village/Olpe", - "_rev" : "173153489", - "_key" : "Olpe", - "isCapital" : false, - "population" : 80000 - }, - "path" : { - "edges" : [ - { - "_id" : "highway/174136529", - "_rev" : "174136529", - "_key" : "174136529", - "_from" : "city/Munich", - "_to" : "city/Cologne", - "distance" : 650 - }, - { - "_id" : "road/175316177", - "_rev" : "175316177", - "_key" : "175316177", - "_from" : "city/Cologne", - "_to" : "village/Olpe", - "distance" : 100 - } - ], - "vertices" : [ - { - "_id" : "city/Munich", - "_rev" : "172694737", - "_key" : "Munich", - "isCapital" : true, - "population" : 1000000 - }, - { - "_id" : "city/Cologne", - "_rev" : "172498129", - "_key" : "Cologne", - "isCapital" : false, - "population" : 1000000 - }, - { - "_id" : "village/Olpe", - "_rev" : "173153489", - "_key" : "Olpe", - "isCapital" : false, - "population" : 80000 - } - ] - }, - "startVertex" : "city/Munich" - }, - { - "vertex" : { - "_id" : "village/Rosenheim", - "_rev" : "173350097", - "_key" : "Rosenheim", - "isCapital" : false, - "population" : 80000 - }, - "path" : { - "edges" : [ - { - "_id" : "highway/174136529", - "_rev" : "174136529", - "_key" : "174136529", - "_from" : "city/Munich", - "_to" : "city/Cologne", - "distance" : 650 - }, - { - "_id" : "road/175512785", - "_rev" : "175512785", - "_key" : "175512785", - "_from" : "city/Cologne", - "_to" : "village/Rosenheim", - "distance" : 750 - } - ], - "vertices" : [ - { - "_id" : "city/Munich", - "_rev" : "172694737", - "_key" : "Munich", - "isCapital" : true, - "population" : 1000000 - }, - { - "_id" : "city/Cologne", - "_rev" : "172498129", - "_key" : "Cologne", - "isCapital" : false, - "population" : 1000000 - }, - { - "_id" : "village/Rosenheim", - "_rev" : "173350097", - "_key" : "Rosenheim", - "isCapital" : false, - "population" : 80000 - } - ] - }, - "startVertex" : "city/Munich" - }, - { - "vertex" : { - "_id" : "village/Rosenheim", - "_rev" : "173350097", - "_key" : "Rosenheim", - "isCapital" : false, - "population" : 80000 - }, - "path" : { - "edges" : [ - { - "_id" : "road/174922961", - "_rev" : "174922961", - "_key" : "174922961", - "_from" : "city/Munich", - "_to" : "village/Rosenheim", - "distance" : 80 - } - ], - "vertices" : [ - { - "_id" : "city/Munich", - "_rev" : "172694737", - "_key" : "Munich", - "isCapital" : true, - "population" : 1000000 - }, - { - "_id" : "village/Rosenheim", - "_rev" : "173350097", - "_key" : "Rosenheim", - "isCapital" : false, - "population" : 80000 - } - ] - }, - "startVertex" : "city/Munich" - }, - { - "vertex" : { - "_id" : "village/Olpe", - "_rev" : "173153489", - "_key" : "Olpe", - "isCapital" : false, - "population" : 80000 - }, - "path" : { - "edges" : [ - { - "_id" : "road/175119569", - "_rev" : "175119569", - "_key" : "175119569", - "_from" : "city/Munich", - "_to" : "village/Olpe", - "distance" : 600 - } - ], - "vertices" : [ - { - "_id" : "city/Munich", - "_rev" : "172694737", - "_key" : "Munich", - "isCapital" : true, - "population" : 1000000 - }, - { - "_id" : "village/Olpe", - "_rev" : "173153489", - "_key" : "Olpe", - "isCapital" : false, - "population" : 80000 - } - ] - }, - "startVertex" : "city/Munich" - } -] -``` -
- +@startDocuBlock JSF_ahuacatl_general_graph_neighbors !SUBSECTION Shortest Paths, distances and traversals. @@ -1169,1147 +32,23 @@ This section describes AQL functions, that calculate pathes from a subset of ver !SUBSUBSECTION GRAPH_PATHS -
-`GRAPH_PATHS (graphName, direction, followCycles, minLength, maxLength)` -*The GRAPH\_PATHS function returns all paths of a graph.* -
-
-This function determines all available paths in a graph identified by *graphName*. -Except for *graphName* every other parameter is optional. -
-* String *graphName* : The name of the graph. -* String *direction* : The direction of the edges. -Possible values are *any*, *inbound* and *outbound* (default). -* Boolean *followCycles* : If set to *true* the query follows cycles in the graph, -default is false. -* Number *minLength* : Defines the minimal length a path must -have to be returned (default is 0). -* Number *maxLength* : 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("org/arangodb/graph-examples/example-graph.js"); -arangosh> var g = examples.loadGraph("social"); -arangosh> db._query("RETURN GRAPH_PATHS('social')").toArray(); -[ - [ - { - "vertices" : [ - { - "_id" : "female/alice", - "_rev" : "134749393", - "_key" : "alice", - "name" : "Alice" - } - ], - "edges" : [ ], - "source" : { - "_id" : "female/alice", - "_rev" : "134749393", - "_key" : "alice", - "name" : "Alice" - }, - "destination" : { - "_id" : "female/alice", - "_rev" : "134749393", - "_key" : "alice", - "name" : "Alice" - } - }, - { - "vertices" : [ - { - "_id" : "female/alice", - "_rev" : "134749393", - "_key" : "alice", - "name" : "Alice" - }, - { - "_id" : "male/bob", - "_rev" : "135142609", - "_key" : "bob", - "name" : "Bob" - } - ], - "edges" : [ - { - "_id" : "relation/aliceAndBob", - "_rev" : "135929041", - "_key" : "aliceAndBob", - "_from" : "female/alice", - "_to" : "male/bob", - "type" : "married" - } - ], - "source" : { - "_id" : "female/alice", - "_rev" : "134749393", - "_key" : "alice", - "name" : "Alice" - }, - "destination" : { - "_id" : "male/bob", - "_rev" : "135142609", - "_key" : "bob", - "name" : "Bob" - } - }, - { - "vertices" : [ - { - "_id" : "female/alice", - "_rev" : "134749393", - "_key" : "alice", - "name" : "Alice" - }, - { - "_id" : "male/bob", - "_rev" : "135142609", - "_key" : "bob", - "name" : "Bob" - }, - { - "_id" : "female/diana", - "_rev" : "135535825", - "_key" : "diana", - "name" : "Diana" - } - ], - "edges" : [ - { - "_id" : "relation/aliceAndBob", - "_rev" : "135929041", - "_key" : "aliceAndBob", - "_from" : "female/alice", - "_to" : "male/bob", - "type" : "married" - }, - { - "_id" : "relation/bobAndDiana", - "_rev" : "136584401", - "_key" : "bobAndDiana", - "_from" : "male/bob", - "_to" : "female/diana", - "type" : "friend" - } - ], - "source" : { - "_id" : "female/alice", - "_rev" : "134749393", - "_key" : "alice", - "name" : "Alice" - }, - "destination" : { - "_id" : "female/diana", - "_rev" : "135535825", - "_key" : "diana", - "name" : "Diana" - } - }, - { - "vertices" : [ - { - "_id" : "female/alice", - "_rev" : "134749393", - "_key" : "alice", - "name" : "Alice" - }, - { - "_id" : "male/charly", - "_rev" : "135339217", - "_key" : "charly", - "name" : "Charly" - } - ], - "edges" : [ - { - "_id" : "relation/aliceAndCharly", - "_rev" : "136191185", - "_key" : "aliceAndCharly", - "_from" : "female/alice", - "_to" : "male/charly", - "type" : "friend" - } - ], - "source" : { - "_id" : "female/alice", - "_rev" : "134749393", - "_key" : "alice", - "name" : "Alice" - }, - "destination" : { - "_id" : "male/charly", - "_rev" : "135339217", - "_key" : "charly", - "name" : "Charly" - } - }, - { - "vertices" : [ - { - "_id" : "female/alice", - "_rev" : "134749393", - "_key" : "alice", - "name" : "Alice" - }, - { - "_id" : "male/charly", - "_rev" : "135339217", - "_key" : "charly", - "name" : "Charly" - }, - { - "_id" : "female/diana", - "_rev" : "135535825", - "_key" : "diana", - "name" : "Diana" - } - ], - "edges" : [ - { - "_id" : "relation/aliceAndCharly", - "_rev" : "136191185", - "_key" : "aliceAndCharly", - "_from" : "female/alice", - "_to" : "male/charly", - "type" : "friend" - }, - { - "_id" : "relation/charlyAndDiana", - "_rev" : "136387793", - "_key" : "charlyAndDiana", - "_from" : "male/charly", - "_to" : "female/diana", - "type" : "married" - } - ], - "source" : { - "_id" : "female/alice", - "_rev" : "134749393", - "_key" : "alice", - "name" : "Alice" - }, - "destination" : { - "_id" : "female/diana", - "_rev" : "135535825", - "_key" : "diana", - "name" : "Diana" - } - }, - { - "vertices" : [ - { - "_id" : "female/diana", - "_rev" : "135535825", - "_key" : "diana", - "name" : "Diana" - } - ], - "edges" : [ ], - "source" : { - "_id" : "female/diana", - "_rev" : "135535825", - "_key" : "diana", - "name" : "Diana" - }, - "destination" : { - "_id" : "female/diana", - "_rev" : "135535825", - "_key" : "diana", - "name" : "Diana" - } - }, - { - "vertices" : [ - { - "_id" : "male/bob", - "_rev" : "135142609", - "_key" : "bob", - "name" : "Bob" - } - ], - "edges" : [ ], - "source" : { - "_id" : "male/bob", - "_rev" : "135142609", - "_key" : "bob", - "name" : "Bob" - }, - "destination" : { - "_id" : "male/bob", - "_rev" : "135142609", - "_key" : "bob", - "name" : "Bob" - } - }, - { - "vertices" : [ - { - "_id" : "male/bob", - "_rev" : "135142609", - "_key" : "bob", - "name" : "Bob" - }, - { - "_id" : "female/diana", - "_rev" : "135535825", - "_key" : "diana", - "name" : "Diana" - } - ], - "edges" : [ - { - "_id" : "relation/bobAndDiana", - "_rev" : "136584401", - "_key" : "bobAndDiana", - "_from" : "male/bob", - "_to" : "female/diana", - "type" : "friend" - } - ], - "source" : { - "_id" : "male/bob", - "_rev" : "135142609", - "_key" : "bob", - "name" : "Bob" - }, - "destination" : { - "_id" : "female/diana", - "_rev" : "135535825", - "_key" : "diana", - "name" : "Diana" - } - }, - { - "vertices" : [ - { - "_id" : "male/charly", - "_rev" : "135339217", - "_key" : "charly", - "name" : "Charly" - } - ], - "edges" : [ ], - "source" : { - "_id" : "male/charly", - "_rev" : "135339217", - "_key" : "charly", - "name" : "Charly" - }, - "destination" : { - "_id" : "male/charly", - "_rev" : "135339217", - "_key" : "charly", - "name" : "Charly" - } - }, - { - "vertices" : [ - { - "_id" : "male/charly", - "_rev" : "135339217", - "_key" : "charly", - "name" : "Charly" - }, - { - "_id" : "female/diana", - "_rev" : "135535825", - "_key" : "diana", - "name" : "Diana" - } - ], - "edges" : [ - { - "_id" : "relation/charlyAndDiana", - "_rev" : "136387793", - "_key" : "charlyAndDiana", - "_from" : "male/charly", - "_to" : "female/diana", - "type" : "married" - } - ], - "source" : { - "_id" : "male/charly", - "_rev" : "135339217", - "_key" : "charly", - "name" : "Charly" - }, - "destination" : { - "_id" : "female/diana", - "_rev" : "135535825", - "_key" : "diana", - "name" : "Diana" - } - } - ] -] -``` -
-Return all inbound paths of the graph "social" with a maximal -length of 1 and a minimal length of 2: -
- -``` -arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); -arangosh> var g = examples.loadGraph("social"); -arangosh> db._query("RETURN GRAPH_PATHS('social', 'inbound', false, 1, 2)").toArray(); -[ - [ - { - "vertices" : [ - { - "_id" : "female/diana", - "_rev" : "281353425", - "_key" : "diana", - "name" : "Diana" - }, - { - "_id" : "male/charly", - "_rev" : "281156817", - "_key" : "charly", - "name" : "Charly" - } - ], - "edges" : [ - { - "_id" : "relation/charlyAndDiana", - "_rev" : "282205393", - "_key" : "charlyAndDiana", - "_from" : "male/charly", - "_to" : "female/diana", - "type" : "married" - } - ], - "source" : { - "_id" : "female/diana", - "_rev" : "281353425", - "_key" : "diana", - "name" : "Diana" - }, - "destination" : { - "_id" : "male/charly", - "_rev" : "281156817", - "_key" : "charly", - "name" : "Charly" - } - }, - { - "vertices" : [ - { - "_id" : "female/diana", - "_rev" : "281353425", - "_key" : "diana", - "name" : "Diana" - }, - { - "_id" : "male/charly", - "_rev" : "281156817", - "_key" : "charly", - "name" : "Charly" - }, - { - "_id" : "female/alice", - "_rev" : "280566993", - "_key" : "alice", - "name" : "Alice" - } - ], - "edges" : [ - { - "_id" : "relation/charlyAndDiana", - "_rev" : "282205393", - "_key" : "charlyAndDiana", - "_from" : "male/charly", - "_to" : "female/diana", - "type" : "married" - }, - { - "_id" : "relation/aliceAndCharly", - "_rev" : "282008785", - "_key" : "aliceAndCharly", - "_from" : "female/alice", - "_to" : "male/charly", - "type" : "friend" - } - ], - "source" : { - "_id" : "female/diana", - "_rev" : "281353425", - "_key" : "diana", - "name" : "Diana" - }, - "destination" : { - "_id" : "female/alice", - "_rev" : "280566993", - "_key" : "alice", - "name" : "Alice" - } - }, - { - "vertices" : [ - { - "_id" : "female/diana", - "_rev" : "281353425", - "_key" : "diana", - "name" : "Diana" - }, - { - "_id" : "male/bob", - "_rev" : "280960209", - "_key" : "bob", - "name" : "Bob" - } - ], - "edges" : [ - { - "_id" : "relation/bobAndDiana", - "_rev" : "282402001", - "_key" : "bobAndDiana", - "_from" : "male/bob", - "_to" : "female/diana", - "type" : "friend" - } - ], - "source" : { - "_id" : "female/diana", - "_rev" : "281353425", - "_key" : "diana", - "name" : "Diana" - }, - "destination" : { - "_id" : "male/bob", - "_rev" : "280960209", - "_key" : "bob", - "name" : "Bob" - } - }, - { - "vertices" : [ - { - "_id" : "female/diana", - "_rev" : "281353425", - "_key" : "diana", - "name" : "Diana" - }, - { - "_id" : "male/bob", - "_rev" : "280960209", - "_key" : "bob", - "name" : "Bob" - }, - { - "_id" : "female/alice", - "_rev" : "280566993", - "_key" : "alice", - "name" : "Alice" - } - ], - "edges" : [ - { - "_id" : "relation/bobAndDiana", - "_rev" : "282402001", - "_key" : "bobAndDiana", - "_from" : "male/bob", - "_to" : "female/diana", - "type" : "friend" - }, - { - "_id" : "relation/aliceAndBob", - "_rev" : "281746641", - "_key" : "aliceAndBob", - "_from" : "female/alice", - "_to" : "male/bob", - "type" : "married" - } - ], - "source" : { - "_id" : "female/diana", - "_rev" : "281353425", - "_key" : "diana", - "name" : "Diana" - }, - "destination" : { - "_id" : "female/alice", - "_rev" : "280566993", - "_key" : "alice", - "name" : "Alice" - } - }, - { - "vertices" : [ - { - "_id" : "male/bob", - "_rev" : "280960209", - "_key" : "bob", - "name" : "Bob" - }, - { - "_id" : "female/alice", - "_rev" : "280566993", - "_key" : "alice", - "name" : "Alice" - } - ], - "edges" : [ - { - "_id" : "relation/aliceAndBob", - "_rev" : "281746641", - "_key" : "aliceAndBob", - "_from" : "female/alice", - "_to" : "male/bob", - "type" : "married" - } - ], - "source" : { - "_id" : "male/bob", - "_rev" : "280960209", - "_key" : "bob", - "name" : "Bob" - }, - "destination" : { - "_id" : "female/alice", - "_rev" : "280566993", - "_key" : "alice", - "name" : "Alice" - } - }, - { - "vertices" : [ - { - "_id" : "male/charly", - "_rev" : "281156817", - "_key" : "charly", - "name" : "Charly" - }, - { - "_id" : "female/alice", - "_rev" : "280566993", - "_key" : "alice", - "name" : "Alice" - } - ], - "edges" : [ - { - "_id" : "relation/aliceAndCharly", - "_rev" : "282008785", - "_key" : "aliceAndCharly", - "_from" : "female/alice", - "_to" : "male/charly", - "type" : "friend" - } - ], - "source" : { - "_id" : "male/charly", - "_rev" : "281156817", - "_key" : "charly", - "name" : "Charly" - }, - "destination" : { - "_id" : "female/alice", - "_rev" : "280566993", - "_key" : "alice", - "name" : "Alice" - } - } - ] -] -``` - +@startDocuBlock JSF_ahuacatl_general_graph_paths !SUBSUBSECTION GRAPH_SHORTEST_PATH -
-`GRAPH_SHORTEST_PATH (graphName, startVertexExample, endVertexExample, options)` -*The GRAPH\_SHORTEST\_PATH function returns all shortest paths of a graph.* -
-
-This function determines all shortest paths in a graph identified by *graphName*. -The function accepts an id, an example, a list of examples -or even an empty example as parameter for -start and end vertex. If one wants to calls this function to receive nearly all -shortest paths for a graph the -option *algorithm* should be set to *Floyd-Warshall* to increase performance. -If no algorithm is provided in the options the function chooses the appropriate -one (either *Floyd-Warshall* or *Dijsktra*) 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. -
-* String *graphName* : The name of the graph. -* String|Object|Array *startVertexExample* : An example for the desired -start Vertices (see below). -* String|Object|Array *endVertexExample* : An example for the desired -end Vertices (see below). -* Object *options* : Optional options, see below: -
-Possible options and there defaults: -* String *direction* : The direction of the edges. -Possible values are *outbound*, *inbound* and *any* (default). -* String|Array *edgeCollectionRestriction* : One or multiple edge -collections that should be considered. -* String|Array *startVertexCollectionRestriction* : One or multiple vertex -collections that should be considered. -* String|Array *endVertexCollectionRestriction* : One or multiple vertex -collections that should be considered. -* String|Object|Array *edgeExamples* : A filter example for the -edges in the shortest paths (see below). -* String *algorithm* : The algorithm to calculate -the shortest paths. If both start and end vertex examples are empty *Floyd-Warshall* is -used, otherwise the default is *Dijkstra* -* String *weight* : The name of the attribute of -the edges containing the length. -* Number *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. -
-Examples for startVertexExample/endVertexExample: -* {} : Returns all possible start/end vertices for this graph. -* *idString* : Returns the vertex with the id *idString*. -* {*key* : *value*} : Returns the vertices that match this example. -* [{*key1* : *value1*}, {*key2* : *value2*}] : Returns the vertices that match one of -the examples. -
-@EXAMPLES -
-A route planner example, shortest distance from all villages to other cities: -
- -``` -arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); -arangosh> var g = examples.loadGraph("routeplanner"); -arangosh> db._query("FOR e IN GRAPH_SHORTEST_PATH(" -........> +"'routeplanner', {}, {}, {weight : 'distance', endVertexCollectionRestriction : 'city', " + -........> "startVertexCollectionRestriction : 'village'}) RETURN [e.startVertex, e.vertex._id, " + -........> "e.distance, LENGTH(e.paths)]" -........> ).toArray(); -[ - [ - "village/Olpe", - "city/Munich", - 600, - 1 - ], - [ - "village/Olpe", - "city/Cologne", - 100, - 1 - ], - [ - "village/Olpe", - "city/Berlin", - 700, - 1 - ], - [ - "village/Rosenheim", - "city/Berlin", - 680, - 1 - ], - [ - "village/Rosenheim", - "city/Munich", - 80, - 1 - ], - [ - "village/Rosenheim", - "city/Cologne", - 730, - 1 - ] -] -``` -
-A route planner example, shortest distance from Munich and Cologne to Olpe: -
- -``` -arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); -arangosh> var g = examples.loadGraph("routeplanner"); -arangosh> db._query("FOR e IN GRAPH_SHORTEST_PATH(" -........> +"'routeplanner', [{_id: 'city/Cologne'},{_id: 'city/Munich'}], 'village/Olpe', " + -........> "{weight : 'distance'}) RETURN [e.startVertex, e.vertex._id, e.distance, LENGTH(e.paths)]" -........> ).toArray(); -[ - [ - "city/Cologne", - "village/Olpe", - 100, - 1 - ], - [ - "city/Munich", - "village/Olpe", - 600, - 1 - ] -] -``` -
- +@startDocuBlock JSF_ahuacatl_general_graph_shortest_paths !SUBSUBSECTION GRAPH_TRAVERSAL -
-`GRAPH_TRAVERSAL (graphName, startVertexExample, direction, options)` -*The GRAPH\_TRAVERSAL function traverses through the graph.* -
-
-This function performs traversals on the given graph. -For a more detailed documentation on the optional parameters see -[Traversals](../Traversals/README.md). -
-* String *graphName* : The name of the graph. -* String|Object|Array *startVerte* : The ID of the start vertex of the traversal. -* String|Object|Array *direction* : The direction of the edges. Possible values -are *outbound*, *inbound* and *any* (default). -* Object *options* : Optional options, see below: -
-@EXAMPLES -
-A route planner example, start a traversal from Munich : -
- -``` -arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); -arangosh> var g = examples.loadGraph("routeplanner"); -arangosh> db._query("FOR e IN GRAPH_TRAVERSAL('routeplanner', 'city/Munich'," + -........> " 'outbound') RETURN e" -........> ).toArray(); -[ - { - "vertex" : { - "_id" : "city/Munich", - "_rev" : "349117649", - "_key" : "Munich", - "isCapital" : true, - "population" : 1000000 - } - }, - { - "vertex" : { - "_id" : "city/Cologne", - "_rev" : "348921041", - "_key" : "Cologne", - "isCapital" : false, - "population" : 1000000 - } - }, - { - "vertex" : { - "_id" : "village/Olpe", - "_rev" : "349576401", - "_key" : "Olpe", - "isCapital" : false, - "population" : 80000 - } - }, - { - "vertex" : { - "_id" : "village/Rosenheim", - "_rev" : "349773009", - "_key" : "Rosenheim", - "isCapital" : false, - "population" : 80000 - } - }, - { - "vertex" : { - "_id" : "village/Rosenheim", - "_rev" : "349773009", - "_key" : "Rosenheim", - "isCapital" : false, - "population" : 80000 - } - }, - { - "vertex" : { - "_id" : "village/Olpe", - "_rev" : "349576401", - "_key" : "Olpe", - "isCapital" : false, - "population" : 80000 - } - } -] -``` -
-A route planner example, start a traversal from Munich with a max depth of 1 -so only the direct neighbors of munich are returned: -
- -``` -arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); -arangosh> var g = examples.loadGraph("routeplanner"); -arangosh> db._query("FOR e IN GRAPH_TRAVERSAL('routeplanner', 'city/Munich'," + -........> " 'outbound', {maxDepth : 1}) RETURN e" -........> ).toArray(); -[ - { - "vertex" : { - "_id" : "city/Munich", - "_rev" : "354294993", - "_key" : "Munich", - "isCapital" : true, - "population" : 1000000 - } - }, - { - "vertex" : { - "_id" : "city/Cologne", - "_rev" : "354098385", - "_key" : "Cologne", - "isCapital" : false, - "population" : 1000000 - } - }, - { - "vertex" : { - "_id" : "village/Rosenheim", - "_rev" : "354950353", - "_key" : "Rosenheim", - "isCapital" : false, - "population" : 80000 - } - }, - { - "vertex" : { - "_id" : "village/Olpe", - "_rev" : "354753745", - "_key" : "Olpe", - "isCapital" : false, - "population" : 80000 - } - } -] -``` -
- +@startDocuBlock JSF_ahuacatl_general_graph_traversal !SUBSUBSECTION GRAPH_TRAVERSAL_TREE -
-`GRAPH_TRAVERSAL_TREE (graphName, startVertexExample, direction, connectName, options)` -*The GRAPH\_TRAVERSAL\_TREE function traverses through the graph.* -
-
-This function creates a tree format from the result for a better visualization of -the path. -This function performs traversals on the given graph. -For a more detailed documentation on the optional parameters see -[Traversals](../Traversals/README.md). -
-* String *graphName* : The name of the graph. -* String|Object|Array *startVerte* : The ID of the start vertex -of the traversal. -* String|Object|Array *direction* : The direction of the edges. -Possible values are *outbound*, *inbound* and *any* (default). -* String|Object|Array *connectName* : The result attribute which -contains the connection. -* Object *options* : Optional options, see below: -
-@EXAMPLES -
-A route planner example, start a traversal from Munich : -
- -``` -arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); -arangosh> var g = examples.loadGraph("routeplanner"); -arangosh> db._query("FOR e IN GRAPH_TRAVERSAL_TREE('routeplanner', 'city/Munich'," + -........> " 'outbound', 'connnection') RETURN e" -........> ).toArray(); -[ - [ - { - "_id" : "city/Munich", - "_rev" : "392830161", - "_key" : "Munich", - "isCapital" : true, - "population" : 1000000, - "connnection" : [ - { - "_id" : "city/Cologne", - "_rev" : "392633553", - "_key" : "Cologne", - "isCapital" : false, - "population" : 1000000, - "connnection" : [ - { - "_id" : "village/Olpe", - "_rev" : "393288913", - "_key" : "Olpe", - "isCapital" : false, - "population" : 80000 - }, - { - "_id" : "village/Rosenheim", - "_rev" : "393485521", - "_key" : "Rosenheim", - "isCapital" : false, - "population" : 80000 - } - ] - }, - { - "_id" : "village/Rosenheim", - "_rev" : "393485521", - "_key" : "Rosenheim", - "isCapital" : false, - "population" : 80000 - }, - { - "_id" : "village/Olpe", - "_rev" : "393288913", - "_key" : "Olpe", - "isCapital" : false, - "population" : 80000 - } - ] - } - ] -] -``` -
-A route planner example, start a traversal from Munich with a max depth of 1 so -only the direct neighbors of munich are returned: -
- -``` -arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); -arangosh> var g = examples.loadGraph("routeplanner"); -arangosh> db._query("FOR e IN GRAPH_TRAVERSAL_TREE('routeplanner', 'city/Munich',"+ -........> " 'outbound', 'connnection', {maxDepth : 1}) RETURN e" -........> ).toArray(); -[ - [ - { - "_id" : "city/Munich", - "_rev" : "109255889", - "_key" : "Munich", - "isCapital" : true, - "population" : 1000000, - "connnection" : [ - { - "_id" : "city/Cologne", - "_rev" : "109059281", - "_key" : "Cologne", - "isCapital" : false, - "population" : 1000000 - }, - { - "_id" : "village/Rosenheim", - "_rev" : "109911249", - "_key" : "Rosenheim", - "isCapital" : false, - "population" : 80000 - }, - { - "_id" : "village/Olpe", - "_rev" : "109714641", - "_key" : "Olpe", - "isCapital" : false, - "population" : 80000 - } - ] - } - ] -] -``` -
- +@startDocuBlock JSF_ahuacatl_general_graph_traversal_tree !SUBSUBSECTION GRAPH_DISTANCE_TO -
-`GRAPH_DISTANCE_TO (graphName, startVertexExample, endVertexExample, options)` -*The GRAPH\_DISTANCE\_TO function returns all paths and there distance within a graph.* -
-
-This function is a wrapper of [GRAPH\_SHORTEST\_PATH](#SUBSUBSECTION GRAPH_SHORTEST_PATH). -It does not return the actual path but only the distance between two vertices. -
-@EXAMPLES -
-A route planner example, distance from all villages to other cities: -
- -``` -arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); -arangosh> var g = examples.loadGraph("routeplanner"); -arangosh> db._query("FOR e IN GRAPH_DISTANCE_TO(" -........> +"'routeplanner', {}, {}, {weight : 'distance', endVertexCollectionRestriction : 'city', " + -........> "startVertexCollectionRestriction : 'village'}) RETURN [e.startVertex, e.vertex._id, " + -........> "e.distance]" -........> ).toArray(); -[ - [ - "village/Rosenheim", - "city/Cologne", - 730 - ], - [ - "village/Rosenheim", - "city/Berlin", - 680 - ], - [ - "village/Rosenheim", - "city/Munich", - 80 - ], - [ - "village/Olpe", - "city/Munich", - 600 - ], - [ - "village/Olpe", - "city/Cologne", - 100 - ], - [ - "village/Olpe", - "city/Berlin", - 700 - ] -] -``` -
-A route planner example, distance from Munich and Cologne to Olpe: -
- -``` -arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); -arangosh> var g = examples.loadGraph("routeplanner"); -arangosh> db._query("FOR e IN GRAPH_DISTANCE_TO(" -........> +"'routeplanner', [{_id: 'city/Cologne'},{_id: 'city/Munich'}], 'village/Olpe', " + -........> "{weight : 'distance'}) RETURN [e.startVertex, e.vertex._id, e.distance]" -........> ).toArray(); -[ - [ - "city/Cologne", - "village/Olpe", - 100 - ], - [ - "city/Munich", - "village/Olpe", - 600 - ] -] -``` -
- +@startDocuBlock JSF_ahuacatl_general_graph_distance !SUBSECTION Graph measurements. @@ -2317,705 +56,33 @@ This section describes AQL functions to calculate various graph related measurem !SUBSUBSECTION GRAPH_ABSOLUTE_ECCENTRICITY -
-`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 function accepts an id, an example, a list of examples or even an empty -example as parameter for vertexExample. -
-* String *graphName* : The name of the graph. -* String|Object|Array *vertexExample* : An example for the desired -vertices (see below). -* Object *options* : Optional options, see below: -
-Possible options and there defaults: -* String *direction* : The direction of the edges. -Possible values are *outbound*, *inbound* and *any* (default). -* String|Array *edgeCollectionRestriction* : One or multiple edge -collections that should be considered. -* String|Array *startVertexCollectionRestriction* : One or multiple vertex -collections that should be considered. -* String|Array *endVertexCollectionRestriction* : One or multiple vertex -collections that should be considered. -* String|Object|Array *edgeExamples* : A filter example for the -edges in the shortest paths (see below). -* String *algorithm* : The algorithm to calculate -the shortest paths. -* String *weight* : The name of the attribute of -the edges containing the length. -* Number *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 for vertexExample: -* {} : Returns all possible vertices for this graph. -* *idString* : Returns the vertex with the id *idString*. -* {*key* : *value*} : Returns the vertices that match this example. -* [{*key1* : *value1*}, {*key2* : *value2*}] : Returns the vertices that -match one of the examples. -
-@EXAMPLES -
-A route planner example, the absolute eccentricity of all locations. -
- -``` -arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); -arangosh> var g = examples.loadGraph("routeplanner"); -arangosh> db._query("RETURN GRAPH_ABSOLUTE_ECCENTRICITY(" -........> +"'routeplanner', {})" -........> ).toArray(); -[ - { - "city/Berlin" : 1, - "city/Munich" : 1, - "city/Cologne" : 1, - "village/Rosenheim" : 2, - "village/Olpe" : 2 - } -] -``` -
-A route planner example, the absolute eccentricity of all locations. -This considers the actual distances. -
- -``` -arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); -arangosh> var g = examples.loadGraph("routeplanner"); -arangosh> db._query("RETURN GRAPH_ABSOLUTE_ECCENTRICITY(" -........> +"'routeplanner', {}, {weight : 'distance'})" -........> ).toArray(); -[ - { - "city/Berlin" : 800, - "city/Cologne" : 800, - "city/Munich" : 650, - "village/Olpe" : 700, - "village/Rosenheim" : 730 - } -] -``` -
-A route planner example, the absolute eccentricity of all cities regarding only -outbound pathes. -
- -``` -arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); -arangosh> var g = examples.loadGraph("routeplanner"); -arangosh> db._query("RETURN GRAPH_ABSOLUTE_ECCENTRICITY(" -........> + "'routeplanner', {}, {startVertexCollectionRestriction : 'city', " + -........> "direction : 'outbound', weight : 'distance'})" -........> ).toArray(); -[ - { - "city/Berlin" : 850, - "city/Munich" : 650, - "city/Cologne" : 750 - } -] -``` -
- +@startDocuBlock JSF_ahuacatl_general_graph_absolute_eccentricity !SUBSUBSECTION GRAPH_ECCENTRICITY -
-`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 -
-
-* String *graphName* : The name of the graph. -* Object *options* : Optional options, see below: -
-Possible options and there defaults: -* String *direction* : The direction of the edges. -Possible values are *outbound*, *inbound* and *any* (default). -* String *algorithm* : The algorithm to calculate -the shortest paths. -* String *weight* : The name of the attribute of -the edges containing the length. -* Number *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. -
- -``` -arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); -arangosh> var g = examples.loadGraph("routeplanner"); -arangosh> db._query("RETURN GRAPH_ECCENTRICITY(" -........> +"'routeplanner')" -........> ).toArray(); -[ - { - "city/Munich" : 1, - "city/Cologne" : 1, - "city/Berlin" : 1, - "village/Olpe" : 0.5, - "village/Rosenheim" : 0.5 - } -] -``` -
-A route planner example, the eccentricity of all locations. -This considers the actual distances. -
- -``` -arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); -arangosh> var g = examples.loadGraph("routeplanner"); -arangosh> db._query("RETURN GRAPH_ECCENTRICITY(" -........> +"'routeplanner', {weight : 'distance'})" -........> ).toArray(); -[ - { - "city/Berlin" : 0.8125, - "city/Munich" : 1, - "city/Cologne" : 0.8125, - "village/Rosenheim" : 0.8904109589041096, - "village/Olpe" : 0.9285714285714286 - } -] -``` -
- +@startDocuBlock JSF_ahuacatl_general_graph_eccentricity !SUBSUBSECTION GRAPH_ABSOLUTE_CLOSENESS -
-`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 function accepts an id, an example, a list of examples or even an empty -example as parameter for vertexExample. -
-* String *graphName* : The name of the graph. -* String|Object|Array *vertexExample* : An example for the desired -vertices (see below). -* Object *options* : Optional options, see below: -
-Possible options and there defaults: -* String *direction* : The direction of the edges. -Possible values are *outbound*, *inbound* and *any* (default). -* String|Array *edgeCollectionRestriction* : One or multiple edge -collections that should be considered. -* String|Array *startVertexCollectionRestriction* : One or multiple vertex -collections that should be considered. -* String|Array *endVertexCollectionRestriction* : One or multiple vertex -collections that should be considered. -* String|Object|Array *edgeExamples* : A filter example for the -edges in the shortest paths (see below). -* String *algorithm* : The algorithm to calculate -the shortest paths. -* String *weight* : The name of the attribute of -the edges containing the length. -* Number *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 for vertexExample: -* {} : Returns all possible vertices for this graph. -* *idString* : Returns the vertex with the id *idString*. -* {*key* : *value*} : Returns the vertices that match this example. -* [{*key1* : *value1*}, {*key2* : *value2*}] : Returns the vertices that -match one of the examples. -
-@EXAMPLES -
-A route planner example, the absolute closeness of all locations. -
- -``` -arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); -arangosh> var g = examples.loadGraph("routeplanner"); -arangosh> db._query("RETURN GRAPH_ABSOLUTE_CLOSENESS(" -........> +"'routeplanner', {})" -........> ).toArray(); -[ - { - "city/Munich" : 4, - "city/Cologne" : 4, - "city/Berlin" : 4, - "village/Olpe" : 5, - "village/Rosenheim" : 5 - } -] -``` -
-A route planner example, the absolute closeness of all locations. -This considers the actual distances. -
- -``` -arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); -arangosh> var g = examples.loadGraph("routeplanner"); -arangosh> db._query("RETURN GRAPH_ABSOLUTE_CLOSENESS(" -........> +"'routeplanner', {}, {weight : 'distance'})" -........> ).toArray(); -[ - { - "city/Berlin" : 2780, - "city/Munich" : 1930, - "city/Cologne" : 2280, - "village/Rosenheim" : 2170, - "village/Olpe" : 2080 - } -] -``` -
-A route planner example, the absolute closeness of all cities regarding only -outbound pathes. -
- -``` -arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); -arangosh> var g = examples.loadGraph("routeplanner"); -arangosh> db._query("RETURN GRAPH_ABSOLUTE_CLOSENESS(" -........> + "'routeplanner', {}, {startVertexCollectionRestriction : 'city', " + -........> "direction : 'outbound', weight : 'distance'})" -........> ).toArray(); -[ - { - "city/Berlin" : 2830, - "city/Munich" : 1330, - "city/Cologne" : 850 - } -] -``` -
- +@startDocuBlock JSF_ahuacatl_general_graph_absolute_closeness !SUBSUBSECTION GRAPH_CLOSENESS -
-`GRAPH_CLOSENESS (graphName, options)` -*The GRAPH\_CLOSENESS function returns the normalized -[closeness](http://en.wikipedia.org/wiki/Centrality#Closeness_centrality) -of graphs vertices.* -
-
-* String *graphName* : The name of the graph. -* Object *options* : Optional options, see below: -
-Possible options and there defaults: -* String *direction* : The direction of the edges. -Possible values are *outbound*, *inbound* and *any* (default). -* String *algorithm* : The algorithm to calculate -the shortest paths. -* String *weight* : The name of the attribute of -the edges containing the length. -* Number *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. -
- -``` -arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); -arangosh> var g = examples.loadGraph("routeplanner"); -arangosh> db._query("RETURN GRAPH_CLOSENESS(" -........> +"'routeplanner')" -........> ).toArray(); -[ - { - "city/Berlin" : 1, - "city/Cologne" : 1, - "city/Munich" : 1, - "village/Olpe" : 0.8, - "village/Rosenheim" : 0.8 - } -] -``` -
-A route planner example, the closeness of all locations. -This considers the actual distances. -
- -``` -arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); -arangosh> var g = examples.loadGraph("routeplanner"); -arangosh> db._query("RETURN GRAPH_CLOSENESS(" -........> +"'routeplanner', {weight : 'distance'})" -........> ).toArray(); -[ - { - "city/Berlin" : 0.6942446043165468, - "city/Cologne" : 0.8464912280701755, - "city/Munich" : 1, - "village/Rosenheim" : 0.8894009216589862, - "village/Olpe" : 0.9278846153846155 - } -] -``` -
-A route planner example, the absolute closeness of all cities regarding only -outbound pathes. -
- -``` -arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); -arangosh> var g = examples.loadGraph("routeplanner"); -arangosh> db._query("RETURN GRAPH_CLOSENESS(" -........> + "'routeplanner',{direction : 'outbound', weight : 'distance'})" -........> ).toArray(); -[ - { - "city/Berlin" : 0.3656319670725433, - "city/Munich" : 1, - "city/Cologne" : 0.7216326530612246, - "village/Rosenheim" : 0, - "village/Olpe" : 0 - } -] -``` -
- +@startDocuBlock JSF_ahuacatl_general_graph_closeness !SUBSUBSECTION GRAPH_ABSOLUTE_BETWEENNESS -
-`GRAPH_ABSOLUTE_BETWEENNESS (graphName, vertexExample, options)` -*The GRAPH\_ABSOLUTE\_BETWEENNESS function returns the -[betweenness](http://en.wikipedia.org/wiki/Betweenness_centrality) -of all vertices in the graph.* -
-
-* String *graphName* : The name of the graph. -* Object *options* : Optional options, see below: -
-Possible options and there defaults: -* String *direction* : The direction of the edges. -Possible values are *outbound*, *inbound* and *any* (default). -* String *weight* : The name of the attribute of -the edges containing the length. -* Number *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 betweenness of all locations. -
- -``` -arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); -arangosh> var g = examples.loadGraph("routeplanner"); -arangosh> db._query("RETURN GRAPH_ABSOLUTE_BETWEENNESS(" -........> +"'routeplanner', {})" -........> ).toArray(); -[ - { - "city/Berlin" : 0.6666666666666666, - "city/Cologne" : 0.6666666666666666, - "city/Munich" : 0.6666666666666666, - "village/Olpe" : 0, - "village/Rosenheim" : 0 - } -] -``` -
-A route planner example, the absolute betweenness of all locations. -This considers the actual distances. -
- -``` -arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); -arangosh> var g = examples.loadGraph("routeplanner"); -arangosh> db._query("RETURN GRAPH_ABSOLUTE_BETWEENNESS(" -........> +"'routeplanner', {weight : 'distance'})" -........> ).toArray(); -[ - { - "city/Berlin" : 0, - "city/Cologne" : 0, - "village/Olpe" : 2, - "city/Munich" : 6, - "village/Rosenheim" : 0 - } -] -``` -
-A route planner example, the absolute closeness of all cities regarding only -outbound pathes. -
- -``` -arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); -arangosh> var g = examples.loadGraph("routeplanner"); -arangosh> db._query("RETURN GRAPH_ABSOLUTE_BETWEENNESS(" -........> + "'routeplanner', {direction : 'outbound', weight : 'distance'})" -........> ).toArray(); -[ - { - "city/Berlin" : 0, - "city/Munich" : 1, - "city/Cologne" : 0, - "village/Rosenheim" : 0, - "village/Olpe" : 0 - } -] -``` -
- +@startDocuBlock JSF_ahuacatl_general_graph_absolute_betweenness !SUBSUBSECTION GRAPH_BETWEENNESS -
-`GRAPH_BETWEENNESS (graphName, options)` -*The GRAPH\_BETWEENNESS function returns the -[betweenness](http://en.wikipedia.org/wiki/Betweenness_centrality) -of graphs vertices.* -
-
-* String *graphName* : The name of the graph. -* Object *options* : Optional options, see below: -
-Possible options and there defaults: -* String *direction* : The direction of the edges. -Possible values are *outbound*, *inbound* and *any* (default). -* String *weight* : The name of the attribute of -the edges containing the length. -* Number *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. -
- -``` -arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); -arangosh> var g = examples.loadGraph("routeplanner"); -arangosh> db._query("RETURN GRAPH_BETWEENNESS(" -........> +"'routeplanner')" -........> ).toArray(); -[ - { - "city/Berlin" : 1, - "city/Munich" : 1, - "city/Cologne" : 1, - "village/Rosenheim" : 0, - "village/Olpe" : 0 - } -] -``` -
-A route planner example, the closeness of all locations. -This considers the actual distances. -
- -``` -arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); -arangosh> var g = examples.loadGraph("routeplanner"); -arangosh> db._query("RETURN GRAPH_BETWEENNESS(" -........> +"'routeplanner', {weight : 'distance'})" -........> ).toArray(); -[ - { - "city/Berlin" : 0, - "city/Cologne" : 0, - "village/Olpe" : 0.3333333333333333, - "city/Munich" : 1, - "village/Rosenheim" : 0 - } -] -``` -
-A route planner example, the closeness of all cities regarding only -outbound pathes. -
- -``` -arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); -arangosh> var g = examples.loadGraph("routeplanner"); -arangosh> db._query("RETURN GRAPH_BETWEENNESS(" -........> + "'routeplanner', {direction : 'outbound', weight : 'distance'})" -........> ).toArray(); -[ - { - "city/Munich" : 1, - "city/Cologne" : 0, - "village/Olpe" : 0, - "village/Rosenheim" : 0, - "city/Berlin" : 0 - } -] -``` -
- +@startDocuBlock JSF_ahuacatl_general_graph_betweenness !SUBSUBSECTION GRAPH_RADIUS -
-`GRAPH_RADIUS (graphName, options)` -*The GRAPH\_RADIUS function returns the -[radius](http://en.wikipedia.org/wiki/Eccentricity_%28graph_theory%29) -of a graph.* -
-
-* String *graphName* : The name of the graph. -* Object *options* : Optional options, see below: -
-Possible options and there defaults: -* String *direction* : The direction of the edges. -Possible values are *outbound*, *inbound* and *any* (default). -* String *algorithm* : The algorithm to calculate -the shortest paths. -* String *weight* : The name of the attribute of -the edges containing the length. -* Number *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. -
- -``` -arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); -arangosh> var g = examples.loadGraph("routeplanner"); -arangosh> db._query("RETURN GRAPH_RADIUS(" -........> +"'routeplanner')" -........> ).toArray(); -[ - 1 -] -``` -
-A route planner example, the radius of the graph. -This considers the actual distances. -
- -``` -arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); -arangosh> var g = examples.loadGraph("routeplanner"); -arangosh> db._query("RETURN GRAPH_RADIUS(" -........> +"'routeplanner', {weight : 'distance'})" -........> ).toArray(); -[ - 650 -] -``` -
-A route planner example, the cradius of the graph regarding only -outbound pathes. -
- -``` -arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); -arangosh> var g = examples.loadGraph("routeplanner"); -arangosh> db._query("RETURN GRAPH_RADIUS(" -........> + "'routeplanner', {direction : 'outbound', weight : 'distance'})" -........> ).toArray(); -[ - 650 -] -``` -
- +@startDocuBlock JSF_ahuacatl_general_graph_radius !SUBSUBSECTION GRAPH_DIAMETER -
-`GRAPH_DIAMETER (graphName, options)` -*The GRAPH\_DIAMETER function returns the -[diameter](http://en.wikipedia.org/wiki/Eccentricity_%28graph_theory%29) -of a graph.* -
-
-* String *graphName* : The name of the graph. -* Object *options* : Optional options, see below: -
-Possible options and there defaults: -* String *direction* : The direction of the edges. -Possible values are *outbound*, *inbound* and *any* (default). -* String *algorithm* : The algorithm to calculate -the shortest paths. -* String *weight* : The name of the attribute of -the edges containing the length. -* Number *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. -
- -``` -arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); -arangosh> var g = examples.loadGraph("routeplanner"); -arangosh> db._query("RETURN GRAPH_DIAMETER(" -........> +"'routeplanner')" -........> ).toArray(); -[ - 2 -] -``` -
-A route planner example, the diameter of the graph. -This considers the actual distances. -
- -``` -arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); -arangosh> var g = examples.loadGraph("routeplanner"); -arangosh> db._query("RETURN GRAPH_DIAMETER(" -........> +"'routeplanner', {weight : 'distance'})" -........> ).toArray(); -[ - 800 -] -``` -
-A route planner example, the diameter of the graph regarding only -outbound pathes. -
- -``` -arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); -arangosh> var g = examples.loadGraph("routeplanner"); -arangosh> db._query("RETURN GRAPH_DIAMETER(" -........> + "'routeplanner', {direction : 'outbound', weight : 'distance'})" -........> ).toArray(); -[ - 850 -] -``` -
- +@startDocuBlock JSF_ahuacatl_general_graph_diameter diff --git a/Documentation/Books/Users/Aql/GraphOperations.mdpp.orig b/Documentation/Books/Users/Aql/GraphOperations.mdpp.orig deleted file mode 100644 index 995fa55c15..0000000000 --- a/Documentation/Books/Users/Aql/GraphOperations.mdpp.orig +++ /dev/null @@ -1,88 +0,0 @@ -!CHAPTER Graph operations - -This chapter describe graph related aql functions. - -!SUBSECTION Edges and Vertices related functions. - -This section describes various AQL functions which can be used to recieve information about the graph's vertices, edges, neighbor relationship and shared properties. - -!SUBSUBSECTION GRAPH_EDGES - - - -!SUBSUBSECTION GRAPH_VERTICES - - - -!SUBSUBSECTION GRAPH_COMMON_NEIGHBORS - - - -!SUBSUBSECTION GRAPH_COMMON_PROPERTIES - - - -!SUBSUBSECTION GRAPH_NEIGHBORS - - - -!SUBSECTION Shortest Paths, distances and traversals. - -This section describes AQL functions, that calculate pathes from a subset of vertices in a graph to another subset of vertices. - -!SUBSUBSECTION GRAPH_PATHS - - - -!SUBSUBSECTION GRAPH_SHORTEST_PATH - - - -!SUBSUBSECTION GRAPH_TRAVERSAL - - - -!SUBSUBSECTION GRAPH_TRAVERSAL_TREE - - - -!SUBSUBSECTION GRAPH_DISTANCE_TO - - - -!SUBSECTION Graph measurements. - -This section describes AQL functions to calculate various graph related measurements as defined in the mathematical graph theory. - -!SUBSUBSECTION GRAPH_ABSOLUTE_ECCENTRICITY - - - -!SUBSUBSECTION GRAPH_ECCENTRICITY - - - -!SUBSUBSECTION GRAPH_ABSOLUTE_CLOSENESS - - - -!SUBSUBSECTION GRAPH_CLOSENESS - - - -!SUBSUBSECTION GRAPH_ABSOLUTE_BETWEENNESS - - - -!SUBSUBSECTION GRAPH_BETWEENNESS - - - -!SUBSUBSECTION GRAPH_RADIUS - - - -!SUBSUBSECTION GRAPH_DIAMETER - - - diff --git a/Documentation/Books/Users/General-Graphs/Functions.mdpp b/Documentation/Books/Users/General-Graphs/Functions.mdpp index 2fa85e4785..7c1f9f2985 100644 --- a/Documentation/Books/Users/General-Graphs/Functions.mdpp +++ b/Documentation/Books/Users/General-Graphs/Functions.mdpp @@ -6,562 +6,62 @@ This chapter describes various functions on a graph. !SUBSECTION Get vertex *from* of an edge -Get the vertex of an edge defined as *_from* -
-`general-graph._getFromVertex(edgeId)` -
-Returns the vertex defined with the attribute *_from* of the edge with *edgeId* as its *_id*. -
-@EXAMPLES -
- -``` -arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); -arangosh> var g = examples.loadGraph("social"); -arangosh> g._getFromVertex("relation/aliceAndBob") -{ - "name" : "Alice", - "_id" : "female/alice", - "_rev" : "236262839", - "_key" : "alice" -} -``` -
+@startDocuBlock JSF_general_graph_getFromVertex !SUBSECTION Get vertex *to* of an edge -Get the vertex of an edge defined as *_to* -
-`general-graph._getToVertex(edgeId)` -
-Returns the vertex defined with the attribute *_to* of the edge with *edgeId* as its *_id*. -
-@EXAMPLES -
+@startDocuBlock JSF_general_graph_getToVertex -``` -arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); -arangosh> var g = examples.loadGraph("social"); -arangosh> g._getToVertex("relation/aliceAndBob") -{ - "name" : "Bob", - "_id" : "male/bob", - "_rev" : "70784439", - "_key" : "bob" -} -``` -
+!SECTION _neighbors + +@startDocuBlock JSF_general_graph_neighbors + +!SECTION _commonNeighbors + +@startDocuBlock JSF_general_graph_common_neighbors + +!SECTION _countCommonNeighbors + +@startDocuBlock JSF_general_graph_count_common_neighbors + +!SECTION _commonProperties + +@startDocuBlock JSF_general_graph_common_properties + +!SECTION _countCommonProperties + +@startDocuBlock JSF_general_graph_count_common_properties -!SECTION _listCommonNeighbors +!SECTION _absoluteEccentricity -
-`general_graph._listCommonNeighbors(vertex1Example, vertex2Examples, -optionsVertex1, optionsVertex2)` -*The general_graph._listCommonNeighbors function returns all common neighbors -of the vertices defined by the examples.* -
-The function accepts an id, an example, a list of examples or even an empty -example as parameter for vertex1Example and vertex2Example. -
-* String|Object|Array *vertex1Example* : An example for the desired -vertices (see below). -* String|Object|Array *vertex2Example* : An example for the desired -vertices (see below). -* Object *optionsVertex1* : Optional options, see below: -* Object *optionsVertex2* : Optional options, see below: -
-Possible options and there defaults: -* String *direction* : The direction of the -edges. Possible values are *outbound*, *inbound* and *any* (default). -* String|Object|Array *edgeExamples* : A filter example -for the edges to the neighbors (see below). -* String|Object|Array *neighborExamples* : An example for -the desired neighbors (see below). -* String|Array *edgeCollectionRestriction* : One or multiple -edge collections that should be considered. -// * String|Array *vertexCollectionRestriction* : One or multiple -vertex collections that should be considered. -// / * Number *minDepth* : Defines the minimal -depth a path to a neighbor must have to be returned (default is 1). -* Number *maxDepth* : Defines the maximal -depth a path to a neighbor must have to be returned (default is 1). -
-Examples for vertexExample: -* {} : Returns all possible vertices for this graph. -* *idString* : Returns the vertex with the id *idString*. -* {*key* : *value*} : Returns the vertices that match this example. -* [{*key1* : *value1*}, {*key2* : *value2*}] : Returns the vertices that -match one of the examples. -
-@EXAMPLES -
-A route planner example, all common neighbors of capitals. -
+@startDocuBlock JSF_general_graph_absolute_eccentricity -``` -arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); -arangosh> var g = examples.loadGraph("routeplanner"); -arangosh> g._listCommonNeighbors({isCapital : true}, {isCapital : true}); -[ - { - "city/Berlin" : { - "city/Munich" : [ - { - "_id" : "city/Cologne", - "_rev" : "339311159", - "_key" : "Cologne", - "isCapital" : false, - "population" : 1000000 - }, - { - "_id" : "village/Olpe", - "_rev" : "339966519", - "_key" : "Olpe", - "isCapital" : false, - "population" : 80000 - }, - { - "_id" : "village/Rosenheim", - "_rev" : "340163127", - "_key" : "Rosenheim", - "isCapital" : false, - "population" : 80000 - } - ] - } - }, - { - "city/Munich" : { - "city/Berlin" : [ - { - "_id" : "city/Cologne", - "_rev" : "339311159", - "_key" : "Cologne", - "isCapital" : false, - "population" : 1000000 - }, - { - "_id" : "village/Olpe", - "_rev" : "339966519", - "_key" : "Olpe", - "isCapital" : false, - "population" : 80000 - }, - { - "_id" : "village/Rosenheim", - "_rev" : "340163127", - "_key" : "Rosenheim", - "isCapital" : false, - "population" : 80000 - } - ] - } - } -] -``` -
-A route planner example, all common outbound neighbors of munich with any other location -which have a maximal depth of 2 : -
+!SECTION _eccentricity -``` -arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); -arangosh> var g = examples.loadGraph("routeplanner"); -arangosh> g._listCommonNeighbors('city/Munich', {}, {direction : 'outbound', maxDepth : 2}, -........> {direction : 'outbound', maxDepth : 2}); -[ - { - "city/Munich" : { - "city/Berlin" : [ - { - "_id" : "city/Cologne", - "_rev" : "424901175", - "_key" : "Cologne", - "isCapital" : false, - "population" : 1000000 - }, - { - "_id" : "village/Olpe", - "_rev" : "425556535", - "_key" : "Olpe", - "isCapital" : false, - "population" : 80000 - }, - { - "_id" : "village/Rosenheim", - "_rev" : "425753143", - "_key" : "Rosenheim", - "isCapital" : false, - "population" : 80000 - } - ], - "city/Cologne" : [ - { - "_id" : "village/Olpe", - "_rev" : "425556535", - "_key" : "Olpe", - "isCapital" : false, - "population" : 80000 - }, - { - "_id" : "village/Rosenheim", - "_rev" : "425753143", - "_key" : "Rosenheim", - "isCapital" : false, - "population" : 80000 - } - ] - } - } -] -``` -
+@startDocuBlock JSF_general_graph_eccentricity +!SECTION _absoluteCloseness +@startDocuBlock JSF_general_graph_absolute_closeness -!SECTION _amountCommonNeighbors +!SECTION _closeness -
-`general_graph._amountCommonNeighbors(vertex1Example, vertex2Examples, -optionsVertex1, optionsVertex2)` -*The general_graph._amountCommonNeighbors function returns the amount of -common neighbors of the vertices defined by the examples.* -
-The function accepts an id, an example, a list of examples or even an empty -example as parameter for vertex1Example and vertex2Example. -
-* String|Object|Array *vertex1Example* : An example for the desired -vertices (see below). -* String|Object|Array *vertex2Example* : An example for the desired -vertices (see below). -* Object *optionsVertex1* : Optional options, see below: -* Object *optionsVertex2* : Optional options, see below: -
-Possible options and there defaults: -* String *direction* : The direction of the -edges. Possible values are *outbound*, *inbound* and *any* (default). -* String|Object|Array *edgeExamples* : A filter example -for the edges to the neighbors (see below). -* String|Object|Array *neighborExamples* : An example for -the desired neighbors (see below). -* String|Array *edgeCollectionRestriction* : One or multiple -edge collections that should be considered. -// * String|Array *vertexCollectionRestriction* : One or multiple -vertex collections that should be considered. -// / * Number *minDepth* : Defines the minimal -depth a path to a neighbor must have to be returned (default is 1). -* Number *maxDepth* : Defines the maximal -depth a path to a neighbor must have to be returned (default is 1). -
-Examples for vertexExample: -* {} : Returns all possible vertices for this graph. -* *idString* : Returns the vertex with the id *idString*. -* {*key* : *value*} : Returns the vertices that match this example. -* [{*key1* : *value1*}, {*key2* : *value2*}] : Returns the vertices that -match one of the examples. -
-@EXAMPLES -
-A route planner example, all common neighbors of capitals. -
+@startDocuBlock JSF_general_graph_closeness -``` -arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); -arangosh> var g = examples.loadGraph("routeplanner"); -arangosh> g._amountCommonNeighbors({isCapital : true}, {isCapital : true}); -[ - { - "city/Berlin" : [ - { - "city/Munich" : 3 - } - ] - }, - { - "city/Munich" : [ - { - "city/Berlin" : 3 - } - ] - } -] -``` -
-A route planner example, all common outbound neighbors of munich with any other location -which have a maximal depth of 2 : -
+!SECTION _absoluteBetweenness -``` -arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); -arangosh> var g = examples.loadGraph("routeplanner"); -arangosh> g._amountCommonNeighbors('city/Munich', {}, {direction : 'outbound', maxDepth : 2}, -........> {direction : 'outbound', maxDepth : 2}); -[ - { - "city/Munich" : [ - { - "city/Berlin" : 3 - }, - { - "city/Cologne" : 2 - } - ] - } -] -``` -
+@startDocuBlock JSF_general_graph_absolute_betweenness +!SECTION _betweenness +@startDocuBlock JSF_general_graph_betweenness -!SECTION _listCommonProperties +!SECTION _radius -
-`general_graph._listCommonProperties(vertex1Example, vertex2Examples, -options)` -*The general_graph._listCommonProperties function returns the vertices of -the graph that share common properties.* -
-The function accepts an id, an example, a list of examples or even an empty -example as parameter for vertex1Example and vertex2Example. -
-* String|Object|Array *vertex1Example* : An example for the desired -vertices (see below). -* String|Object|Array *vertex2Example* : An example for the desired -vertices (see below). -* Object *options* : Optional options, see below: -
-Possible options and there defaults: -// * String|Array *vertex1CollectionRestriction* : One or multiple -vertex collections that should be considered. -* String|Array *vertex2CollectionRestriction* : One or multiple -vertex collections that should be considered. -* String|Array *ignoreProperties* : One or multiple -attributes of a document that should be ignored. -
-Examples for vertexExample: -* {} : Returns all possible vertices for this graph. -* *idString* : Returns the vertex with the id *idString*. -* {*key* : *value*} : Returns the vertices that match this example. -* [{*key1* : *value1*}, {*key2* : *value2*}] : Returns the vertices that -match one of the examples. -
-@EXAMPLES -
-A route planner example, all locations with the same properties: -
+@startDocuBlock JSF_general_graph_radius -``` -arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); -arangosh> var g = examples.loadGraph("routeplanner"); -arangosh> g._listCommonProperties({}, {}); -[ - { - "city/Berlin" : [ - { - "_id" : "city/Munich", - "_rev" : "174396855", - "_key" : "Munich", - "isCapital" : true, - "population" : 1000000 - } - ] - }, - { - "city/Cologne" : [ - { - "_id" : "village/Rosenheim", - "_rev" : "175052215", - "_key" : "Rosenheim", - "isCapital" : false, - "population" : 80000 - }, - { - "_id" : "village/Olpe", - "_rev" : "174855607", - "_key" : "Olpe", - "isCapital" : false, - "population" : 80000 - }, - { - "_id" : "city/Munich", - "_rev" : "174396855", - "_key" : "Munich", - "isCapital" : true, - "population" : 1000000 - } - ] - }, - { - "city/Munich" : [ - { - "_id" : "city/Berlin", - "_rev" : "174003639", - "_key" : "Berlin", - "isCapital" : true, - "population" : 3000000 - }, - { - "_id" : "city/Cologne", - "_rev" : "174200247", - "_key" : "Cologne", - "isCapital" : false, - "population" : 1000000 - } - ] - }, - { - "village/Olpe" : [ - { - "_id" : "city/Cologne", - "_rev" : "174200247", - "_key" : "Cologne", - "isCapital" : false, - "population" : 1000000 - }, - { - "_id" : "village/Rosenheim", - "_rev" : "175052215", - "_key" : "Rosenheim", - "isCapital" : false, - "population" : 80000 - } - ] - }, - { - "village/Rosenheim" : [ - { - "_id" : "city/Cologne", - "_rev" : "174200247", - "_key" : "Cologne", - "isCapital" : false, - "population" : 1000000 - }, - { - "_id" : "village/Olpe", - "_rev" : "174855607", - "_key" : "Olpe", - "isCapital" : false, - "population" : 80000 - } - ] - } -] -``` -
-A route planner example, all cities which share same properties except for population. -
+!SECTION _diameter -``` -arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); -arangosh> var g = examples.loadGraph("routeplanner"); -arangosh> g._listCommonProperties({}, {}, {vertex1CollectionRestriction : 'city', -........> vertex2CollectionRestriction : 'city' ,ignoreProperties: 'population'}); -[ - { - "city/Berlin" : [ - { - "_id" : "city/Munich", - "_rev" : "179574199", - "_key" : "Munich", - "isCapital" : true, - "population" : 1000000 - } - ] - }, - { - "city/Munich" : [ - { - "_id" : "city/Berlin", - "_rev" : "179180983", - "_key" : "Berlin", - "isCapital" : true, - "population" : 3000000 - } - ] - } -] -``` -
- - - -!SECTION _amountCommonProperties - -
-`general_graph._amountCommonProperties(vertex1Example, vertex2Examples, -options)` -*The general_graph._amountCommonProperties function returns the amount of vertices of -the graph that share common properties.* -
-The function accepts an id, an example, a list of examples or even an empty -example as parameter for vertex1Example and vertex2Example. -
-* String|Object|Array *vertex1Example* : An example for the desired -vertices (see below). -* String|Object|Array *vertex2Example* : An example for the desired -vertices (see below). -* Object *options* : Optional options, see below: -
-Possible options and there defaults: -// * String|Array *vertex1CollectionRestriction* : One or multiple -vertex collections that should be considered. -* String|Array *vertex2CollectionRestriction* : One or multiple -vertex collections that should be considered. -* String|Array *ignoreProperties* : One or multiple -attributes of a document that should be ignored. -
-Examples for vertexExample: -* {} : Returns all possible vertices for this graph. -* *idString* : Returns the vertex with the id *idString*. -* {*key* : *value*} : Returns the vertices that match this example. -* [{*key1* : *value1*}, {*key2* : *value2*}] : Returns the vertices that -match one of the examples. -
-@EXAMPLES -
-A route planner example, all locations with the same properties: -
- -``` -arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); -arangosh> var g = examples.loadGraph("routeplanner"); -arangosh> g._amountCommonProperties({}, {}); -[ - { - "city/Berlin" : 1 - }, - { - "city/Cologne" : 3 - }, - { - "city/Munich" : 2 - }, - { - "village/Olpe" : 2 - }, - { - "village/Rosenheim" : 2 - } -] -``` -
-A route planner example, all cities which share same properties except for population. -
- -``` -arangosh> var examples = require("org/arangodb/graph-examples/example-graph.js"); -arangosh> var g = examples.loadGraph("routeplanner"); -arangosh> g._amountCommonProperties({}, {}, {vertex1CollectionRestriction : 'city', -........> vertex2CollectionRestriction : 'city' ,ignoreProperties: 'population'}); -[ - { - "city/Berlin" : 1 - }, - { - "city/Munich" : 1 - } -] -``` -
+@startDocuBlock JSF_general_graph_diameter diff --git a/Documentation/Books/Users/General-Graphs/Functions.mdpp.orig b/Documentation/Books/Users/General-Graphs/Functions.mdpp.orig deleted file mode 100644 index f6dc89f32c..0000000000 --- a/Documentation/Books/Users/General-Graphs/Functions.mdpp.orig +++ /dev/null @@ -1,34 +0,0 @@ -!CHAPTER Graph Functions - -This chapter describes various functions on a graph. - -!SECTION Get vertices from edges. - -!SUBSECTION Get vertex *from* of an edge - - - -!SUBSECTION Get vertex *to* of an edge - - - - -!SECTION _listCommonNeighbors - - - - -!SECTION _amountCommonNeighbors - - - - -!SECTION _listCommonProperties - - - - -!SECTION _amountCommonProperties - - - diff --git a/js/common/modules/org/arangodb/general-graph.js b/js/common/modules/org/arangodb/general-graph.js index 5c3684984f..5e0351c65e 100644 --- a/js/common/modules/org/arangodb/general-graph.js +++ b/js/common/modules/org/arangodb/general-graph.js @@ -886,6 +886,19 @@ AQLGenerator.prototype.pathEdges = function() { /// Only vertices having these attributes are matched. /// * A list containing example objects and/or strings. /// All vertices matching at least one of the elements in the list are returned. +/// Possible options and there defaults: +/// * String *direction* : The direction of the +/// edges. Possible values are *outbound*, *inbound* and *any* (default). +/// * String|Object|Array *edgeExamples* : A filter example +/// for the edges to the neighbors (see below). +/// * String|Array *edgeCollectionRestriction* : One or multiple +/// edge collections that should be considered. +/// * String|Array *vertexCollectionRestriction* : One or multiple +/// vertex collections that should be considered. +/// * Number *minDepth* : Defines the minimal +/// depth a path to a neighbor must have to be returned (default is 1). +/// * Number *maxDepth* : Defines the maximal +/// depth a path to a neighbor must have to be returned (default is 1). /// /// *Examples* /// @@ -2519,22 +2532,18 @@ Graph.prototype._getVertexCollectionByName = function(name) { //////////////////////////////////////////////////////////////////////////////// -/// @startDocuBlock JSF_general_graph_common_neighbors +/// @startDocuBlock JSF_general_graph_neighbors /// -/// `general_graph._listCommonNeighbors(vertex1Example, vertex2Examples, -/// optionsVertex1, optionsVertex2)` -/// *The general_graph._listCommonNeighbors function returns all common neighbors -/// of the vertices defined by the examples.* +/// `general_graph._neighbors(vertexExample, options)` +/// *The general_graph._neighbors function returns all neighbors +/// of the vertices defined by the example.* /// /// The function accepts an id, an example, a list of examples or even an empty -/// example as parameter for vertex1Example and vertex2Example. +/// example as parameter for vertexExample. /// -/// * String|Object|Array *vertex1Example* : An example for the desired +/// * String|Object|Array *vertexExample* : An example for the desired /// vertices (see below). -/// * String|Object|Array *vertex2Example* : An example for the desired -/// vertices (see below). -/// * Object *optionsVertex1* : Optional options, see below: -/// * Object *optionsVertex2* : Optional options, see below: +/// * Object *options* : Optional options, see below: /// /// Possible options and there defaults: /// * String *direction* : The direction of the @@ -2561,24 +2570,81 @@ Graph.prototype._getVertexCollectionByName = function(name) { /// /// *Examples* /// +/// A route planner example, all neighbors of capitals. +/// +/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphModuleNeighbors1} +/// ~ var db = require("internal").db; +/// var examples = require("org/arangodb/graph-examples/example-graph.js"); +/// var g = examples.loadGraph("routeplanner"); +/// g._neighbors({isCapital : true}); +/// @END_EXAMPLE_ARANGOSH_OUTPUT +/// +/// A route planner example, all outbound neighbors of Hamburg. +/// +/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphModuleNeighbors2} +/// ~ var db = require("internal").db; +/// var examples = require("org/arangodb/graph-examples/example-graph.js"); +/// var g = examples.loadGraph("routeplanner"); +/// g._neighbors('germanCity/Hamburg', {direction : 'outbound', maxDepth : 2}); +/// @END_EXAMPLE_ARANGOSH_OUTPUT +/// +/// @endDocuBlock +// +//////////////////////////////////////////////////////////////////////////////// +Graph.prototype._neighbors = function(vertexExample, options) { + var AQLStmt = new AQLGenerator(this); + // If no direction is specified all edges are duplicated. + // => For initial requests a direction has to be set + if (!options) { + options = {}; + } + return AQLStmt.vertices(vertexExample).neighbors(options.neighborExamples, options) + .toArray(); +}; + + +//////////////////////////////////////////////////////////////////////////////// +/// @startDocuBlock JSF_general_graph_common_neighbors +/// +/// `general_graph._commonNeighbors(vertex1Example, vertex2Examples, +/// optionsVertex1, optionsVertex2)` +/// *The general_graph._commonNeighbors function returns all common neighbors +/// of the vertices defined by the examples.* +/// +/// The function accepts an id, an example, a list of examples or even an empty +/// example as parameter for vertex1Example and vertex2Example. +/// +/// This function returns the intersection of *general_graph._neighbors(vertex1Example, optionsVertex1)* +/// and *general_graph._neighbors(vertex2Example, optionsVertex2)*. +/// For parameter documentation read the documentation *general_graph._neighbors*. +/// +/// Examples for vertexExample: +/// * {} : Returns all possible vertices for this graph. +/// * *idString* : Returns the vertex with the id *idString*. +/// * {*key* : *value*} : Returns the vertices that match this example. +/// * [{*key1* : *value1*}, {*key2* : *value2*}] : Returns the vertices that +/// match one of the examples. +/// +/// *Examples* +/// /// A route planner example, all common neighbors of capitals. /// /// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphModuleCommonNeighbors1} /// ~ var db = require("internal").db; /// var examples = require("org/arangodb/graph-examples/example-graph.js"); /// var g = examples.loadGraph("routeplanner"); -/// g._listCommonNeighbors({isCapital : true}, {isCapital : true}); +/// g._commonNeighbors({isCapital : true}, {isCapital : true}); /// @END_EXAMPLE_ARANGOSH_OUTPUT /// -/// A route planner example, all common outbound neighbors of munich with any other location +/// A route planner example, all common outbound neighbors of Hamburg with any other location /// which have a maximal depth of 2 : /// /// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphModuleCommonNeighbors2} /// ~ var db = require("internal").db; /// var examples = require("org/arangodb/graph-examples/example-graph.js"); /// var g = examples.loadGraph("routeplanner"); -/// | g._listCommonNeighbors( -/// | 'city/Munich', +/// | g._commonNeighbors( +/// | 'germanCity/Hamburg', /// | {}, /// | {direction : 'outbound', maxDepth : 2}, /// {direction : 'outbound', maxDepth : 2}); @@ -2588,7 +2654,7 @@ Graph.prototype._getVertexCollectionByName = function(name) { // //////////////////////////////////////////////////////////////////////////////// -Graph.prototype._listCommonNeighbors = function(vertex1Example, vertex2Example, optionsVertex1, optionsVertex2) { +Graph.prototype._commonNeighbors = function(vertex1Example, vertex2Example, optionsVertex1, optionsVertex2) { var ex1 = transformExample(vertex1Example); var ex2 = transformExample(vertex2Example); @@ -2612,11 +2678,11 @@ Graph.prototype._listCommonNeighbors = function(vertex1Example, vertex2Example, }; //////////////////////////////////////////////////////////////////////////////// -/// @startDocuBlock JSF_general_graph_amount_common_neighbors +/// @startDocuBlock JSF_general_graph_count_common_neighbors /// -/// `general_graph._amountCommonNeighbors(vertex1Example, vertex2Examples, +/// `general_graph._countCommonNeighbors(vertex1Example, vertex2Examples, /// optionsVertex1, optionsVertex2)` -/// *The general_graph._amountCommonNeighbors function returns the amount of +/// *The general_graph._countCommonNeighbors function returns the amount of /// common neighbors of the vertices defined by the examples.* /// /// The function accepts an id, an example, a list of examples or even an empty @@ -2660,17 +2726,17 @@ Graph.prototype._listCommonNeighbors = function(vertex1Example, vertex2Example, /// ~ var db = require("internal").db; /// var examples = require("org/arangodb/graph-examples/example-graph.js"); /// var g = examples.loadGraph("routeplanner"); -/// g._amountCommonNeighbors({isCapital : true}, {isCapital : true}); +/// g._countCommonNeighbors({isCapital : true}, {isCapital : true}); /// @END_EXAMPLE_ARANGOSH_OUTPUT /// -/// A route planner example, all common outbound neighbors of munich with any other location +/// A route planner example, all common outbound neighbors of Hamburg with any other location /// which have a maximal depth of 2 : /// /// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphModuleCommonNeighborsAmount2} /// ~ var db = require("internal").db; /// var examples = require("org/arangodb/graph-examples/example-graph.js"); /// var g = examples.loadGraph("routeplanner"); -/// |g._amountCommonNeighbors('city/Munich', {}, {direction : 'outbound', maxDepth : 2}, +/// |g._countCommonNeighbors('germanCity/Hamburg', {}, {direction : 'outbound', maxDepth : 2}, /// {direction : 'outbound', maxDepth : 2}); /// @END_EXAMPLE_ARANGOSH_OUTPUT /// @@ -2678,7 +2744,7 @@ Graph.prototype._listCommonNeighbors = function(vertex1Example, vertex2Example, // //////////////////////////////////////////////////////////////////////////////// -Graph.prototype._amountCommonNeighbors = function(vertex1Example, vertex2Example, optionsVertex1, optionsVertex2) { +Graph.prototype._countCommonNeighbors = function(vertex1Example, vertex2Example, optionsVertex1, optionsVertex2) { var ex1 = transformExample(vertex1Example); var ex2 = transformExample(vertex2Example); var query = "FOR e" @@ -2719,9 +2785,9 @@ Graph.prototype._amountCommonNeighbors = function(vertex1Example, vertex2Example //////////////////////////////////////////////////////////////////////////////// /// @startDocuBlock JSF_general_graph_common_properties /// -/// `general_graph._listCommonProperties(vertex1Example, vertex2Examples, +/// `general_graph._commonProperties(vertex1Example, vertex2Examples, /// options)` -/// *The general_graph._listCommonProperties function returns the vertices of +/// *The general_graph._commonProperties function returns the vertices of /// the graph that share common properties.* /// /// The function accepts an id, an example, a list of examples or even an empty @@ -2756,7 +2822,7 @@ Graph.prototype._amountCommonNeighbors = function(vertex1Example, vertex2Example /// ~ var db = require("internal").db; /// var examples = require("org/arangodb/graph-examples/example-graph.js"); /// var g = examples.loadGraph("routeplanner"); -/// g._listCommonProperties({}, {}); +/// g._commonProperties({}, {}); /// @END_EXAMPLE_ARANGOSH_OUTPUT /// /// A route planner example, all cities which share same properties except for population. @@ -2765,15 +2831,14 @@ Graph.prototype._amountCommonNeighbors = function(vertex1Example, vertex2Example /// ~ var db = require("internal").db; /// var examples = require("org/arangodb/graph-examples/example-graph.js"); /// var g = examples.loadGraph("routeplanner"); -/// |g._listCommonProperties({}, {}, {vertex1CollectionRestriction : 'city', -/// vertex2CollectionRestriction : 'city' ,ignoreProperties: 'population'}); +/// g._commonProperties({}, {}, {ignoreProperties: 'population'}); /// @END_EXAMPLE_ARANGOSH_OUTPUT /// /// @endDocuBlock // //////////////////////////////////////////////////////////////////////////////// -Graph.prototype._listCommonProperties = function(vertex1Example, vertex2Example, options) { +Graph.prototype._commonProperties = function(vertex1Example, vertex2Example, options) { var ex1 = transformExample(vertex1Example); var ex2 = transformExample(vertex2Example); @@ -2795,11 +2860,11 @@ Graph.prototype._listCommonProperties = function(vertex1Example, vertex2Example, }; //////////////////////////////////////////////////////////////////////////////// -/// @startDocuBlock JSF_general_graph_amount_common_properties +/// @startDocuBlock JSF_general_graph_count_common_properties /// -/// `general_graph._amountCommonProperties(vertex1Example, vertex2Examples, +/// `general_graph._countCommonProperties(vertex1Example, vertex2Examples, /// options)` -/// *The general_graph._amountCommonProperties function returns the amount of vertices of +/// *The general_graph._countCommonProperties function returns the amount of vertices of /// the graph that share common properties.* /// /// The function accepts an id, an example, a list of examples or even an empty @@ -2834,24 +2899,24 @@ Graph.prototype._listCommonProperties = function(vertex1Example, vertex2Example, /// ~ var db = require("internal").db; /// var examples = require("org/arangodb/graph-examples/example-graph.js"); /// var g = examples.loadGraph("routeplanner"); -/// g._amountCommonProperties({}, {}); +/// g._countCommonProperties({}, {}); /// @END_EXAMPLE_ARANGOSH_OUTPUT /// -/// A route planner example, all cities which share same properties except for population. +/// A route planner example, all german cities which share same properties except for population. /// /// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphModuleAmountProperties2} /// ~ var db = require("internal").db; /// var examples = require("org/arangodb/graph-examples/example-graph.js"); /// var g = examples.loadGraph("routeplanner"); -/// |g._amountCommonProperties({}, {}, {vertex1CollectionRestriction : 'city', -/// vertex2CollectionRestriction : 'city' ,ignoreProperties: 'population'}); +/// |g._countCommonProperties({}, {}, {vertex1CollectionRestriction : 'germanCity', +/// vertex2CollectionRestriction : 'germanCity' ,ignoreProperties: 'population'}); /// @END_EXAMPLE_ARANGOSH_OUTPUT /// /// @endDocuBlock // //////////////////////////////////////////////////////////////////////////////// -Graph.prototype._amountCommonProperties = function(vertex1Example, vertex2Example, options) { +Graph.prototype._countCommonProperties = function(vertex1Example, vertex2Example, options) { var ex1 = transformExample(vertex1Example); var ex2 = transformExample(vertex2Example); var query = "FOR e" @@ -2877,6 +2942,625 @@ Graph.prototype._amountCommonProperties = function(vertex1Example, vertex2Exampl }; +//////////////////////////////////////////////////////////////////////////////// +/// @startDocuBlock JSF_general_graph_absolute_eccentricity +/// +/// `general_graph._absoluteEccentricity(vertexExample, options)` +/// *The _absoluteEccentricity function returns the* +/// [eccentricity](http://en.wikipedia.org/wiki/Distance_%28graph_theory%29) +/// *of the vertices defined by the examples.* +/// +/// The function accepts an id, an example, a list of examples or even an empty +/// example as parameter for vertexExample. +/// +/// * String|Object|Array *vertexExample* : An example for the desired +/// vertices (see below). +/// * Object *options* : Optional options, see below: +/// +/// Possible options and there defaults: +/// * String *direction* : The direction of the edges. +/// Possible values are *outbound*, *inbound* and *any* (default). +/// * String|Array *edgeCollectionRestriction* : One or multiple edge +/// collections that should be considered. +/// * String|Array *startVertexCollectionRestriction* : One or multiple vertex +/// collections that should be considered. +/// * String|Array *endVertexCollectionRestriction* : One or multiple vertex +/// collections that should be considered. +/// * String|Object|Array *edgeExamples* : A filter example for the +/// edges in the shortest paths (see below). +/// * String *algorithm* : The algorithm to calculate +/// the shortest paths. +/// * String *weight* : The name of the attribute of +/// the edges containing the length. +/// * Number *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 for vertexExample: +/// * {} : Returns all possible vertices for this graph. +/// * *idString* : Returns the vertex with the id *idString*. +/// * {*key* : *value*} : Returns the vertices that match this example. +/// * [{*key1* : *value1*}, {*key2* : *value2*}] : Returns the vertices that +/// match one of the examples. +/// +/// @EXAMPLES +/// +/// A route planner example, the absolute eccentricity of all locations. +/// +/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphModuleAbsEccentricity1} +/// ~ var db = require("internal").db; +/// var examples = require("org/arangodb/graph-examples/example-graph.js"); +/// var g = examples.loadGraph("routeplanner"); +/// |db._query("RETURN GRAPH_ABSOLUTE_ECCENTRICITY(" +/// |+"'routeplanner', {})" +/// ).toArray(); +/// @END_EXAMPLE_ARANGOSH_OUTPUT +/// +/// A route planner example, the absolute eccentricity of all locations. +/// This considers the actual distances. +/// +/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphModuleAbsEccentricity2} +/// ~ var db = require("internal").db; +/// var examples = require("org/arangodb/graph-examples/example-graph.js"); +/// var g = examples.loadGraph("routeplanner"); +/// g._absoluteEccentricity({}, {weight : 'distance'}); +/// @END_EXAMPLE_ARANGOSH_OUTPUT +/// +/// A route planner example, the absolute eccentricity of all cities regarding only +/// outbound paths. +/// +/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphModuleAbsEccentricity3} +/// ~ var db = require("internal").db; +/// var examples = require("org/arangodb/graph-examples/example-graph.js"); +/// var g = examples.loadGraph("routeplanner"); +/// |g._absoluteEccentricity({}, {startVertexCollectionRestriction : 'city', +/// direction : 'outbound', weight : 'distance'}); +/// @END_EXAMPLE_ARANGOSH_OUTPUT +/// +/// @endDocuBlock +// +//////////////////////////////////////////////////////////////////////////////// +Graph.prototype._absoluteEccentricity = function(vertexExample, options) { + var ex1 = transformExample(vertexExample); + var query = "RETURN" + + " GRAPH_ABSOLUTE_ECCENTRICITY(@graphName" + + ',@ex1' + + ',@options' + + ')'; + options = options || {}; + var bindVars = { + "graphName": this.__name, + "options": options, + "ex1": ex1 + }; + var result = db._query(query, bindVars).toArray(), returnHash = []; + return result; +}; + + +//////////////////////////////////////////////////////////////////////////////// +/// @startDocuBlock JSF_general_graph_eccentricity +/// +/// `general_graph._eccentricity(vertexExample, options)` +/// *The _eccentricity function returns the normalized* +/// [eccentricity](http://en.wikipedia.org/wiki/Distance_%28graph_theory%29) +/// *of the vertices defined by the examples.* +/// +/// * Object *options* : Optional options, see below: +/// +/// Possible options and there defaults: +/// * String *direction* : The direction of the edges. +/// Possible values are *outbound*, *inbound* and *any* (default). +/// * String *algorithm* : The algorithm to calculate +/// the shortest paths. +/// * String *weight* : The name of the attribute of +/// the edges containing the length. +/// * Number *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. +/// +/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphModuleEccentricity2} +/// ~ var db = require("internal").db; +/// var examples = require("org/arangodb/graph-examples/example-graph.js"); +/// var g = examples.loadGraph("routeplanner"); +/// g._eccentricity(); +/// @END_EXAMPLE_ARANGOSH_OUTPUT +/// +/// A route planner example, the weighted eccentricity. +/// +/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphModuleEccentricity3} +/// ~ var db = require("internal").db; +/// var examples = require("org/arangodb/graph-examples/example-graph.js"); +/// var g = examples.loadGraph("routeplanner"); +/// g._eccentricity({weight : 'distance'}); +/// @END_EXAMPLE_ARANGOSH_OUTPUT +/// +/// @endDocuBlock +// +//////////////////////////////////////////////////////////////////////////////// +Graph.prototype._eccentricity = function(options) { + var query = "RETURN" + + " GRAPH_ECCENTRICITY(@graphName" + + ',@options' + + ')'; + options = options || {}; + var bindVars = { + "graphName": this.__name, + "options": options + }; + var result = db._query(query, bindVars).toArray(), returnHash = []; + return result; +}; + + + +//////////////////////////////////////////////////////////////////////////////// +/// @startDocuBlock JSF_general_graph_absolute_closeness +/// +/// `general_graph._absoluteCloseness(vertexExample, options)` +/// *The _absoluteCloseness function returns the* +/// [closeness](http://en.wikipedia.org/wiki/Centrality#Closeness_centrality) +/// *of the vertices defined by the examples.* +/// +/// The function accepts an id, an example, a list of examples or even an empty +/// example as parameter for vertexExample. +/// +/// * String|Object|Array *vertexExample* : An example for the desired +/// vertices (see below). +/// * Object *options* : Optional options, see below: +/// +/// Possible options and there defaults: +/// * String *direction* : The direction of the edges. +/// Possible values are *outbound*, *inbound* and *any* (default). +/// * String|Array *edgeCollectionRestriction* : One or multiple edge +/// collections that should be considered. +/// * String|Array *startVertexCollectionRestriction* : One or multiple vertex +/// collections that should be considered. +/// * String|Array *endVertexCollectionRestriction* : One or multiple vertex +/// collections that should be considered. +/// * String|Object|Array *edgeExamples* : A filter example for the +/// edges in the shortest paths (see below). +/// * String *algorithm* : The algorithm to calculate +/// the shortest paths. +/// * String *weight* : The name of the attribute of +/// the edges containing the length. +/// * Number *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 for vertexExample: +/// * {} : Returns all possible vertices for this graph. +/// * *idString* : Returns the vertex with the id *idString*. +/// * {*key* : *value*} : Returns the vertices that match this example. +/// * [{*key1* : *value1*}, {*key2* : *value2*}] : Returns the vertices that +/// match one of the examples. +/// +/// @EXAMPLES +/// +/// A route planner example, the absolute closeness of all locations. +/// +/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphModuleAbsCloseness1} +/// ~ var db = require("internal").db; +/// var examples = require("org/arangodb/graph-examples/example-graph.js"); +/// var g = examples.loadGraph("routeplanner"); +/// g._absoluteCloseness({}); +/// @END_EXAMPLE_ARANGOSH_OUTPUT +/// +/// A route planner example, the absolute closeness of all locations. +/// This considers the actual distances. +/// +/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphModuleAbsCloseness2} +/// ~ var db = require("internal").db; +/// var examples = require("org/arangodb/graph-examples/example-graph.js"); +/// var g = examples.loadGraph("routeplanner"); +/// g._absoluteCloseness({}, {weight : 'distance'}); +/// @END_EXAMPLE_ARANGOSH_OUTPUT +/// +/// A route planner example, the absolute closeness of all germanCities regarding only +/// outbound paths. +/// +/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphModuleAbsCloseness3} +/// ~ var db = require("internal").db; +/// var examples = require("org/arangodb/graph-examples/example-graph.js"); +/// var g = examples.loadGraph("routeplanner"); +/// |g._absoluteCloseness({}, {startVertexCollectionRestriction : 'germanCity', +/// direction : 'outbound', weight : 'distance'}); +/// @END_EXAMPLE_ARANGOSH_OUTPUT +/// +/// @endDocuBlock +// +//////////////////////////////////////////////////////////////////////////////// +Graph.prototype._absoluteCloseness = function(vertexExample, options) { + var ex1 = transformExample(vertexExample); + var query = "RETURN" + + " GRAPH_ABSOLUTE_CLOSENESS(@graphName" + + ',@ex1' + + ',@options' + + ')'; + options = options || {}; + var bindVars = { + "graphName": this.__name, + "options": options, + "ex1": ex1 + }; + var result = db._query(query, bindVars).toArray(), returnHash = []; + return result; +}; + +//////////////////////////////////////////////////////////////////////////////// +/// @startDocuBlock JSF_general_graph_closeness +/// +/// `general_graph._closeness(options)` +/// *The _closeness function returns the normalized* +/// [closeness](http://en.wikipedia.org/wiki/Centrality#Closeness_centrality) +/// *of graphs vertices.* +/// +/// * Object *options* : Optional options, see below: +/// +/// Possible options and there defaults: +/// * String *direction* : The direction of the edges. +/// Possible values are *outbound*, *inbound* and *any* (default). +/// * String *algorithm* : The algorithm to calculate +/// the shortest paths. +/// * String *weight* : The name of the attribute of +/// the edges containing the length. +/// * Number *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 normalized closeness of all locations. +/// +/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphModuleCloseness1} +/// ~ var db = require("internal").db; +/// var examples = require("org/arangodb/graph-examples/example-graph.js"); +/// var g = examples.loadGraph("routeplanner"); +/// g._closeness(); +/// @END_EXAMPLE_ARANGOSH_OUTPUT +/// +/// A route planner example, the closeness of all locations. +/// This considers the actual distances. +/// +/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphModuleCloseness2} +/// ~ var db = require("internal").db; +/// var examples = require("org/arangodb/graph-examples/example-graph.js"); +/// var g = examples.loadGraph("routeplanner"); +/// g._closeness({weight : 'distance'}); +/// @END_EXAMPLE_ARANGOSH_OUTPUT +/// +/// A route planner example, the closeness of all cities regarding only +/// outbound paths. +/// +/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphModuleCloseness3} +/// ~ var db = require("internal").db; +/// var examples = require("org/arangodb/graph-examples/example-graph.js"); +/// var g = examples.loadGraph("routeplanner"); +/// g._closeness({direction : 'outbound', weight : 'distance'}); +/// @END_EXAMPLE_ARANGOSH_OUTPUT +/// +/// @endDocuBlock +// +//////////////////////////////////////////////////////////////////////////////// +Graph.prototype._closeness = function(options) { + var query = "RETURN" + + " GRAPH_CLOSENESS(@graphName" + + ',@options' + + ')'; + options = options || {}; + var bindVars = { + "graphName": this.__name, + "options": options + }; + var result = db._query(query, bindVars).toArray(), returnHash = []; + return result; +}; + + + +//////////////////////////////////////////////////////////////////////////////// +/// @startDocuBlock JSF_general_graph_absolute_betweenness +/// +/// `general_graph._absoluteBetweenness(options)` +/// *The _absoluteBetweenness function returns the* +/// [betweenness](http://en.wikipedia.org/wiki/Betweenness_centrality) +/// *of all vertices in the graph.* +/// +/// +/// * Object *options* : Optional options, see below: +/// +/// Possible options and there defaults: +/// * String *direction* : The direction of the edges. +/// Possible values are *outbound*, *inbound* and *any* (default). +/// * String *weight* : The name of the attribute of +/// the edges containing the length. +/// * Number *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. +/// +/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphModuleAbsBetweenness1} +/// ~ var db = require("internal").db; +/// var examples = require("org/arangodb/graph-examples/example-graph.js"); +/// var g = examples.loadGraph("routeplanner"); +/// g._absoluteBetweenness({}); +/// @END_EXAMPLE_ARANGOSH_OUTPUT +/// +/// A route planner example, the absolute betweenness of all locations. +/// This considers the actual distances. +/// +/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphModuleAbsBetweenness2} +/// ~ var db = require("internal").db; +/// var examples = require("org/arangodb/graph-examples/example-graph.js"); +/// var g = examples.loadGraph("routeplanner"); +/// g._absoluteBetweenness({weight : 'distance'}); +/// @END_EXAMPLE_ARANGOSH_OUTPUT +/// +/// A route planner example, the absolute closeness of all cities regarding only +/// outbound paths. +/// +/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphModuleAbsBetweenness3} +/// ~ var db = require("internal").db; +/// var examples = require("org/arangodb/graph-examples/example-graph.js"); +/// var g = examples.loadGraph("routeplanner"); +/// g._absoluteBetweenness({direction : 'outbound', weight : 'distance'}); +/// @END_EXAMPLE_ARANGOSH_OUTPUT +/// +/// @endDocuBlock +// +//////////////////////////////////////////////////////////////////////////////// +Graph.prototype._absoluteBetweenness = function(options) { + + var query = "RETURN" + + " GRAPH_ABSOLUTE_BETWEENNESS(@graphName" + + ',@options' + + ')'; + options = options || {}; + var bindVars = { + "graphName": this.__name, + "options": options + }; + var result = db._query(query, bindVars).toArray(), returnHash = []; + return result; +}; + +//////////////////////////////////////////////////////////////////////////////// +/// @startDocuBlock JSF_general_graph_betweenness +/// +/// `general_graph._betweenness(options)` +/// *The _betweenness function returns the* +/// [betweenness](http://en.wikipedia.org/wiki/Betweenness_centrality) +/// *of graphs vertices.* +/// +/// * Object *options* : Optional options, see below: +/// +/// Possible options and there defaults: +/// * String *direction* : The direction of the edges. +/// Possible values are *outbound*, *inbound* and *any* (default). +/// * String *weight* : The name of the attribute of +/// the edges containing the length. +/// * Number *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. +/// +/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphModuleBetweenness1} +/// ~ var db = require("internal").db; +/// var examples = require("org/arangodb/graph-examples/example-graph.js"); +/// var g = examples.loadGraph("routeplanner"); +/// g._betweenness(); +/// @END_EXAMPLE_ARANGOSH_OUTPUT +/// +/// A route planner example, the closeness of all locations. +/// This considers the actual distances. +/// +/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphModuleBetweenness2} +/// ~ var db = require("internal").db; +/// var examples = require("org/arangodb/graph-examples/example-graph.js"); +/// var g = examples.loadGraph("routeplanner"); +/// g._betweenness({weight : 'distance'}); +/// @END_EXAMPLE_ARANGOSH_OUTPUT +/// +/// A route planner example, the closeness of all cities regarding only +/// outbound paths. +/// +/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphModuleBetweenness3} +/// ~ var db = require("internal").db; +/// var examples = require("org/arangodb/graph-examples/example-graph.js"); +/// var g = examples.loadGraph("routeplanner"); +/// g._betweenness({direction : 'outbound', weight : 'distance'}); +/// @END_EXAMPLE_ARANGOSH_OUTPUT +/// +/// @endDocuBlock +// +//////////////////////////////////////////////////////////////////////////////// +Graph.prototype._betweenness = function(options) { + + var query = "RETURN" + + " GRAPH_BETWEENNESS(@graphName" + + ',@options' + + ')'; + options = options || {}; + var bindVars = { + "graphName": this.__name, + "options": options + }; + var result = db._query(query, bindVars).toArray(), returnHash = []; + return result; +}; + + + +//////////////////////////////////////////////////////////////////////////////// +/// @startDocuBlock JSF_general_graph_radius +/// +/// `general_graph._radius(options)` +/// *The _radius function returns the* +/// [radius](http://en.wikipedia.org/wiki/Eccentricity_%28graph_theory%29) +/// *of a graph.* +/// +/// * Object *options* : Optional options, see below: +/// +/// Possible options and there defaults: +/// * String *direction* : The direction of the edges. +/// Possible values are *outbound*, *inbound* and *any* (default). +/// * String *algorithm* : The algorithm to calculate +/// the shortest paths. +/// * String *weight* : The name of the attribute of +/// the edges containing the length. +/// * Number *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. +/// +/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphModuleRadius1} +/// ~ var db = require("internal").db; +/// var examples = require("org/arangodb/graph-examples/example-graph.js"); +/// var g = examples.loadGraph("routeplanner"); +/// g._radius(); +/// @END_EXAMPLE_ARANGOSH_OUTPUT +/// +/// A route planner example, the radius of the graph. +/// This considers the actual distances. +/// +/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphModuleRadius2} +/// ~ var db = require("internal").db; +/// var examples = require("org/arangodb/graph-examples/example-graph.js"); +/// var g = examples.loadGraph("routeplanner"); +/// g._radius({weight : 'distance'}); +/// @END_EXAMPLE_ARANGOSH_OUTPUT +/// +/// A route planner example, the radius of the graph regarding only +/// outbound paths. +/// +/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphModuleRadius3} +/// ~ var db = require("internal").db; +/// var examples = require("org/arangodb/graph-examples/example-graph.js"); +/// var g = examples.loadGraph("routeplanner"); +/// g._radius({direction : 'outbound', weight : 'distance'}); +/// @END_EXAMPLE_ARANGOSH_OUTPUT +/// +/// @endDocuBlock +// +//////////////////////////////////////////////////////////////////////////////// +Graph.prototype._radius = function(options) { + + var query = "RETURN" + + " GRAPH_RADIUS(@graphName" + + ',@options' + + ')'; + options = options || {}; + var bindVars = { + "graphName": this.__name, + "options": options + }; + var result = db._query(query, bindVars).toArray(), returnHash = []; + return result; +}; + + + +//////////////////////////////////////////////////////////////////////////////// +/// @startDocuBlock JSF_general_graph_diameter +/// +/// `general_graph._diameter(graphName, options)` +/// *The _diameter function returns the* +/// [diameter](http://en.wikipedia.org/wiki/Eccentricity_%28graph_theory%29) +/// *of a graph.* +/// +/// * Object *options* : Optional options, see below: +/// +/// Possible options and there defaults: +/// * String *direction* : The direction of the edges. +/// Possible values are *outbound*, *inbound* and *any* (default). +/// * String *algorithm* : The algorithm to calculate +/// the shortest paths. +/// * String *weight* : The name of the attribute of +/// the edges containing the length. +/// * Number *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. +/// +/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphModuleDiameter1} +/// ~ var db = require("internal").db; +/// var examples = require("org/arangodb/graph-examples/example-graph.js"); +/// var g = examples.loadGraph("routeplanner"); +/// g._diameter(); +/// @END_EXAMPLE_ARANGOSH_OUTPUT +/// +/// A route planner example, the diameter of the graph. +/// This considers the actual distances. +/// +/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphModuleDiameter2} +/// ~ var db = require("internal").db; +/// var examples = require("org/arangodb/graph-examples/example-graph.js"); +/// var g = examples.loadGraph("routeplanner"); +/// g._diameter({weight : 'distance'}); +/// @END_EXAMPLE_ARANGOSH_OUTPUT +/// +/// A route planner example, the diameter of the graph regarding only +/// outbound paths. +/// +/// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphModuleDiameter3} +/// ~ var db = require("internal").db; +/// var examples = require("org/arangodb/graph-examples/example-graph.js"); +/// var g = examples.loadGraph("routeplanner"); +/// g._diameter({direction : 'outbound', weight : 'distance'}); +/// @END_EXAMPLE_ARANGOSH_OUTPUT +/// +/// @endDocuBlock +// +//////////////////////////////////////////////////////////////////////////////// +Graph.prototype._diameter = function(options) { + + var query = "RETURN" + + " GRAPH_DIAMETER(@graphName" + + ',@options' + + ')'; + options = options || {}; + var bindVars = { + "graphName": this.__name, + "options": options + }; + var result = db._query(query, bindVars).toArray(), returnHash = []; + return result; +}; + + + //////////////////////////////////////////////////////////////////////////////// /// @startDocuBlock JSF_general_graph__extendEdgeDefinitions diff --git a/js/common/modules/org/arangodb/graph-examples/example-graph.js b/js/common/modules/org/arangodb/graph-examples/example-graph.js index bd0c790b2c..4b729a6588 100644 --- a/js/common/modules/org/arangodb/graph-examples/example-graph.js +++ b/js/common/modules/org/arangodb/graph-examples/example-graph.js @@ -65,25 +65,31 @@ var createRoutePlannerGraph = function() { var edgeDefinition = []; - edgeDefinition.push(Graph._directedRelation("highway", ["city"], ["city"])); edgeDefinition.push(Graph._directedRelation( - "road", ["village", "city"], ["village", "city"]) + "germanHighway", ["germanCity"], ["germanCity"]) + ); + edgeDefinition.push( + Graph._directedRelation("frenchHighway", ["frenchCity"], ["frenchCity"]) + ); + edgeDefinition.push(Graph._directedRelation( + "internationalHighway", ["frenchCity", "germanCity"], ["frenchCity", "germanCity"]) ); var g = Graph._create("routeplanner", edgeDefinition); - var berlin = g.city.save({_key: "Berlin", population : 3000000, isCapital : true}); - var cologne = g.city.save({_key: "Cologne", population : 1000000, isCapital : false}); - var munich = g.city.save({_key: "Munich", population : 1000000, isCapital : true}); - var olpe = g.village.save({_key: "Olpe", population : 80000, isCapital : false}); - var rosenheim = g.village.save({_key: "Rosenheim", population : 80000, isCapital : false}); - g.highway.save(berlin._id, cologne._id, {distance: 850}); - g.highway.save(berlin._id, munich._id, {distance: 600}); - g.highway.save(munich._id, cologne._id, {distance: 650}); - g.road.save(berlin._id, olpe._id, {distance: 700}); - g.road.save(berlin._id, rosenheim._id, {distance: 800}); - g.road.save(munich._id, rosenheim._id, {distance: 80}); - g.road.save(munich._id, olpe._id, {distance: 600}); - g.road.save(cologne._id, olpe._id, {distance: 100}); - g.road.save(cologne._id, rosenheim._id, {distance: 750}); + var berlin = g.germanCity.save({_key: "Berlin", population : 3000000, isCapital : true}); + var cologne = g.germanCity.save({_key: "Cologne", population : 1000000, isCapital : false}); + var hamburg = g.germanCity.save({_key: "Hamburg", population : 1000000, isCapital : false}); + var lyon = g.frenchCity.save({_key: "Lyon", population : 80000, isCapital : false}); + var paris = g.frenchCity.save({_key: "Paris", population : 4000000, isCapital : true}); + g.germanHighway.save(berlin._id, cologne._id, {distance: 850}); + g.germanHighway.save(berlin._id, hamburg._id, {distance: 400}); + g.germanHighway.save(hamburg._id, cologne._id, {distance: 500}); + g.frenchHighway.save(paris._id, lyon._id, {distance: 550}); + g.internationalHighway.save(berlin._id, lyon._id, {distance: 1100}); + g.internationalHighway.save(berlin._id, paris._id, {distance: 1200}); + g.internationalHighway.save(hamburg._id, paris._id, {distance: 900}); + g.internationalHighway.save(hamburg._id, lyon._id, {distance: 1300}); + g.internationalHighway.save(cologne._id, lyon._id, {distance: 700}); + g.internationalHighway.save(cologne._id, paris._id, {distance: 550}); return g; }; diff --git a/js/common/tests/shell-general-graph.js b/js/common/tests/shell-general-graph.js index ccd83a241a..fb8abac3b2 100644 --- a/js/common/tests/shell-general-graph.js +++ b/js/common/tests/shell-general-graph.js @@ -2314,11 +2314,30 @@ function GeneralGraphCommonNeighborsSuite() { /// @brief checks GRAPH_COMMON_NEIGHBORS() and GRAPH_COMMON_PROPERTIES() //////////////////////////////////////////////////////////////////////////////// + + testNeighborsAnyV3: function () { + actual = testGraph._neighbors(v3); + assertTrue(actual[0]._id, v2); + assertTrue(actual[1]._id, v5); + assertTrue(actual[2]._id, v8); + assertTrue(actual[3]._id, v5); + assertTrue(actual[4]._id, v7); + }, + + testNeighborsAnyV6: function () { + actual = testGraph._neighbors(v6); + assertTrue(actual[0]._id, v2); + assertTrue(actual[1]._id, v7); + + + }, + + testCommonNeighborsAny: function () { - actual = testGraph._listCommonNeighbors(v3 , v6); + actual = testGraph._commonNeighbors(v3 , v6); assertEqual(actual[0][v3][v6][0]._id , v2); assertEqual(actual[0][v3][v6][1]._id , v7); - actual = testGraph._amountCommonNeighbors(v3 , v6); + actual = testGraph._countCommonNeighbors(v3 , v6); assertEqual(actual[0][v3][0][v6] , 2); }, //////////////////////////////////////////////////////////////////////////////// @@ -2326,7 +2345,7 @@ function GeneralGraphCommonNeighborsSuite() { //////////////////////////////////////////////////////////////////////////////// testCommonNeighborsIn: function () { - actual = testGraph._listCommonNeighbors({} , {}, {direction : 'inbound'}, {direction : 'inbound'}); + actual = testGraph._commonNeighbors({} , {}, {direction : 'inbound'}, {direction : 'inbound'}); assertEqual(actual[0][v3][v6][0]._id, v2); assertEqual(actual[1][v5][v8][0]._id, v3); assertEqual(actual[1][v5][v7][0]._id, v3); @@ -2336,7 +2355,7 @@ function GeneralGraphCommonNeighborsSuite() { assertEqual(actual[4][v8][v5][0]._id, v3); assertEqual(actual[4][v8][v7][0]._id, v3); - actual = testGraph._amountCommonNeighbors({} , {}, {direction : 'inbound'}, {direction : 'inbound'}); + actual = testGraph._countCommonNeighbors({} , {}, {direction : 'inbound'}, {direction : 'inbound'}); assertEqual(actual[0][v3][0][v6] , 1); assertEqual(actual[1][v5][0][v8] , 1); assertEqual(actual[1][v5][1][v7] , 1); @@ -2355,7 +2374,7 @@ function GeneralGraphCommonNeighborsSuite() { //////////////////////////////////////////////////////////////////////////////// testCommonNeighborsOut: function () { - actual = testGraph._listCommonNeighbors( + actual = testGraph._commonNeighbors( {hugo: true}, {heinz: 1}, {direction: 'outbound', minDepth: 1, maxDepth: 3}, {direction: 'outbound', minDepth: 1, maxDepth: 3} @@ -2372,7 +2391,7 @@ function GeneralGraphCommonNeighborsSuite() { assertEqual(actual[0][Object.keys(actual[0])[0]][v3].length, 4); assertEqual(actual[0][Object.keys(actual[0])[0]][v8].length, 3); - actual = testGraph._amountCommonNeighbors( + actual = testGraph._countCommonNeighbors( {hugo: true }, {heinz: 1}, {direction: 'outbound', minDepth: 1, maxDepth: 3}, {direction: 'outbound', minDepth: 1, maxDepth: 3} @@ -2388,7 +2407,7 @@ function GeneralGraphCommonNeighborsSuite() { //////////////////////////////////////////////////////////////////////////////// testCommonProperties: function () { - actual = testGraph._listCommonProperties({} ,{} ,{}); + actual = testGraph._commonProperties({} ,{} ,{}); assertEqual(actual[0][v1][0]._id , v2); assertEqual(actual[1][v2][0]._id , v1); assertEqual(actual[2][v3][0]._id , v8); @@ -2408,7 +2427,7 @@ function GeneralGraphCommonNeighborsSuite() { assertEqual(actual[7][v8][2]._id , v7); assertEqual(actual[7][v8][3]._id , v3); - actual = testGraph._amountCommonProperties({} ,{} ,{}); + actual = testGraph._countCommonProperties({} ,{} ,{}); assertEqual(actual, [ createKeyValueObject(v1, 1), createKeyValueObject(v2, 1), @@ -2422,13 +2441,13 @@ function GeneralGraphCommonNeighborsSuite() { }, testCommonPropertiesWithFilters: function () { - actual = testGraph._listCommonProperties({ageing : true} , {harald : 'meier'}, {}); + actual = testGraph._commonProperties({ageing : true} , {harald : 'meier'}, {}); assertEqual(actual[0][v5][0]._id , v6); assertEqual(actual[1][v6][0]._id , v4); assertEqual(actual[1][v6][1]._id , v8); assertEqual(actual[1][v6][2]._id , v7); - actual = testGraph._amountCommonProperties({ageing : true} , {harald : 'meier'}, {}); + actual = testGraph._countCommonProperties({ageing : true} , {harald : 'meier'}, {}); assertEqual(actual, [ createKeyValueObject(v5, 1), createKeyValueObject(v6, 3) @@ -2437,7 +2456,7 @@ function GeneralGraphCommonNeighborsSuite() { }, testCommonPropertiesWithFiltersAndIgnoringKeyHarald: function () { - actual = testGraph._listCommonProperties( {} , {}, {ignoreProperties : 'harald'}); + actual = testGraph._commonProperties( {} , {}, {ignoreProperties : 'harald'}); assertEqual(actual[0][v1][0]._id , v2); assertEqual(actual[1][v2][0]._id , v1); @@ -2446,7 +2465,7 @@ function GeneralGraphCommonNeighborsSuite() { assertEqual(actual[4][v6][0]._id , v5); assertEqual(actual[5][v8][0]._id , v3); - actual = testGraph._amountCommonProperties({} , {}, {ignoreProperties : 'harald'}); + actual = testGraph._countCommonProperties({} , {}, {ignoreProperties : 'harald'}); assertEqual(actual, [ createKeyValueObject(v1, 1), createKeyValueObject(v2, 1), @@ -2581,6 +2600,142 @@ function OrphanCollectionSuite() { } +function MeasurementsSuite() { + + var g; + var vertexId1, vertexId2; + var unitTestGraphName = "unitTestGraph"; + + var ec1 = "unitTestEdgeCollection1"; + var ec2 = "unitTestEdgeCollection2"; + var vc1 = "unitTestVertexCollection1"; + var vc2 = "unitTestVertexCollection2"; + var vc3 = "unitTestVertexCollection3"; + var vc4 = "unitTestVertexCollection4"; + + + var fillCollections = function() { + var ids = {}; + var vertex = g[vc1].save({first_name: "Tam"}); + ids.vId11 = vertex._id; + vertex = g[vc1].save({first_name: "Tem"}); + ids.vId12 = vertex._id; + vertex = g[vc1].save({first_name: "Tim"}); + ids.vId13 = vertex._id; + vertex = g[vc1].save({first_name: "Tom"}); + ids.vId14 = vertex._id; + vertex = g[vc1].save({first_name: "Tum"}); + ids.vId15 = vertex._id; + vertex = g[vc3].save({first_name: "Tam"}); + ids.vId31 = vertex._id; + vertex = g[vc3].save({first_name: "Tem"}); + ids.vId32 = vertex._id; + vertex = g[vc3].save({first_name: "Tim"}); + ids.vId33 = vertex._id; + vertex = g[vc3].save({first_name: "Tom"}); + ids.vId34 = vertex._id; + vertex = g[vc3].save({first_name: "Tum"}); + ids.vId35 = vertex._id; + + var edge = g[ec1].save(ids.vId11, ids.vId12, {}); + ids.eId11 = edge._id; + edge = g[ec1].save(ids.vId11, ids.vId13, {}); + ids.eId12 = edge._id; + edge = g[ec1].save(ids.vId11, ids.vId14, {}); + ids.eId13 = edge._id; + edge = g[ec1].save(ids.vId11, ids.vId15, {}); + ids.eId14 = edge._id; + edge = g[ec1].save(ids.vId12, ids.vId11, {}); + ids.eId15 = edge._id; + edge = g[ec1].save(ids.vId13, ids.vId11, {}); + ids.eId16 = edge._id; + edge = g[ec1].save(ids.vId14, ids.vId11, {}); + ids.eId17 = edge._id; + edge = g[ec1].save(ids.vId15, ids.vId11, {}); + ids.eId18 = edge._id; + edge = g[ec2].save(ids.vId11, ids.vId31, {}); + ids.eId21 = edge._id; + edge = g[ec2].save(ids.vId11, ids.vId32, {}); + ids.eId22 = edge._id; + edge = g[ec2].save(ids.vId11, ids.vId33, {}); + ids.eId23 = edge._id; + edge = g[ec2].save(ids.vId11, ids.vId34, {}); + ids.eId24 = edge._id; + edge = g[ec2].save(ids.vId11, ids.vId35, {}); + ids.eId25 = edge._id; + return ids; + }; + + return { + + setUp : function() { + try { + arangodb.db._collection("_graphs").remove(unitTestGraphName); + } catch (ignore) { + } + g = graph._create( + unitTestGraphName, + graph._edgeDefinitions( + graph._undirectedRelationDefinition(ec1, vc1), + graph._directedRelationDefinition(ec2, + [vc1, vc2], [vc3, vc4] + ) + ) + ); + fillCollections(); + }, + + tearDown : function() { + graph._drop(unitTestGraphName); + try {db[vc1].drop()} catch (e) {} + try {db[vc2].drop()} catch (e) {} + try {db[vc3].drop()} catch (e) {} + try {db[vc4].drop()} catch (e) {} + try {db[ec1].drop()} catch (e) {} + try {db[ec2].drop()} catch (e) {} + + }, + + test_absoluteEccentricity : function () { + var a = g._absoluteEccentricity({}); + assertEqual(Object.keys(a[0]).length , 10); + }, + + test_eccentricity : function () { + var a = g._eccentricity({}); + assertEqual(Object.keys(a[0]).length , 10); + }, + test_absoluteCloseness : function () { + var a = g._absoluteCloseness({}); + assertEqual(Object.keys(a[0]).length , 10); + }, + test_closeness : function () { + var a = g._closeness({}); + assertEqual(Object.keys(a[0]).length , 10); + }, + test_absoluteBetweenness : function () { + var a = g._absoluteBetweenness({}); + assertEqual(Object.keys(a[0]).length , 10); + }, + test_betweenness : function () { + var a = g._betweenness({}); + assertEqual(Object.keys(a[0]).length , 10); + }, + test_radius : function () { + var a = g._radius({}); + assertEqual(a[0] , 1); + }, + test_diameter : function () { + var a = g._diameter({}); + assertEqual(a[0] , 2); + } + + + }; +} + + + // ----------------------------------------------------------------------------- // --SECTION-- main @@ -2596,6 +2751,7 @@ jsunity.run(EdgesAndVerticesSuite); jsunity.run(GeneralGraphCreationSuite); jsunity.run(ChainedFluentAQLResultsSuite); jsunity.run(OrphanCollectionSuite); +jsunity.run(MeasurementsSuite); return jsunity.done(); diff --git a/js/server/modules/org/arangodb/ahuacatl.js b/js/server/modules/org/arangodb/ahuacatl.js index 2fff8abfc3..698b3ee494 100644 --- a/js/server/modules/org/arangodb/ahuacatl.js +++ b/js/server/modules/org/arangodb/ahuacatl.js @@ -4557,11 +4557,6 @@ function DOCUMENTS_BY_EXAMPLE (collectionList, example) { function RESOLVE_GRAPH_TO_DOCUMENTS (graphname, options) { // check graph exists and load edgeDefintions - /*if (ResolvedGraphCache[graphname + JSON.stringify(options)]) { - require("internal").print("resolved from cache"); - return ResolvedGraphCache[graphname + JSON.stringify(options)]; - }*/ - var graph = DOCUMENT_HANDLE("_graphs/" + graphname); if (! graph) { THROW(INTERNAL.errors.ERROR_GRAPH_INVALID_GRAPH, "GRAPH_EDGES"); @@ -5083,27 +5078,29 @@ function IS_EXAMPLE_SET (example) { /// /// *Examples* /// -/// A route planner example, shortest distance from all villages to other cities: +/// A route planner example, shortest distance from all german to all french cities: /// /// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphShortestPaths1} /// ~ var db = require("internal").db; /// var examples = require("org/arangodb/graph-examples/example-graph.js"); /// var g = examples.loadGraph("routeplanner"); /// |db._query("FOR e IN GRAPH_SHORTEST_PATH(" -/// |+"'routeplanner', {}, {}, {weight : 'distance', endVertexCollectionRestriction : 'city', " + -/// |"startVertexCollectionRestriction : 'village'}) RETURN [e.startVertex, e.vertex._id, " + +/// | + "'routeplanner', {}, {}, {" + +/// | "weight : 'distance', endVertexCollectionRestriction : 'frenchCity', " + +/// | "startVertexCollectionRestriction : 'germanCity'}) RETURN [e.startVertex, e.vertex._id, " + /// | "e.distance, LENGTH(e.paths)]" /// ).toArray(); /// @END_EXAMPLE_ARANGOSH_OUTPUT /// -/// A route planner example, shortest distance from Munich and Cologne to Olpe: +/// A route planner example, shortest distance from Hamburg and Cologne to Lyon: /// /// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphShortestPaths2} /// ~ var db = require("internal").db; /// var examples = require("org/arangodb/graph-examples/example-graph.js"); /// var g = examples.loadGraph("routeplanner"); /// |db._query("FOR e IN GRAPH_SHORTEST_PATH(" -/// |+"'routeplanner', [{_id: 'city/Cologne'},{_id: 'city/Munich'}], 'village/Olpe', " + +/// |+"'routeplanner', [{_id: 'germanCity/Cologne'},{_id: 'germanCity/Munich'}], " + +/// | "'frenchCity/Lyon', " + /// | "{weight : 'distance'}) RETURN [e.startVertex, e.vertex._id, e.distance, LENGTH(e.paths)]" /// ).toArray(); /// @END_EXAMPLE_ARANGOSH_OUTPUT @@ -5184,25 +5181,25 @@ function GRAPH_TRAVERSAL (vertexCollection, /// /// *Examples* /// -/// A route planner example, start a traversal from Munich : +/// A route planner example, start a traversal from Hamburg : /// /// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphTraversal1} /// ~ var db = require("internal").db; /// var examples = require("org/arangodb/graph-examples/example-graph.js"); /// var g = examples.loadGraph("routeplanner"); -/// |db._query("FOR e IN GRAPH_TRAVERSAL('routeplanner', 'city/Munich'," + +/// |db._query("FOR e IN GRAPH_TRAVERSAL('routeplanner', 'germanCity/Hamburg'," + /// | " 'outbound') RETURN e" /// ).toArray(); /// @END_EXAMPLE_ARANGOSH_OUTPUT /// -/// A route planner example, start a traversal from Munich with a max depth of 1 -/// so only the direct neighbors of munich are returned: +/// A route planner example, start a traversal from Hamburg with a max depth of 1 +/// so only the direct neighbors of Hamburg are returned: /// /// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphTraversal2} /// ~ var db = require("internal").db; /// var examples = require("org/arangodb/graph-examples/example-graph.js"); /// var g = examples.loadGraph("routeplanner"); -/// |db._query("FOR e IN GRAPH_TRAVERSAL('routeplanner', 'city/Munich'," + +/// |db._query("FOR e IN GRAPH_TRAVERSAL('routeplanner', 'germanCity/Hamburg'," + /// |" 'outbound', {maxDepth : 1}) RETURN e" /// ).toArray(); /// @END_EXAMPLE_ARANGOSH_OUTPUT @@ -5289,27 +5286,29 @@ function GRAPH_TRAVERSAL_TREE (vertexCollection, /// /// *Examples* /// -/// A route planner example, distance from all villages to other cities: +/// A route planner example, distance from all french to all german cities: /// /// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphDistanceTo1} /// ~ var db = require("internal").db; /// var examples = require("org/arangodb/graph-examples/example-graph.js"); /// var g = examples.loadGraph("routeplanner"); /// |db._query("FOR e IN GRAPH_DISTANCE_TO(" -/// |+"'routeplanner', {}, {}, {weight : 'distance', endVertexCollectionRestriction : 'city', " + -/// |"startVertexCollectionRestriction : 'village'}) RETURN [e.startVertex, e.vertex._id, " + +/// |+"'routeplanner', {}, {}, { " + +/// | " weight : 'distance', endVertexCollectionRestriction : 'germanCity', " + +/// |"startVertexCollectionRestriction : 'frenchCity'}) RETURN [e.startVertex, e.vertex._id, " + /// | "e.distance]" /// ).toArray(); /// @END_EXAMPLE_ARANGOSH_OUTPUT /// -/// A route planner example, distance from Munich and Cologne to Olpe: +/// A route planner example, distance from Hambug and Cologne to Lyon: /// /// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphDistanceTo2} /// ~ var db = require("internal").db; /// var examples = require("org/arangodb/graph-examples/example-graph.js"); /// var g = examples.loadGraph("routeplanner"); /// |db._query("FOR e IN GRAPH_DISTANCE_TO(" -/// |+"'routeplanner', [{_id: 'city/Cologne'},{_id: 'city/Munich'}], 'village/Olpe', " + +/// | + "'routeplanner', [{_id: 'germanCity/Cologne'},{_id: 'germanCity/Hamburg'}], " + +/// | "'frenchCity/Lyon', " + /// | "{weight : 'distance'}) RETURN [e.startVertex, e.vertex._id, e.distance]" /// ).toArray(); /// @END_EXAMPLE_ARANGOSH_OUTPUT @@ -5362,25 +5361,25 @@ function GENERAL_GRAPH_DISTANCE_TO (graphName, /// /// *Examples* /// -/// A route planner example, start a traversal from Munich : +/// A route planner example, start a traversal from Hamburg : /// /// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphTraversalTree1} /// ~ var db = require("internal").db; /// var examples = require("org/arangodb/graph-examples/example-graph.js"); /// var g = examples.loadGraph("routeplanner"); -/// |db._query("FOR e IN GRAPH_TRAVERSAL_TREE('routeplanner', 'city/Munich'," + +/// |db._query("FOR e IN GRAPH_TRAVERSAL_TREE('routeplanner', 'germanCity/Hamburg'," + /// | " 'outbound', 'connnection') RETURN e" /// ).toArray(); /// @END_EXAMPLE_ARANGOSH_OUTPUT /// -/// A route planner example, start a traversal from Munich with a max depth of 1 so -/// only the direct neighbors of munich are returned: +/// A route planner example, start a traversal from Hamburg with a max depth of 1 so +/// only the direct neighbors of Hamburg are returned: /// /// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphTraversalTree2} /// ~ var db = require("internal").db; /// var examples = require("org/arangodb/graph-examples/example-graph.js"); /// var g = examples.loadGraph("routeplanner"); -/// |db._query("FOR e IN GRAPH_TRAVERSAL_TREE('routeplanner', 'city/Munich',"+ +/// |db._query("FOR e IN GRAPH_TRAVERSAL_TREE('routeplanner', 'germanCity/Hamburg',"+ /// | " 'outbound', 'connnection', {maxDepth : 1}) RETURN e" /// ).toArray(); /// @END_EXAMPLE_ARANGOSH_OUTPUT @@ -5549,14 +5548,14 @@ function GRAPH_NEIGHBORS (vertexCollection, /// ).toArray(); /// @END_EXAMPLE_ARANGOSH_OUTPUT /// -/// A route planner example, all outbound neighbors of munich with a maximal depth of 2 : +/// A route planner example, all outbound neighbors of Hamburg with a maximal depth of 2 : /// /// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphNeighbors2} /// ~ var db = require("internal").db; /// var examples = require("org/arangodb/graph-examples/example-graph.js"); /// var g = examples.loadGraph("routeplanner"); /// |db._query("FOR e IN GRAPH_NEIGHBORS(" -/// |+"'routeplanner', 'city/Munich', {direction : 'outbound', maxDepth : 2}) RETURN e" +/// |+"'routeplanner', 'germanCity/Hamburg', {direction : 'outbound', maxDepth : 2}) RETURN e" /// ).toArray(); /// @END_EXAMPLE_ARANGOSH_OUTPUT /// @@ -5671,14 +5670,14 @@ function GENERAL_GRAPH_NEIGHBORS (graphName, /// ).toArray(); /// @END_EXAMPLE_ARANGOSH_OUTPUT /// -/// A route planner example, all outbound edges of munich with a maximal depth of 2 : +/// A route planner example, all outbound edges of Hamburg with a maximal depth of 2 : /// /// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphEdges2} /// ~ var db = require("internal").db; /// var examples = require("org/arangodb/graph-examples/example-graph.js"); /// var g = examples.loadGraph("routeplanner"); /// |db._query("FOR e IN GRAPH_EDGES(" -/// |+"'routeplanner', 'city/Munich', {direction : 'outbound', maxDepth : 2}) RETURN e" +/// |+"'routeplanner', 'germanCity/Hamburg', {direction : 'outbound', maxDepth : 2}) RETURN e" /// ).toArray(); /// @END_EXAMPLE_ARANGOSH_OUTPUT /// @@ -5746,7 +5745,7 @@ function GENERAL_GRAPH_EDGES ( /// ).toArray(); /// @END_EXAMPLE_ARANGOSH_OUTPUT /// -/// A route planner example, all vertices from collection *city*. +/// A route planner example, all vertices from collection *germanCity*. /// /// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphVertices2} /// ~ var db = require("internal").db; @@ -5754,7 +5753,7 @@ function GENERAL_GRAPH_EDGES ( /// var g = examples.loadGraph("routeplanner"); /// |db._query("FOR e IN GRAPH_VERTICES(" /// |+"'routeplanner', {}, {direction : 'any', vertexCollectionRestriction" + -/// |" : 'city'}) RETURN e" +/// |" : 'germanCity'}) RETURN e" /// ).toArray(); /// @END_EXAMPLE_ARANGOSH_OUTPUT /// @@ -5817,36 +5816,9 @@ function TRANSFER_GENERAL_GRAPH_NEIGHBORS_RESULT (result) { /// The function accepts an id, an example, a list of examples or even an empty /// example as parameter for vertex1Example and vertex2Example. /// -/// * String *graphName* : The name of the graph. -/// * String|Object|Array *vertex1Example* : An example for the desired -/// vertices (see below). -/// * String|Object|Array *vertex2Example* : An example for the desired -/// vertices (see below). -/// * Object *optionsVertex1* : Optional options, see below: -/// * Object *optionsVertex2* : Optional options, see below: -/// -/// Possible options and there defaults: -/// * String *direction* : The direction of the -/// edges. Possible values are *outbound*, *inbound* and *any* (default). -/// * String|Object|Array *edgeExamples* : A filter example -/// for the edges to the neighbors (see below). -/// * String|Object|Array *neighborExamples* : An example for -/// the desired neighbors (see below). -/// * String|Array *edgeCollectionRestriction* : One or multiple -/// edge collections that should be considered. -// * String|Array *vertexCollectionRestriction* : One or multiple -/// vertex collections that should be considered. -// / * Number *minDepth* : Defines the minimal -/// depth a path to a neighbor must have to be returned (default is 1). -/// * Number *maxDepth* : Defines the maximal -/// depth a path to a neighbor must have to be returned (default is 1). -/// -/// Examples for vertexExample: -/// * {} : Returns all possible vertices for this graph. -/// * *idString* : Returns the vertex with the id *idString*. -/// * {*key* : *value*} : Returns the vertices that match this example. -/// * [{*key1* : *value1*}, {*key2* : *value2*}] : Returns the vertices that -/// match one of the examples. +/// This function returns the intersection of *GRAPH_NEIGHBORS(vertex1Example, optionsVertex1)* +/// and *GRAPH_NEIGHBORS(vertex2Example, optionsVertex2)*. +/// For parameter documentation read the documentation of *GRAPH_NEIGHORS*. /// /// *Examples* /// @@ -5861,7 +5833,7 @@ function TRANSFER_GENERAL_GRAPH_NEIGHBORS_RESULT (result) { /// ).toArray(); /// @END_EXAMPLE_ARANGOSH_OUTPUT /// -/// A route planner example, all common outbound neighbors of munich with any other location +/// A route planner example, all common outbound neighbors of Hamburg with any other location /// which have a maximal depth of 2 : /// /// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphCommonNeighbors2} @@ -5869,7 +5841,7 @@ function TRANSFER_GENERAL_GRAPH_NEIGHBORS_RESULT (result) { /// var examples = require("org/arangodb/graph-examples/example-graph.js"); /// var g = examples.loadGraph("routeplanner"); /// |db._query("FOR e IN GRAPH_COMMON_NEIGHBORS(" -/// |+"'routeplanner', 'city/Munich', {}, {direction : 'outbound', maxDepth : 2}, "+ +/// |+"'routeplanner', 'germanCity/Hamburg', {}, {direction : 'outbound', maxDepth : 2}, "+ /// | "{direction : 'outbound', maxDepth : 2}) RETURN e" /// ).toArray(); /// @END_EXAMPLE_ARANGOSH_OUTPUT @@ -5985,9 +5957,7 @@ function GENERAL_GRAPH_COMMON_NEIGHBORS ( /// var examples = require("org/arangodb/graph-examples/example-graph.js"); /// var g = examples.loadGraph("routeplanner"); /// |db._query("FOR e IN GRAPH_COMMON_PROPERTIES(" -/// |+"'routeplanner', {}, {}, {vertex1CollectionRestriction : 'city', " + -/// | "vertex2CollectionRestriction : 'city'" + -/// |" ,ignoreProperties: 'population'}) RETURN e" +/// |+"'routeplanner', {}, {}, {ignoreProperties: 'population'}) RETURN e" /// ).toArray(); /// @END_EXAMPLE_ARANGOSH_OUTPUT /// @@ -6143,7 +6113,7 @@ function GENERAL_GRAPH_COMMON_PROPERTIES ( /// ).toArray(); /// @END_EXAMPLE_ARANGOSH_OUTPUT /// -/// A route planner example, the absolute eccentricity of all cities regarding only +/// A route planner example, the absolute eccentricity of all german cities regarding only /// outbound paths. /// /// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphAbsEccentricity3} @@ -6151,7 +6121,7 @@ function GENERAL_GRAPH_COMMON_PROPERTIES ( /// var examples = require("org/arangodb/graph-examples/example-graph.js"); /// var g = examples.loadGraph("routeplanner"); /// |db._query("RETURN GRAPH_ABSOLUTE_ECCENTRICITY(" -/// | + "'routeplanner', {}, {startVertexCollectionRestriction : 'city', " + +/// | + "'routeplanner', {}, {startVertexCollectionRestriction : 'germanCity', " + /// | "direction : 'outbound', weight : 'distance'})" /// ).toArray(); /// @END_EXAMPLE_ARANGOSH_OUTPUT @@ -6162,7 +6132,6 @@ function GENERAL_GRAPH_COMMON_PROPERTIES ( function GENERAL_GRAPH_ABSOLUTE_ECCENTRICITY (graphName, vertexExample, options) { "use strict"; - if (! options) { options = { }; } @@ -6332,7 +6301,7 @@ function GENERAL_GRAPH_ECCENTRICITY (graphName, options) { /// ).toArray(); /// @END_EXAMPLE_ARANGOSH_OUTPUT /// -/// A route planner example, the absolute closeness of all cities regarding only +/// A route planner example, the absolute closeness of all german cities regarding only /// outbound paths. /// /// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphAbsCloseness3} @@ -6340,7 +6309,7 @@ function GENERAL_GRAPH_ECCENTRICITY (graphName, options) { /// var examples = require("org/arangodb/graph-examples/example-graph.js"); /// var g = examples.loadGraph("routeplanner"); /// |db._query("RETURN GRAPH_ABSOLUTE_CLOSENESS(" -/// | + "'routeplanner', {}, {startVertexCollectionRestriction : 'city', " + +/// | + "'routeplanner', {}, {startVertexCollectionRestriction : 'germanCity', " + /// | "direction : 'outbound', weight : 'distance'})" /// ).toArray(); /// @END_EXAMPLE_ARANGOSH_OUTPUT @@ -6489,7 +6458,7 @@ function GENERAL_GRAPH_CLOSENESS (graphName, options) { /// 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. +/// hence the betweenness can not be calculated. /// /// *Examples* /// @@ -6516,7 +6485,7 @@ function GENERAL_GRAPH_CLOSENESS (graphName, options) { /// ).toArray(); /// @END_EXAMPLE_ARANGOSH_OUTPUT /// -/// A route planner example, the absolute closeness of all cities regarding only +/// A route planner example, the absolute closeness regarding only /// outbound paths. /// /// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphAbsBetweenness3} @@ -6612,7 +6581,7 @@ function GENERAL_GRAPH_ABSOLUTE_BETWEENNESS (graphName, options) { /// ).toArray(); /// @END_EXAMPLE_ARANGOSH_OUTPUT /// -/// A route planner example, the closeness of all locations. +/// A route planner example, the betweenness of all locations. /// This considers the actual distances. /// /// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphBetweenness2} @@ -6624,7 +6593,7 @@ function GENERAL_GRAPH_ABSOLUTE_BETWEENNESS (graphName, options) { /// ).toArray(); /// @END_EXAMPLE_ARANGOSH_OUTPUT /// -/// A route planner example, the closeness of all cities regarding only +/// A route planner example, the betweenness regarding only /// outbound paths. /// /// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphBetweenness3} @@ -6711,7 +6680,7 @@ function GENERAL_GRAPH_BETWEENNESS (graphName, options) { /// ).toArray(); /// @END_EXAMPLE_ARANGOSH_OUTPUT /// -/// A route planner example, the cradius of the graph regarding only +/// A route planner example, the radius of the graph regarding only /// outbound paths. /// /// @EXAMPLE_ARANGOSH_OUTPUT{generalGraphRadius3}