Graph Functions

    Examples will explain the API on the :

    For many of the following functions examples can be passed in as a parameter.Examples are used to filter the result set for objects that match the conditions.These examples can have the following values:

    • null, there is no matching executed all found results are valid.
    • A string, only results are returned, which _id equal the value of the string
    • An example object, defining a set of attributes. Only results having these attributes are matched.
    • A list containing example objects and/or strings. All results matching at least one of the elements in the list are returned.

    Get vertices from edges.

    Get the source vertex of an edge

    Returns the vertex defined with the attribute from of the edge with _edgeId as its id_.

    Parameters

    • edgeId (required) _id attribute of the edge

    Examples

    Show execution results

    Hide execution results

    1. {
    2. "_key" : "alice",
    3. "_id" : "female/alice",
    4. "_rev" : "_Z2KDQUG---",
    5. "name" : "Alice"
    6. }

    Get vertex to of an edge

    Get the target vertex of an edge

    graph._toVertex(edgeId)

    Returns the vertex defined with the attribute to of the edge with _edgeId as its id_.

    Parameters

    • edgeId (required) _id attribute of the edge

    Examples

    1. arangosh> var examples = require("@arangodb/graph-examples/example-graph.js");
    2. arangosh> var graph = examples.loadGraph("social");
    3. arangosh> var any = require("@arangodb").db.relation.any();
    4. arangosh> graph._toVertex("relation/" + any._key);

    Show execution results

    Hide execution results

    1. {
    2. "_key" : "charly",
    3. "_id" : "male/charly",
    4. "_rev" : "_Z2KDQVG---",
    5. "name" : "Charly"
    6. }

    _neighbors

    Get all neighbors of the vertices defined by the example

    graph._neighbors(vertexExample, options)

    The function accepts an id, an example, a list of examples or even an emptyexample as parameter for vertexExample.The complexity of this method is O(n*m^x) with n being the vertices defined by theparameter vertexExamplex, m the average amount of neighbors and x the maximal depths.Hence the default call would have a complexity of O(n*m);

    Parameters

    • vertexExample (optional) See Definition of examples
    • options (optional) An object defining further options. Can have the following values:
      • direction: The direction of the edges. Possible values are outbound, inbound and any (default).
      • edgeExamples: Filter the edges, see
      • neighborExamples: Filter the neighbor vertices, see Definition of examples
      • edgeCollectionRestriction : One or a list of edge-collection names that should beconsidered to be on the path.
      • vertexCollectionRestriction : One or a list of vertex-collection names that should beconsidered on the intermediate vertex steps.
      • minDepth: Defines the minimal number of intermediate steps to neighbors (default is 1).
      • maxDepth: Defines the maximal number of intermediate steps to neighbors (default is 1).

    Examples

    A route planner example, all neighbors of capitals.

    1. arangosh> var examples = require("@arangodb/graph-examples/example-graph.js");
    2. arangosh> var graph = examples.loadGraph("routeplanner");
    3. arangosh> graph._neighbors({isCapital : true});

    Show execution results

    Hide execution results

    1. [
    2. "frenchCity/Lyon",
    3. "germanCity/Berlin",
    4. "germanCity/Hamburg",
    5. "germanCity/Cologne",
    6. "frenchCity/Paris"
    7. ]

    A route planner example, all outbound neighbors of Hamburg.

    1. arangosh> var examples = require("@arangodb/graph-examples/example-graph.js");
    2. arangosh> var graph = examples.loadGraph("routeplanner");
    3. arangosh> graph._neighbors('germanCity/Hamburg', {direction : 'outbound', maxDepth : 2});

    Show execution results

    Hide execution results

    1. [
    2. "germanCity/Cologne",
    3. "frenchCity/Paris",
    4. "frenchCity/Lyon"
    5. ]

    _commonNeighbors

    Get all common neighbors of the vertices defined by the examples.

    graph._commonNeighbors(vertex1Example, vertex2Examples, optionsVertex1, optionsVertex2)

    This function returns the intersection of graph_module._neighbors(vertex1Example, optionsVertex1)_and _graph_module._neighbors(vertex2Example, optionsVertex2).For parameter documentation see .

    The complexity of this method is O(n*m^x) with n being the maximal amount of verticesdefined by the parameters vertexExamples, m the average amount of neighbors and x themaximal depths.Hence the default call would have a complexity of O(n*m);

    Examples

    A route planner example, all common neighbors of capitals.

    1. arangosh> var examples = require("@arangodb/graph-examples/example-graph.js");
    2. arangosh> var graph = examples.loadGraph("routeplanner");
    3. arangosh> graph._commonNeighbors({isCapital : true}, {isCapital : true});

    Show execution results

    Hide execution results

    1. [
    2. {
    3. "left" : "frenchCity/Paris",
    4. "right" : "germanCity/Berlin",
    5. "neighbors" : [
    6. "germanCity/Cologne",
    7. "germanCity/Hamburg",
    8. "frenchCity/Lyon"
    9. ]
    10. },
    11. {
    12. "left" : "germanCity/Berlin",
    13. "right" : "frenchCity/Paris",
    14. "neighbors" : [
    15. "frenchCity/Lyon",
    16. "germanCity/Hamburg",
    17. "germanCity/Cologne"
    18. ]
    19. }
    20. ]

    A route planner example, all common outbound neighbors of Hamburg with any other locationwhich have a maximal depth of 2 :

    1. arangosh> var examples = require("@arangodb/graph-examples/example-graph.js");
    2. arangosh> var graph = examples.loadGraph("routeplanner");
    3. arangosh> graph._commonNeighbors(
    4. ........> 'germanCity/Hamburg',
    5. ........> {},
    6. ........> {direction : 'outbound', maxDepth : 2},
    7. ........> {direction : 'outbound', maxDepth : 2});

    Show execution results

    Hide execution results

    1. [
    2. {
    3. "left" : "germanCity/Hamburg",
    4. "right" : "frenchCity/Paris",
    5. "neighbors" : [
    6. "frenchCity/Lyon"
    7. ]
    8. },
    9. {
    10. "left" : "germanCity/Hamburg",
    11. "right" : "germanCity/Berlin",
    12. "neighbors" : [
    13. "frenchCity/Lyon",
    14. "frenchCity/Paris",
    15. "germanCity/Cologne"
    16. ]
    17. },
    18. {
    19. "left" : "germanCity/Hamburg",
    20. "right" : "germanCity/Cologne",
    21. "neighbors" : [
    22. "frenchCity/Lyon",
    23. "frenchCity/Paris"
    24. ]
    25. }
    26. ]

    _countCommonNeighbors

    Get the amount of common neighbors of the vertices defined by the examples.

    graph._countCommonNeighbors(vertex1Example, vertex2Examples, optionsVertex1, optionsVertex2)

    Similar to _commonNeighbors but returns count instead of the elements.

    Examples

    A route planner example, all common neighbors of capitals.

    1. arangosh> var examples = require("@arangodb/graph-examples/example-graph.js");
    2. arangosh> var graph = examples.loadGraph("routeplanner");
    3. arangosh> var example = { isCapital: true };
    4. arangosh> var options = { includeData: true };
    5. arangosh> graph._countCommonNeighbors(example, example, options, options);

    Show execution results

    Hide execution results

    1. [
    2. {
    3. "frenchCity/Paris" : [
    4. {
    5. "germanCity/Berlin" : 3
    6. }
    7. ]
    8. },
    9. {
    10. "germanCity/Berlin" : [
    11. {
    12. "frenchCity/Paris" : 3
    13. }
    14. ]
    15. }
    16. ]

    A route planner example, all common outbound neighbors of Hamburg with any other locationwhich have a maximal depth of 2 :

    1. arangosh> var examples = require("@arangodb/graph-examples/example-graph.js");
    2. arangosh> var graph = examples.loadGraph("routeplanner");
    3. arangosh> var options = { direction: 'outbound', maxDepth: 2, includeData: true };
    4. arangosh> graph._countCommonNeighbors('germanCity/Hamburg', {}, options, options);

    Show execution results

    Hide execution results

    1. [
    2. {
    3. "germanCity/Hamburg" : [
    4. {
    5. "frenchCity/Paris" : 1
    6. },
    7. {
    8. "germanCity/Berlin" : 3
    9. },
    10. {
    11. "germanCity/Cologne" : 2
    12. }
    13. ]
    14. }
    15. ]

    _commonProperties

    Get the vertices of the graph that share common properties.

    The function accepts an id, an example, a list of examples or even an emptyexample as parameter for vertex1Example and vertex2Example.

    The complexity of this method is O(n) with n being the maximal amount of verticesdefined by the parameters vertexExamples.

    Parameters

    • vertex1Examples (optional) Filter the set of source vertices, see

    • vertex2Examples (optional) Filter the set of vertices compared to, see Definition of examples

    • options (optional) An object defining further options. Can have the following values:
      • vertex1CollectionRestriction : One or a list of vertex-collection names that should besearched for source vertices.
      • vertex2CollectionRestriction : One or a list of vertex-collection names that should besearched for compare vertices.
      • ignoreProperties : One or a list of attribute names of a document that should be ignored.

    Examples

    A route planner example, all locations with the same properties:

    1. arangosh> var examples = require("@arangodb/graph-examples/example-graph.js");
    2. arangosh> var graph = examples.loadGraph("routeplanner");
    3. arangosh> graph._commonProperties({}, {});

    Show execution results

    Hide execution results

    1. [
    2. {
    3. "frenchCity/Lyon" : [
    4. {
    5. "_id" : "germanCity/Cologne",
    6. "isCapital" : false
    7. },
    8. {
    9. "_id" : "germanCity/Hamburg",
    10. "isCapital" : false
    11. }
    12. ]
    13. },
    14. {
    15. "frenchCity/Paris" : [
    16. {
    17. "_id" : "germanCity/Berlin",
    18. "isCapital" : true
    19. }
    20. ]
    21. },
    22. {
    23. "germanCity/Berlin" : [
    24. {
    25. "_id" : "frenchCity/Paris",
    26. "isCapital" : true
    27. }
    28. ]
    29. },
    30. {
    31. "germanCity/Cologne" : [
    32. {
    33. "_id" : "frenchCity/Lyon",
    34. "isCapital" : false
    35. },
    36. {
    37. "_id" : "germanCity/Hamburg",
    38. "isCapital" : false,
    39. "population" : 1000000
    40. }
    41. ]
    42. },
    43. {
    44. "germanCity/Hamburg" : [
    45. {
    46. "_id" : "frenchCity/Lyon",
    47. "isCapital" : false
    48. },
    49. {
    50. "_id" : "germanCity/Cologne",
    51. "isCapital" : false,
    52. "population" : 1000000
    53. }
    54. ]
    55. }
    56. ]

    A route planner example, all cities which share same properties except for population.

    1. arangosh> var examples = require("@arangodb/graph-examples/example-graph.js");
    2. arangosh> var graph = examples.loadGraph("routeplanner");
    3. arangosh> graph._commonProperties({}, {}, {ignoreProperties: 'population'});

    Show execution results

    Hide execution results

    1. [
    2. {
    3. "frenchCity/Lyon" : [
    4. {
    5. "_id" : "germanCity/Cologne",
    6. "isCapital" : false
    7. },
    8. {
    9. "_id" : "germanCity/Hamburg",
    10. "isCapital" : false
    11. }
    12. ]
    13. },
    14. {
    15. "frenchCity/Paris" : [
    16. {
    17. "_id" : "germanCity/Berlin",
    18. "isCapital" : true
    19. }
    20. ]
    21. },
    22. {
    23. "germanCity/Berlin" : [
    24. {
    25. "_id" : "frenchCity/Paris",
    26. "isCapital" : true
    27. }
    28. ]
    29. },
    30. {
    31. "germanCity/Cologne" : [
    32. {
    33. "_id" : "frenchCity/Lyon",
    34. "isCapital" : false
    35. },
    36. {
    37. "_id" : "germanCity/Hamburg",
    38. "isCapital" : false
    39. }
    40. ]
    41. },
    42. {
    43. "germanCity/Hamburg" : [
    44. {
    45. "_id" : "frenchCity/Lyon",
    46. "isCapital" : false
    47. },
    48. {
    49. "_id" : "germanCity/Cologne",
    50. "isCapital" : false
    51. }
    52. ]
    53. }
    54. ]

    Get the amount of vertices of the graph that share common properties.

    graph._countCommonProperties(vertex1Example, vertex2Examples, options)

    Similar to but returns count instead ofthe objects.

    Examples

    A route planner example, all locations with the same properties:

    1. arangosh> var examples = require("@arangodb/graph-examples/example-graph.js");
    2. arangosh> var graph = examples.loadGraph("routeplanner");
    3. arangosh> graph._countCommonProperties({}, {});

    Show execution results

    1. [
    2. {
    3. "frenchCity/Lyon" : 2
    4. },
    5. {
    6. "frenchCity/Paris" : 1
    7. },
    8. {
    9. "germanCity/Berlin" : 1
    10. },
    11. {
    12. "germanCity/Cologne" : 2
    13. },
    14. {
    15. "germanCity/Hamburg" : 2
    16. }
    17. ]

    A route planner example, all German cities which share same properties except for population.

    1. arangosh> var examples = require("@arangodb/graph-examples/example-graph.js");
    2. arangosh> var graph = examples.loadGraph("routeplanner");
    3. arangosh> graph._countCommonProperties({}, {}, {vertex1CollectionRestriction : 'germanCity',
    4. ........> vertex2CollectionRestriction : 'germanCity' ,ignoreProperties: 'population'});

    Show execution results

    Hide execution results

    1. [
    2. {
    3. "frenchCity/Lyon" : 2
    4. },
    5. {
    6. "frenchCity/Paris" : 1
    7. },
    8. {
    9. "germanCity/Berlin" : 1
    10. },
    11. {
    12. "germanCity/Cologne" : 2
    13. },
    14. {
    15. "germanCity/Hamburg" : 2
    16. }
    17. ]

    _paths

    The _paths function returns all paths of a graph.

    graph._paths(options)

    This function determines all available paths in a graph.

    The complexity of this method is O(nnm) with n being the amount of vertices inthe graph and m the average amount of connected edges;

    Parameters

    • options (optional) An object containing options, see below:
      • direction: The direction of the edges. Possible values are any,inbound and outbound (default).
      • followCycles (optional): If set to true the query follows cycles in the graph,default is false.
      • minLength (optional): Defines the minimal length a path musthave to be returned (default is 0).
      • maxLength (optional): Defines the maximal length a path must have to be returned (default is 10).

    Examples

    Return all paths of the graph “social”:

    1. arangosh> var examples = require("@arangodb/graph-examples/example-graph.js");
    2. arangosh> var g = examples.loadGraph("social");
    3. arangosh> g._paths();

    Show execution results

    Hide execution results

    1. [
    2. {
    3. "source" : {
    4. "_key" : "alice",
    5. "_id" : "female/alice",
    6. "_rev" : "_Z2KDRF6---",
    7. "name" : "Alice"
    8. },
    9. "destination" : {
    10. "_key" : "alice",
    11. "_id" : "female/alice",
    12. "_rev" : "_Z2KDRF6---",
    13. "name" : "Alice"
    14. },
    15. "edges" : [ ],
    16. "vertice" : [
    17. {
    18. "_key" : "alice",
    19. "_id" : "female/alice",
    20. "_rev" : "_Z2KDRF6---",
    21. "name" : "Alice"
    22. }
    23. ]
    24. },
    25. {
    26. "source" : {
    27. "_key" : "alice",
    28. "_id" : "female/alice",
    29. "_rev" : "_Z2KDRF6---",
    30. "name" : "Alice"
    31. },
    32. "destination" : {
    33. "_key" : "bob",
    34. "_id" : "male/bob",
    35. "_rev" : "_Z2KDRG----",
    36. "name" : "Bob"
    37. },
    38. "edges" : [
    39. {
    40. "_key" : "77883",
    41. "_id" : "relation/77883",
    42. "_from" : "female/alice",
    43. "_to" : "male/bob",
    44. "_rev" : "_Z2KDRGC---",
    45. "type" : "married",
    46. "vertex" : "alice"
    47. }
    48. ],
    49. "vertice" : [
    50. {
    51. "_key" : "alice",
    52. "_id" : "female/alice",
    53. "_rev" : "_Z2KDRF6---",
    54. "name" : "Alice"
    55. },
    56. {
    57. "_key" : "bob",
    58. "_id" : "male/bob",
    59. "_rev" : "_Z2KDRG----",
    60. "name" : "Bob"
    61. }
    62. ]
    63. },
    64. {
    65. "source" : {
    66. "_key" : "alice",
    67. "_id" : "female/alice",
    68. "_rev" : "_Z2KDRF6---",
    69. "name" : "Alice"
    70. },
    71. "destination" : {
    72. "_key" : "diana",
    73. "_id" : "female/diana",
    74. "_rev" : "_Z2KDRG---C",
    75. "name" : "Diana"
    76. },
    77. "edges" : [
    78. {
    79. "_key" : "77883",
    80. "_id" : "relation/77883",
    81. "_from" : "female/alice",
    82. "_to" : "male/bob",
    83. "_rev" : "_Z2KDRGC---",
    84. "type" : "married",
    85. "vertex" : "alice"
    86. },
    87. {
    88. "_key" : "77889",
    89. "_id" : "relation/77889",
    90. "_from" : "male/bob",
    91. "_to" : "female/diana",
    92. "_rev" : "_Z2KDRGG--A",
    93. "type" : "friend",
    94. "vertex" : "bob"
    95. }
    96. ],
    97. "vertice" : [
    98. {
    99. "_key" : "alice",
    100. "_id" : "female/alice",
    101. "_rev" : "_Z2KDRF6---",
    102. "name" : "Alice"
    103. },
    104. {
    105. "_key" : "bob",
    106. "_id" : "male/bob",
    107. "_rev" : "_Z2KDRG----",
    108. "name" : "Bob"
    109. },
    110. {
    111. "_key" : "diana",
    112. "_id" : "female/diana",
    113. "_rev" : "_Z2KDRG---C",
    114. "name" : "Diana"
    115. }
    116. ]
    117. },
    118. {
    119. "source" : {
    120. "_key" : "alice",
    121. "_id" : "female/alice",
    122. "_rev" : "_Z2KDRF6---",
    123. "name" : "Alice"
    124. },
    125. "destination" : {
    126. "_key" : "charly",
    127. "_id" : "male/charly",
    128. "_rev" : "_Z2KDRG---A",
    129. "name" : "Charly"
    130. },
    131. "edges" : [
    132. "_key" : "77885",
    133. "_id" : "relation/77885",
    134. "_from" : "female/alice",
    135. "_to" : "male/charly",
    136. "_rev" : "_Z2KDRGC--A",
    137. "type" : "friend",
    138. "vertex" : "alice"
    139. }
    140. ],
    141. "vertice" : [
    142. {
    143. "_key" : "alice",
    144. "_id" : "female/alice",
    145. "_rev" : "_Z2KDRF6---",
    146. "name" : "Alice"
    147. },
    148. {
    149. "_key" : "charly",
    150. "_id" : "male/charly",
    151. "_rev" : "_Z2KDRG---A",
    152. "name" : "Charly"
    153. }
    154. ]
    155. },
    156. {
    157. "source" : {
    158. "_key" : "alice",
    159. "_id" : "female/alice",
    160. "_rev" : "_Z2KDRF6---",
    161. "name" : "Alice"
    162. },
    163. "destination" : {
    164. "_key" : "diana",
    165. "_id" : "female/diana",
    166. "_rev" : "_Z2KDRG---C",
    167. "name" : "Diana"
    168. },
    169. "edges" : [
    170. {
    171. "_key" : "77885",
    172. "_id" : "relation/77885",
    173. "_from" : "female/alice",
    174. "_to" : "male/charly",
    175. "_rev" : "_Z2KDRGC--A",
    176. "type" : "friend",
    177. "vertex" : "alice"
    178. },
    179. {
    180. "_key" : "77887",
    181. "_id" : "relation/77887",
    182. "_from" : "male/charly",
    183. "_to" : "female/diana",
    184. "_rev" : "_Z2KDRGG---",
    185. "type" : "married",
    186. "vertex" : "charly"
    187. }
    188. ],
    189. "vertice" : [
    190. {
    191. "_key" : "alice",
    192. "_id" : "female/alice",
    193. "_rev" : "_Z2KDRF6---",
    194. "name" : "Alice"
    195. },
    196. {
    197. "_key" : "charly",
    198. "_id" : "male/charly",
    199. "_rev" : "_Z2KDRG---A",
    200. "name" : "Charly"
    201. },
    202. {
    203. "_key" : "diana",
    204. "_id" : "female/diana",
    205. "_rev" : "_Z2KDRG---C",
    206. "name" : "Diana"
    207. }
    208. ]
    209. },
    210. {
    211. "source" : {
    212. "_key" : "diana",
    213. "_id" : "female/diana",
    214. "_rev" : "_Z2KDRG---C",
    215. "name" : "Diana"
    216. },
    217. "destination" : {
    218. "_key" : "diana",
    219. "_id" : "female/diana",
    220. "_rev" : "_Z2KDRG---C",
    221. "name" : "Diana"
    222. },
    223. "edges" : [ ],
    224. "vertice" : [
    225. {
    226. "_key" : "diana",
    227. "_id" : "female/diana",
    228. "_rev" : "_Z2KDRG---C",
    229. "name" : "Diana"
    230. }
    231. ]
    232. },
    233. {
    234. "source" : {
    235. "_key" : "bob",
    236. "_id" : "male/bob",
    237. "_rev" : "_Z2KDRG----",
    238. "name" : "Bob"
    239. },
    240. "destination" : {
    241. "_key" : "bob",
    242. "_id" : "male/bob",
    243. "_rev" : "_Z2KDRG----",
    244. "name" : "Bob"
    245. },
    246. "edges" : [ ],
    247. "vertice" : [
    248. {
    249. "_key" : "bob",
    250. "_id" : "male/bob",
    251. "_rev" : "_Z2KDRG----",
    252. "name" : "Bob"
    253. }
    254. ]
    255. },
    256. {
    257. "source" : {
    258. "_key" : "bob",
    259. "_id" : "male/bob",
    260. "_rev" : "_Z2KDRG----",
    261. "name" : "Bob"
    262. },
    263. "destination" : {
    264. "_key" : "diana",
    265. "_id" : "female/diana",
    266. "_rev" : "_Z2KDRG---C",
    267. "name" : "Diana"
    268. },
    269. "edges" : [
    270. {
    271. "_key" : "77889",
    272. "_id" : "relation/77889",
    273. "_from" : "male/bob",
    274. "_to" : "female/diana",
    275. "_rev" : "_Z2KDRGG--A",
    276. "type" : "friend",
    277. "vertex" : "bob"
    278. }
    279. ],
    280. "vertice" : [
    281. {
    282. "_key" : "bob",
    283. "_id" : "male/bob",
    284. "_rev" : "_Z2KDRG----",
    285. "name" : "Bob"
    286. },
    287. {
    288. "_key" : "diana",
    289. "_id" : "female/diana",
    290. "_rev" : "_Z2KDRG---C",
    291. "name" : "Diana"
    292. }
    293. ]
    294. },
    295. {
    296. "source" : {
    297. "_key" : "charly",
    298. "_id" : "male/charly",
    299. "_rev" : "_Z2KDRG---A",
    300. "name" : "Charly"
    301. },
    302. "destination" : {
    303. "_key" : "charly",
    304. "_id" : "male/charly",
    305. "_rev" : "_Z2KDRG---A",
    306. "name" : "Charly"
    307. },
    308. "edges" : [ ],
    309. "vertice" : [
    310. {
    311. "_key" : "charly",
    312. "_id" : "male/charly",
    313. "_rev" : "_Z2KDRG---A",
    314. "name" : "Charly"
    315. }
    316. ]
    317. },
    318. {
    319. "source" : {
    320. "_key" : "charly",
    321. "_id" : "male/charly",
    322. "_rev" : "_Z2KDRG---A",
    323. "name" : "Charly"
    324. },
    325. "destination" : {
    326. "_key" : "diana",
    327. "_id" : "female/diana",
    328. "_rev" : "_Z2KDRG---C",
    329. "name" : "Diana"
    330. },
    331. "edges" : [
    332. {
    333. "_key" : "77887",
    334. "_id" : "relation/77887",
    335. "_from" : "male/charly",
    336. "_to" : "female/diana",
    337. "_rev" : "_Z2KDRGG---",
    338. "type" : "married",
    339. "vertex" : "charly"
    340. }
    341. ],
    342. "vertice" : [
    343. {
    344. "_key" : "charly",
    345. "_id" : "male/charly",
    346. "_rev" : "_Z2KDRG---A",
    347. "name" : "Charly"
    348. },
    349. {
    350. "_key" : "diana",
    351. "_id" : "female/diana",
    352. "_rev" : "_Z2KDRG---C",
    353. "name" : "Diana"
    354. }
    355. ]
    356. }
    357. ]

    Return all inbound paths of the graph “social” with a maximallength of 1 and a minimal length of 2:

    1. arangosh> var examples = require("@arangodb/graph-examples/example-graph.js");
    2. arangosh> var g = examples.loadGraph("social");
    3. arangosh> g._paths({direction : 'inbound', minLength : 1, maxLength : 2});

    Show execution results

    Hide execution results

    _shortestPath

    The _shortestPath function returns all shortest paths of a graph.

    graph._shortestPath(startVertexExample, endVertexExample, options)

    This function determines all shortest paths in a graph.The function accepts an id, an example, a list of examplesor even an empty example as parameter forstart and end vertex.The length of a path is by default the amount of edges from one start vertex toan end vertex. The option weight allows the user to define an edge attributerepresenting the length.

    Parameters

    • startVertexExample (optional) An example for the desired start Vertices (see Definition of examples).
    • endVertexExample (optional) An example for the desired end Vertices (see ).
    • options (optional) An object containing options, see below:
      • direction: The direction of the edges as a string.Possible values are outbound, inbound and any (default).
      • edgeCollectionRestriction: One or multiple edgecollection names. Only edges from these collections will be considered for the path.
      • startVertexCollectionRestriction: One or multiple vertexcollection names. Only vertices from these collections will be considered asstart vertex of a path.
      • endVertexCollectionRestriction: One or multiple vertexcollection names. Only vertices from these collections will be considered asend vertex of a path.
      • weight: The name of the attribute ofthe edges containing the length as a string.
      • defaultWeight: Only used with the option weight.If an edge does not have the attribute named as defined in option weight this defaultis used as length.If no default is supplied the default would be positive Infinity so the path couldnot be calculated.

    Examples

    A route planner example, shortest path from all german to all french cities:

    1. arangosh> var examples = require("@arangodb/graph-examples/example-graph.js");
    2. arangosh> var g = examples.loadGraph("routeplanner");
    3. arangosh> g._shortestPath({}, {}, {weight : 'distance', endVertexCollectionRestriction : 'frenchCity',
    4. ........> startVertexCollectionRestriction : 'germanCity'});

    Show execution results

    Hide execution results

    1. [
    2. {
    3. "vertices" : [
    4. "frenchCity/Lyon",
    5. "frenchCity/Paris"
    6. ],
    7. "edges" : [
    8. {
    9. "_key" : "78373",
    10. "_id" : "frenchHighway/78373",
    11. "_from" : "frenchCity/Paris",
    12. "_to" : "frenchCity/Lyon",
    13. "_rev" : "_Z2KDRR6---",
    14. "distance" : 550
    15. }
    16. ],
    17. "distance" : 1
    18. },
    19. {
    20. "vertices" : [
    21. "frenchCity/Lyon",
    22. "germanCity/Berlin"
    23. ],
    24. "edges" : [
    25. {
    26. "_key" : "78375",
    27. "_id" : "internationalHighway/78375",
    28. "_from" : "germanCity/Berlin",
    29. "_to" : "frenchCity/Lyon",
    30. "_rev" : "_Z2KDRR6--A",
    31. "distance" : 1100
    32. }
    33. ],
    34. "distance" : 1
    35. },
    36. {
    37. "vertices" : [
    38. "frenchCity/Lyon",
    39. "germanCity/Cologne"
    40. ],
    41. "edges" : [
    42. {
    43. "_key" : "78383",
    44. "_id" : "internationalHighway/78383",
    45. "_from" : "germanCity/Cologne",
    46. "_to" : "frenchCity/Lyon",
    47. "_rev" : "_Z2KDRSC--A",
    48. "distance" : 700
    49. }
    50. ],
    51. "distance" : 1
    52. },
    53. {
    54. "vertices" : [
    55. "frenchCity/Lyon",
    56. "germanCity/Hamburg"
    57. ],
    58. "edges" : [
    59. {
    60. "_key" : "78381",
    61. "_id" : "internationalHighway/78381",
    62. "_from" : "germanCity/Hamburg",
    63. "_to" : "frenchCity/Lyon",
    64. "_rev" : "_Z2KDRSC---",
    65. "distance" : 1300
    66. }
    67. ],
    68. "distance" : 1
    69. },
    70. {
    71. "vertices" : [
    72. "frenchCity/Paris",
    73. "frenchCity/Lyon"
    74. ],
    75. "edges" : [
    76. {
    77. "_key" : "78373",
    78. "_id" : "frenchHighway/78373",
    79. "_from" : "frenchCity/Paris",
    80. "_to" : "frenchCity/Lyon",
    81. "_rev" : "_Z2KDRR6---",
    82. "distance" : 550
    83. }
    84. ],
    85. "distance" : 1
    86. },
    87. {
    88. "vertices" : [
    89. "frenchCity/Paris",
    90. "germanCity/Berlin"
    91. ],
    92. "edges" : [
    93. {
    94. "_key" : "78377",
    95. "_id" : "internationalHighway/78377",
    96. "_from" : "germanCity/Berlin",
    97. "_to" : "frenchCity/Paris",
    98. "_rev" : "_Z2KDRS----",
    99. "distance" : 1200
    100. }
    101. ],
    102. "distance" : 1
    103. },
    104. {
    105. "vertices" : [
    106. "frenchCity/Paris",
    107. "germanCity/Cologne"
    108. ],
    109. "edges" : [
    110. {
    111. "_key" : "78385",
    112. "_id" : "internationalHighway/78385",
    113. "_from" : "germanCity/Cologne",
    114. "_to" : "frenchCity/Paris",
    115. "_rev" : "_Z2KDRSG---",
    116. "distance" : 550
    117. }
    118. ],
    119. "distance" : 1
    120. },
    121. {
    122. "vertices" : [
    123. "frenchCity/Paris",
    124. "germanCity/Hamburg"
    125. ],
    126. "edges" : [
    127. {
    128. "_key" : "78379",
    129. "_id" : "internationalHighway/78379",
    130. "_from" : "germanCity/Hamburg",
    131. "_to" : "frenchCity/Paris",
    132. "_rev" : "_Z2KDRS---A",
    133. "distance" : 900
    134. }
    135. ],
    136. "distance" : 1
    137. },
    138. {
    139. "vertices" : [
    140. "germanCity/Berlin",
    141. "frenchCity/Lyon"
    142. ],
    143. "edges" : [
    144. {
    145. "_key" : "78375",
    146. "_id" : "internationalHighway/78375",
    147. "_from" : "germanCity/Berlin",
    148. "_to" : "frenchCity/Lyon",
    149. "_rev" : "_Z2KDRR6--A",
    150. "distance" : 1100
    151. }
    152. ],
    153. "distance" : 1
    154. },
    155. {
    156. "vertices" : [
    157. "germanCity/Berlin",
    158. "frenchCity/Paris"
    159. ],
    160. "edges" : [
    161. {
    162. "_key" : "78377",
    163. "_id" : "internationalHighway/78377",
    164. "_from" : "germanCity/Berlin",
    165. "_to" : "frenchCity/Paris",
    166. "_rev" : "_Z2KDRS----",
    167. "distance" : 1200
    168. }
    169. ],
    170. "distance" : 1
    171. },
    172. {
    173. "vertices" : [
    174. "germanCity/Berlin",
    175. "germanCity/Cologne"
    176. ],
    177. "edges" : [
    178. {
    179. "_key" : "78367",
    180. "_id" : "germanHighway/78367",
    181. "_from" : "germanCity/Berlin",
    182. "_to" : "germanCity/Cologne",
    183. "_rev" : "_Z2KDRRy--_",
    184. "distance" : 850
    185. }
    186. ],
    187. "distance" : 1
    188. },
    189. {
    190. "vertices" : [
    191. "germanCity/Berlin",
    192. "germanCity/Hamburg"
    193. ],
    194. "edges" : [
    195. {
    196. "_key" : "78369",
    197. "_id" : "germanHighway/78369",
    198. "_from" : "germanCity/Berlin",
    199. "_to" : "germanCity/Hamburg",
    200. "_rev" : "_Z2KDRR2---",
    201. "distance" : 400
    202. }
    203. ],
    204. "distance" : 1
    205. },
    206. {
    207. "vertices" : [
    208. "germanCity/Cologne",
    209. "frenchCity/Lyon"
    210. ],
    211. "edges" : [
    212. {
    213. "_key" : "78383",
    214. "_id" : "internationalHighway/78383",
    215. "_from" : "germanCity/Cologne",
    216. "_to" : "frenchCity/Lyon",
    217. "_rev" : "_Z2KDRSC--A",
    218. "distance" : 700
    219. }
    220. ],
    221. "distance" : 1
    222. },
    223. {
    224. "vertices" : [
    225. "germanCity/Cologne",
    226. ],
    227. "edges" : [
    228. {
    229. "_key" : "78385",
    230. "_id" : "internationalHighway/78385",
    231. "_from" : "germanCity/Cologne",
    232. "_to" : "frenchCity/Paris",
    233. "_rev" : "_Z2KDRSG---",
    234. "distance" : 550
    235. }
    236. ],
    237. "distance" : 1
    238. },
    239. {
    240. "vertices" : [
    241. "germanCity/Cologne",
    242. "germanCity/Berlin"
    243. ],
    244. "edges" : [
    245. {
    246. "_key" : "78367",
    247. "_id" : "germanHighway/78367",
    248. "_from" : "germanCity/Berlin",
    249. "_to" : "germanCity/Cologne",
    250. "_rev" : "_Z2KDRRy--_",
    251. "distance" : 850
    252. }
    253. ],
    254. "distance" : 1
    255. },
    256. {
    257. "vertices" : [
    258. "germanCity/Cologne",
    259. "germanCity/Hamburg"
    260. ],
    261. "edges" : [
    262. {
    263. "_key" : "78371",
    264. "_id" : "germanHighway/78371",
    265. "_from" : "germanCity/Hamburg",
    266. "_to" : "germanCity/Cologne",
    267. "_rev" : "_Z2KDRR2--A",
    268. "distance" : 500
    269. }
    270. ],
    271. "distance" : 1
    272. },
    273. {
    274. "vertices" : [
    275. "germanCity/Hamburg",
    276. "frenchCity/Lyon"
    277. ],
    278. "edges" : [
    279. {
    280. "_key" : "78381",
    281. "_id" : "internationalHighway/78381",
    282. "_from" : "germanCity/Hamburg",
    283. "_to" : "frenchCity/Lyon",
    284. "_rev" : "_Z2KDRSC---",
    285. "distance" : 1300
    286. }
    287. ],
    288. "distance" : 1
    289. },
    290. {
    291. "vertices" : [
    292. "germanCity/Hamburg",
    293. "frenchCity/Paris"
    294. ],
    295. "edges" : [
    296. {
    297. "_key" : "78379",
    298. "_id" : "internationalHighway/78379",
    299. "_from" : "germanCity/Hamburg",
    300. "_to" : "frenchCity/Paris",
    301. "_rev" : "_Z2KDRS---A",
    302. "distance" : 900
    303. }
    304. ],
    305. "distance" : 1
    306. },
    307. {
    308. "vertices" : [
    309. "germanCity/Hamburg",
    310. "germanCity/Berlin"
    311. ],
    312. "edges" : [
    313. {
    314. "_key" : "78369",
    315. "_id" : "germanHighway/78369",
    316. "_from" : "germanCity/Berlin",
    317. "_to" : "germanCity/Hamburg",
    318. "_rev" : "_Z2KDRR2---",
    319. "distance" : 400
    320. }
    321. ],
    322. "distance" : 1
    323. },
    324. {
    325. "vertices" : [
    326. "germanCity/Hamburg",
    327. "germanCity/Cologne"
    328. ],
    329. "edges" : [
    330. {
    331. "_key" : "78371",
    332. "_id" : "germanHighway/78371",
    333. "_from" : "germanCity/Hamburg",
    334. "_to" : "germanCity/Cologne",
    335. "_rev" : "_Z2KDRR2--A",
    336. "distance" : 500
    337. }
    338. ],
    339. "distance" : 1
    340. }
    341. ]

    A route planner example, shortest path from Hamburg and Cologne to Lyon:

    1. arangosh> var examples = require("@arangodb/graph-examples/example-graph.js");
    2. arangosh> var g = examples.loadGraph("routeplanner");
    3. arangosh> g._shortestPath([{_id: 'germanCity/Cologne'},{_id: 'germanCity/Munich'}], 'frenchCity/Lyon',
    4. ........> {weight : 'distance'});

    Show execution results

    Hide execution results

    1. [
    2. {
    3. "vertices" : [
    4. "germanCity/Cologne",
    5. "frenchCity/Lyon"
    6. ],
    7. "edges" : [
    8. {
    9. "_key" : "78459",
    10. "_id" : "internationalHighway/78459",
    11. "_from" : "germanCity/Cologne",
    12. "_to" : "frenchCity/Lyon",
    13. "_rev" : "_Z2KDRUW---",
    14. "distance" : 700
    15. }
    16. ],
    17. "distance" : 1
    18. }
    19. ]

    _distanceTo

    The _distanceTo function returns all paths and there distance within a graph.

    graph._distanceTo(startVertexExample, endVertexExample, options)

    This function is a wrapper of graph._shortestPath.It does not return the actual path but only the distance between two vertices.

    Examples

    A route planner example, shortest distance from all german to all french cities:

    1. arangosh> var examples = require("@arangodb/graph-examples/example-graph.js");
    2. arangosh> var g = examples.loadGraph("routeplanner");
    3. arangosh> g._distanceTo({}, {}, {weight : 'distance', endVertexCollectionRestriction : 'frenchCity',
    4. ........> startVertexCollectionRestriction : 'germanCity'});

    Show execution results

    Hide execution results

    1. [
    2. {
    3. "startVertex" : "frenchCity/Lyon",
    4. "vertex" : "frenchCity/Paris",
    5. "distance" : 1
    6. },
    7. {
    8. "startVertex" : "frenchCity/Lyon",
    9. "vertex" : "germanCity/Berlin",
    10. "distance" : 1
    11. },
    12. {
    13. "startVertex" : "frenchCity/Lyon",
    14. "vertex" : "germanCity/Cologne",
    15. "distance" : 1
    16. },
    17. {
    18. "startVertex" : "frenchCity/Lyon",
    19. "vertex" : "germanCity/Hamburg",
    20. "distance" : 1
    21. },
    22. {
    23. "startVertex" : "frenchCity/Paris",
    24. "vertex" : "frenchCity/Lyon",
    25. "distance" : 1
    26. },
    27. {
    28. "startVertex" : "frenchCity/Paris",
    29. "vertex" : "germanCity/Berlin",
    30. "distance" : 1
    31. },
    32. {
    33. "startVertex" : "frenchCity/Paris",
    34. "vertex" : "germanCity/Cologne",
    35. "distance" : 1
    36. },
    37. {
    38. "startVertex" : "frenchCity/Paris",
    39. "vertex" : "germanCity/Hamburg",
    40. "distance" : 1
    41. },
    42. {
    43. "startVertex" : "germanCity/Berlin",
    44. "vertex" : "frenchCity/Lyon",
    45. "distance" : 1
    46. },
    47. {
    48. "startVertex" : "germanCity/Berlin",
    49. "vertex" : "frenchCity/Paris",
    50. "distance" : 1
    51. },
    52. {
    53. "startVertex" : "germanCity/Berlin",
    54. "vertex" : "germanCity/Cologne",
    55. "distance" : 1
    56. },
    57. {
    58. "startVertex" : "germanCity/Berlin",
    59. "vertex" : "germanCity/Hamburg",
    60. "distance" : 1
    61. },
    62. {
    63. "startVertex" : "germanCity/Cologne",
    64. "vertex" : "frenchCity/Lyon",
    65. "distance" : 1
    66. },
    67. {
    68. "startVertex" : "germanCity/Cologne",
    69. "vertex" : "frenchCity/Paris",
    70. "distance" : 1
    71. },
    72. {
    73. "startVertex" : "germanCity/Cologne",
    74. "vertex" : "germanCity/Berlin",
    75. "distance" : 1
    76. },
    77. {
    78. "startVertex" : "germanCity/Cologne",
    79. "vertex" : "germanCity/Hamburg",
    80. "distance" : 1
    81. },
    82. {
    83. "startVertex" : "germanCity/Hamburg",
    84. "vertex" : "frenchCity/Lyon",
    85. "distance" : 1
    86. },
    87. {
    88. "startVertex" : "germanCity/Hamburg",
    89. "vertex" : "frenchCity/Paris",
    90. "distance" : 1
    91. },
    92. {
    93. "startVertex" : "germanCity/Hamburg",
    94. "vertex" : "germanCity/Berlin",
    95. "distance" : 1
    96. },
    97. {
    98. "startVertex" : "germanCity/Hamburg",
    99. "vertex" : "germanCity/Cologne",
    100. "distance" : 1
    101. }
    102. ]

    A route planner example, shortest distance from Hamburg and Cologne to Lyon:

    1. arangosh> var examples = require("@arangodb/graph-examples/example-graph.js");
    2. arangosh> var g = examples.loadGraph("routeplanner");
    3. arangosh> g._distanceTo([{_id: 'germanCity/Cologne'},{_id: 'germanCity/Munich'}], 'frenchCity/Lyon',
    4. ........> {weight : 'distance'});

    Show execution results

    Hide execution results

    1. [
    2. {
    3. "startVertex" : "germanCity/Cologne",
    4. "vertex" : "frenchCity/Lyon",
    5. "distance" : 1
    6. }
    7. ]

    _absoluteEccentricity

    Get theof the vertices defined by the examples.

    The function accepts an id, an example, a list of examples or even an emptyexample as parameter for vertexExample.

    Parameters

    • vertexExample (optional) Filter the vertices, see Definition of examples
    • options (optional) An object defining further options. Can have the following values:
      • direction: The direction of the edges. Possible values are outbound, inbound and any (default).
      • edgeCollectionRestriction : One or a list of edge-collection names that should beconsidered to be on the path.
      • startVertexCollectionRestriction : One or a list of vertex-collection names that should beconsidered for source vertices.
      • endVertexCollectionRestriction : One or a list of vertex-collection names that should beconsidered for target vertices.
      • weight: The name of the attribute of the edges containing the weight.
      • defaultWeight: Only used with the option weight.If an edge does not have the attribute named as defined in option weight this defaultis used as weight.If no default is supplied the default would be positive infinity so the path andhence the eccentricity can not be calculated.

    Examples

    A route planner example, the absolute eccentricity of all locations.

    1. arangosh> var examples = require("@arangodb/graph-examples/example-graph.js");
    2. arangosh> var graph = examples.loadGraph("routeplanner");
    3. arangosh> graph._absoluteEccentricity({});

    Show execution results

    Hide execution results

    1. {
    2. "frenchCity/Lyon" : 1,
    3. "frenchCity/Paris" : 1,
    4. "germanCity/Berlin" : 1,
    5. "germanCity/Cologne" : 1,
    6. "germanCity/Hamburg" : 1
    7. }

    A route planner example, the absolute eccentricity of all locations.This considers the actual distances.

    1. arangosh> var examples = require("@arangodb/graph-examples/example-graph.js");
    2. arangosh> var graph = examples.loadGraph("routeplanner");
    3. arangosh> graph._absoluteEccentricity({}, {weight : 'distance'});

    Show execution results

    Hide execution results

    1. {
    2. "frenchCity/Lyon" : 1,
    3. "frenchCity/Paris" : 1,
    4. "germanCity/Berlin" : 1,
    5. "germanCity/Cologne" : 1,
    6. "germanCity/Hamburg" : 1
    7. }

    A route planner example, the absolute eccentricity of all cities regarding onlyoutbound paths.

    1. arangosh> var examples = require("@arangodb/graph-examples/example-graph.js");
    2. arangosh> var graph = examples.loadGraph("routeplanner");
    3. arangosh> graph._absoluteEccentricity({}, {startVertexCollectionRestriction : 'germanCity',
    4. ........> direction : 'outbound', weight : 'distance'});

    Show execution results

    Hide execution results

    1. {
    2. "frenchCity/Lyon" : 0,
    3. "frenchCity/Paris" : 1,
    4. "germanCity/Berlin" : 1,
    5. "germanCity/Cologne" : 1,
    6. "germanCity/Hamburg" : 1
    7. }

    _eccentricity

    Get the normalizedof the vertices defined by the examples.

    graph._eccentricity(vertexExample, options)

    Similar to _absoluteEccentricity but returns a normalized result.

    Examples

    A route planner example, the eccentricity of all locations.

    1. arangosh> var examples = require("@arangodb/graph-examples/example-graph.js");
    2. arangosh> var graph = examples.loadGraph("routeplanner");
    3. arangosh> graph._eccentricity();

    Show execution results

    Hide execution results

    1. {
    2. "frenchCity/Lyon" : 1,
    3. "frenchCity/Paris" : 1,
    4. "germanCity/Berlin" : 1,
    5. "germanCity/Cologne" : 1,
    6. "germanCity/Hamburg" : 1
    7. }

    A route planner example, the weighted eccentricity.

    1. arangosh> var examples = require("@arangodb/graph-examples/example-graph.js");
    2. arangosh> var graph = examples.loadGraph("routeplanner");
    3. arangosh> graph._eccentricity({weight : 'distance'});

    Show execution results

    Hide execution results

    1. {
    2. "frenchCity/Lyon" : 1,
    3. "frenchCity/Paris" : 1,
    4. "germanCity/Berlin" : 1,
    5. "germanCity/Cologne" : 1,
    6. "germanCity/Hamburg" : 1
    7. }

    Get theof the vertices defined by the examples.

    graph._absoluteCloseness(vertexExample, options)

    The function accepts an id, an example, a list of examples or even an emptyexample as parameter for vertexExample.

    Parameters

    • vertexExample (optional) Filter the vertices, see Definition of examples
    • options (optional) An object defining further options. Can have the following values:
      • direction: The direction of the edges. Possible values are outbound, inbound and any (default).
      • edgeCollectionRestriction : One or a list of edge-collection names that should beconsidered to be on the path.
      • startVertexCollectionRestriction : One or a list of vertex-collection names that should beconsidered for source vertices.
      • endVertexCollectionRestriction : One or a list of vertex-collection names that should beconsidered for target vertices.
      • weight: The name of the attribute of the edges containing the weight.
      • defaultWeight: Only used with the option weight.If an edge does not have the attribute named as defined in option weight this defaultis used as weight.If no default is supplied the default would be positive infinity so the path andhence the closeness can not be calculated.

    Examples

    A route planner example, the absolute closeness of all locations.

    1. arangosh> var examples = require("@arangodb/graph-examples/example-graph.js");
    2. arangosh> var graph = examples.loadGraph("routeplanner");
    3. arangosh> graph._absoluteCloseness({});

    Show execution results

    Hide execution results

    1. {
    2. "frenchCity/Lyon" : 4,
    3. "frenchCity/Paris" : 4,
    4. "germanCity/Berlin" : 4,
    5. "germanCity/Cologne" : 4,
    6. "germanCity/Hamburg" : 4
    7. }

    A route planner example, the absolute closeness of all locations.This considers the actual distances.

    1. arangosh> var examples = require("@arangodb/graph-examples/example-graph.js");
    2. arangosh> var graph = examples.loadGraph("routeplanner");
    3. arangosh> graph._absoluteCloseness({}, {weight : 'distance'});

    Hide execution results

    1. {
    2. "frenchCity/Lyon" : 4,
    3. "frenchCity/Paris" : 4,
    4. "germanCity/Berlin" : 4,
    5. "germanCity/Cologne" : 4,
    6. "germanCity/Hamburg" : 4
    7. }

    A route planner example, the absolute closeness of all German Cities regarding onlyoutbound paths.

    1. arangosh> var examples = require("@arangodb/graph-examples/example-graph.js");
    2. arangosh> var graph = examples.loadGraph("routeplanner");
    3. arangosh> graph._absoluteCloseness({}, {startVertexCollectionRestriction : 'germanCity',
    4. ........> direction : 'outbound', weight : 'distance'});

    Show execution results

    Hide execution results

    1. {
    2. "frenchCity/Lyon" : 0,
    3. "frenchCity/Paris" : 1,
    4. "germanCity/Berlin" : 4,
    5. "germanCity/Cologne" : 2,
    6. "germanCity/Hamburg" : 3
    7. }

    _closeness

    Get the normalizedof graphs vertices.

    graph._closeness(options)

    Similar to _absoluteCloseness but returns a normalized value.

    Examples

    A route planner example, the normalized closeness of all locations.

    1. arangosh> var examples = require("@arangodb/graph-examples/example-graph.js");
    2. arangosh> var graph = examples.loadGraph("routeplanner");
    3. arangosh> graph._closeness();

    Show execution results

    Hide execution results

    1. {
    2. "frenchCity/Lyon" : 1,
    3. "frenchCity/Paris" : 1,
    4. "germanCity/Berlin" : 1,
    5. "germanCity/Cologne" : 1,
    6. "germanCity/Hamburg" : 1
    7. }

    A route planner example, the closeness of all locations.This considers the actual distances.

    Show execution results

    Hide execution results

    1. {
    2. "frenchCity/Lyon" : 1,
    3. "frenchCity/Paris" : 1,
    4. "germanCity/Berlin" : 1,
    5. "germanCity/Cologne" : 1,
    6. "germanCity/Hamburg" : 1
    7. }

    A route planner example, the closeness of all cities regarding onlyoutbound paths.

    1. arangosh> var examples = require("@arangodb/graph-examples/example-graph.js");
    2. arangosh> var graph = examples.loadGraph("routeplanner");
    3. arangosh> graph._closeness({direction : 'outbound', weight : 'distance'});

    Show execution results

    Hide execution results

    1. {
    2. "frenchCity/Lyon" : 0,
    3. "frenchCity/Paris" : 1,
    4. "germanCity/Berlin" : 0.25,
    5. "germanCity/Cologne" : 0.5,
    6. "germanCity/Hamburg" : 0.3333333333333333
    7. }

    _absoluteBetweenness

    Get theof all vertices in the graph.

    graph._absoluteBetweenness(vertexExample, options)

    Parameters

    • vertexExample (optional) Filter the vertices, see Definition of examples
    • options (optional) An object defining further options. Can have the following values:
      • direction: The direction of the edges. Possible values are outbound, inbound and any (default).
      • weight: The name of the attribute of the edges containing the weight.
      • defaultWeight: Only used with the option weight.If an edge does not have the attribute named as defined in option weight this defaultis used as weight.If no default is supplied the default would be positive infinity so the path andhence the betweenness can not be calculated.

    Examples

    A route planner example, the absolute betweenness of all locations.

    1. arangosh> var examples = require("@arangodb/graph-examples/example-graph.js");
    2. arangosh> var graph = examples.loadGraph("routeplanner");
    3. arangosh> graph._absoluteBetweenness({});

    Show execution results

    Hide execution results

    1. {
    2. "frenchCity/Lyon" : 0,
    3. "frenchCity/Paris" : 0,
    4. "germanCity/Berlin" : 0,
    5. "germanCity/Cologne" : 0,
    6. "germanCity/Hamburg" : 0
    7. }

    A route planner example, the absolute betweenness of all locations.This considers the actual distances.

    1. arangosh> var examples = require("@arangodb/graph-examples/example-graph.js");
    2. arangosh> var graph = examples.loadGraph("routeplanner");
    3. arangosh> graph._absoluteBetweenness({weight : 'distance'});

    Show execution results

    Hide execution results

    1. {
    2. }

    A route planner example, the absolute betweenness of all cities regarding onlyoutbound paths.

    1. arangosh> var examples = require("@arangodb/graph-examples/example-graph.js");
    2. arangosh> var graph = examples.loadGraph("routeplanner");
    3. arangosh> graph._absoluteBetweenness({direction : 'outbound', weight : 'distance'});

    Show execution results

    Hide execution results

    1. {
    2. }

    _betweenness

    Get the normalizedof graphs vertices.

    Similar to _absoluteBetweenness but returns normalized values.

    Examples

    A route planner example, the betweenness of all locations.

    1. arangosh> var examples = require("@arangodb/graph-examples/example-graph.js");
    2. arangosh> var graph = examples.loadGraph("routeplanner");
    3. arangosh> graph._betweenness();

    Show execution results

    Hide execution results

    1. {
    2. "frenchCity/Lyon" : 0,
    3. "frenchCity/Paris" : 0,
    4. "germanCity/Berlin" : 0,
    5. "germanCity/Cologne" : 0,
    6. "germanCity/Hamburg" : 0
    7. }

    A route planner example, the betweenness of all locations.This considers the actual distances.

    1. arangosh> var examples = require("@arangodb/graph-examples/example-graph.js");
    2. arangosh> var graph = examples.loadGraph("routeplanner");
    3. arangosh> graph._betweenness({weight : 'distance'});

    Show execution results

    Hide execution results

    1. {
    2. "frenchCity/Lyon" : 0,
    3. "frenchCity/Paris" : 0,
    4. "germanCity/Berlin" : 0,
    5. "germanCity/Cologne" : 0,
    6. "germanCity/Hamburg" : 0
    7. }

    A route planner example, the betweenness of all cities regarding onlyoutbound paths.

    1. arangosh> var examples = require("@arangodb/graph-examples/example-graph.js");
    2. arangosh> var graph = examples.loadGraph("routeplanner");
    3. arangosh> graph._betweenness({direction : 'outbound', weight : 'distance'});

    Show execution results

    Hide execution results

    1. {
    2. "frenchCity/Lyon" : 0,
    3. "frenchCity/Paris" : 0,
    4. "germanCity/Berlin" : 0,
    5. "germanCity/Cologne" : 0,
    6. "germanCity/Hamburg" : 0
    7. }

    _radius

    Get theof a graph.

    `

    Parameters

    • options (optional) An object defining further options. Can have the following values:
      • direction: The direction of the edges. Possible values are outbound, inbound and any (default).
      • weight: The name of the attribute of the edges containing the weight.
      • defaultWeight: Only used with the option weight.If an edge does not have the attribute named as defined in option weight this defaultis used as weight.If no default is supplied the default would be positive infinity so the path andhence the radius can not be calculated.

    Examples

    A route planner example, the radius of the graph.

    1. arangosh> var examples = require("@arangodb/graph-examples/example-graph.js");
    2. arangosh> var graph = examples.loadGraph("routeplanner");
    3. arangosh> graph._radius();

    Show execution results

    Hide execution results

    1. 1

    A route planner example, the radius of the graph.This considers the actual distances.

    1. arangosh> var examples = require("@arangodb/graph-examples/example-graph.js");
    2. arangosh> var graph = examples.loadGraph("routeplanner");
    3. arangosh> graph._radius({weight : 'distance'});

    Show execution results

    Hide execution results

    1. 1

    A route planner example, the radius of the graph regarding onlyoutbound paths.

    1. arangosh> var examples = require("@arangodb/graph-examples/example-graph.js");
    2. arangosh> var graph = examples.loadGraph("routeplanner");
    3. arangosh> graph._radius({direction : 'outbound', weight : 'distance'});

    Show execution results

    Hide execution results

    1. 1

    _diameter

    Get thediameterof a graph.

    graph._diameter(graphName, options)

    Parameters

    • options (optional) An object defining further options. Can have the following values:
      • direction: The direction of the edges. Possible values are outbound, inbound and any (default).
      • weight: The name of the attribute of the edges containing the weight.
      • defaultWeight: Only used with the option weight.If an edge does not have the attribute named as defined in option weight this defaultis used as weight.If no default is supplied the default would be positive infinity so the path andhence the radius can not be calculated.

    Examples

    A route planner example, the diameter of the graph.

    1. arangosh> var examples = require("@arangodb/graph-examples/example-graph.js");
    2. arangosh> var graph = examples.loadGraph("routeplanner");
    3. arangosh> graph._diameter();

    Show execution results

    Hide execution results

    1. 1

    A route planner example, the diameter of the graph.This considers the actual distances.

    1. arangosh> var examples = require("@arangodb/graph-examples/example-graph.js");
    2. arangosh> var graph = examples.loadGraph("routeplanner");
    3. arangosh> graph._diameter({weight : 'distance'});

    Show execution results

    Hide execution results

    1. 1

    A route planner example, the diameter of the graph regarding onlyoutbound paths.

    1. arangosh> var examples = require("@arangodb/graph-examples/example-graph.js");
    2. arangosh> var graph = examples.loadGraph("routeplanner");
    3. arangosh> graph._diameter({direction : 'outbound', weight : 'distance'});

    Show execution results

    Hide execution results