Skip to content

Commit 81370ad

Browse files
Simran-Bnerpaula
andauthored
Improve lead paragraphs and text for AQL graph traversal and path search algorithms (#723)
* Improve lead paragraphs and text for AQL graph traversal and path search algorithms * fix typo --------- Co-authored-by: Paula <paula.mihu@arangodb.com>
1 parent eba08bb commit 81370ad

File tree

12 files changed

+231
-228
lines changed

12 files changed

+231
-228
lines changed

site/content/3.11/aql/graphs/all-shortest-paths.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: All Shortest Paths in AQL
33
menuTitle: All Shortest Paths
44
weight: 20
55
description: >-
6-
Find all paths of shortest length between a start and target vertex
6+
Find all paths of shortest length between two vertices
77
---
88
## General query idea
99

@@ -32,7 +32,7 @@ expected two shortest paths are:
3232
2. Carlisle – York – London
3333

3434
Another path that connects Carlisle and London is
35-
Carlisle – Glasgow – Edinburgh – York – London, but it is has two more stops and
35+
Carlisle – Glasgow – Edinburgh – York – London, but it has two more stops and
3636
is therefore not a path of the shortest length.
3737

3838
## Syntax
@@ -57,12 +57,12 @@ FOR path
5757
edges are followed (outgoing, incoming, or both)
5858
- `ALL_SHORTEST_PATHS`: The keyword to compute All Shortest Paths
5959
- **startVertex** `TO` **targetVertex** (both string\|object): The two vertices between
60-
which the paths will be computed. This can be specified in the form of
60+
which the paths are computed. This can be specified in the form of
6161
a ID string or in the form of a document with the attribute `_id`. All other
6262
values result in a warning and an empty result. If one of the specified
6363
documents does not exist, the result is empty as well and there is no warning.
6464
- `GRAPH` **graphName** (string): The name identifying the named graph. Its vertex and
65-
edge collections will be looked up.
65+
edge collections are looked up for the path search.
6666

6767
{{< info >}}
6868
All Shortest Paths traversals do not support edge weights.
@@ -96,7 +96,7 @@ FOR path IN OUTBOUND ALL_SHORTEST_PATHS
9696
edges1, ANY edges2, edges3
9797
```
9898

99-
All collections in the list that do not specify their own direction will use the
99+
All collections in the list that do not specify their own direction use the
100100
direction defined after `IN` (here: `OUTBOUND`). This allows using a different
101101
direction for each collection in your path search.
102102

site/content/3.11/aql/graphs/k-paths.md

Lines changed: 37 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,22 @@ title: k Paths in AQL
33
menuTitle: k Paths
44
weight: 30
55
description: >-
6-
Determine all paths between a start and end vertex limited specified path
7-
lengths
6+
Find all paths between two vertices with a fixed range of path lengths
87
---
98
## General query idea
109

11-
This type of query finds all paths between two given documents,
12-
*startVertex* and *targetVertex* in your graph. The paths are restricted
13-
by minimum and maximum length of the paths.
10+
This type of query finds all paths between two given documents
11+
(*startVertex* and *targetVertex*) in your graph. The paths are restricted
12+
by a minimum and maximum length that you specify.
1413

15-
Every such path will be returned as a JSON object with two components:
14+
Every such path is returned as a JSON object with two components:
1615

1716
- an array containing the `vertices` on the path
1817
- an array containing the `edges` on the path
1918

2019
**Example**
2120

22-
Let us take a look at a simple example to explain how it works.
23-
This is the graph that we are going to find some paths on:
21+
Here is an example graph to explain how the k Paths algorithm works:
2422

2523
![Train Connection Map](../../../images/train_map.png)
2624

@@ -30,9 +28,9 @@ between cities and are the edges of the graph. The numbers near the arrows
3028
describe how long it takes to get from one station to another. They are used
3129
as edge weights.
3230

33-
Let us assume that we want to go from **Aberdeen** to **London** by train.
31+
Assume that you want to go from **Aberdeen** to **London** by train.
3432

35-
Here we have a couple of alternatives:
33+
You have a couple of alternatives:
3634

3735
a) Straight way
3836

@@ -72,8 +70,9 @@ d) Detour at Edinburgh to York
7270
6. York
7371
7. London
7472

75-
Note that we only consider paths as valid that do not contain the same vertex
76-
twice. The following alternative would visit Aberdeen twice and will not be returned by k Paths:
73+
Note that only paths that do not contain the same vertex twice are consider to
74+
be valid. The following alternative would visit Aberdeen twice and is **not**
75+
returned by the k Paths algorithm:
7776

7877
1. Aberdeen
7978
2. **Inverness**
@@ -86,16 +85,16 @@ twice. The following alternative would visit Aberdeen twice and will not be retu
8685
## Example Use Cases
8786

8887
The use-cases for k Paths are about the same as for unweighted k Shortest Paths.
89-
The main difference is that k Shortest Paths will enumerate all paths with
90-
**increasing length**. It will stop as soon as a given limit is reached.
91-
k Paths will instead only enumerate **all paths** within a given range of
92-
path length, and are thereby upper-bounded.
88+
The main difference is that k Shortest Paths enumerates all paths with
89+
**increasing length**. It stops as soon as a given number of paths is reached.
90+
k Paths enumerates all paths within a given **range of path lengths** instead,
91+
and is thereby upper-bounded.
9392

9493
The k Paths traversal can be used as foundation for several other algorithms:
9594

9695
- **Transportation** of any kind (e.g. road traffic, network package routing)
97-
- **Flow problems**: We need to transfer items from A to B, which alternatives
98-
do we have? What is their capacity?
96+
- **Flow problems**: You need to transfer items from A to B, which alternatives
97+
do you have? What is their capacity?
9998

10099
## Syntax
101100

@@ -105,8 +104,8 @@ minimum and maximum length of the path.
105104

106105
{{< warning >}}
107106
It is highly recommended that you use a reasonable maximum path length or a
108-
**LIMIT** statement, as k Paths is a potentially expensive operation. On large
109-
connected graphs it can return a large number of paths.
107+
**LIMIT** statement, as k Paths is a potentially expensive operation. It can
108+
return a large number of paths for large connected graphs.
110109
{{< /warning >}}
111110

112111
### Working with named graphs
@@ -121,23 +120,23 @@ FOR path
121120
- `FOR`: Emits the variable **path** which contains one path as an object
122121
containing `vertices` and `edges` of the path.
123122
- `IN` `MIN..MAX`: The minimal and maximal depth for the traversal:
124-
- **min** (number, *optional*): Paths returned by this query will
125-
have at least a length of *min* many edges.
126-
If not specified, it defaults to 1. The minimal possible value is 0.
127-
- **max** (number, *optional*): Paths returned by this query will
128-
have at most a length of *max* many edges.
129-
If omitted, *max* defaults to *min*. Thus only the vertices and edges in
130-
the range of *min* are returned. *max* cannot be specified without *min*.
123+
- **min** (number, *optional*): Paths returned by this query
124+
have at least a length of this many edges.
125+
If not specified, it defaults to `1`. The minimal possible value is `0`.
126+
- **max** (number, *optional*): Paths returned by this query
127+
have at most a length of this many edges.
128+
If omitted, it defaults to the value of `min`. Thus, only the vertices and
129+
edges in the range of `min` are returned. You cannot specify `max` without `min`.
131130
- `OUTBOUND|INBOUND|ANY`: Defines in which direction
132-
edges are followed (outgoing, incoming, or both)
133-
- `K_PATHS`: The keyword to compute all Paths
131+
edges are followed (outgoing, incoming, or both).
132+
- `K_PATHS`: The keyword to compute all paths with the specified lengths.
134133
- **startVertex** `TO` **targetVertex** (both string\|object): The two vertices
135-
between which the paths will be computed. This can be specified in the form of
136-
a document identifier string or in the form of an object with the attribute
137-
`_id`. All other values will lead to a warning and an empty result. This is
134+
between which the paths are computed. This can be specified in the form of
135+
a document identifier string or in the form of an object with the `_id`
136+
attribute. All other values lead to a warning and an empty result. This is
138137
also the case if one of the specified documents does not exist.
139138
- `GRAPH` **graphName** (string): The name identifying the named graph.
140-
Its vertex and edge collections will be looked up.
139+
Its vertex and edge collections are looked up for the path search.
141140

142141
### Working with collection sets
143142

@@ -168,14 +167,14 @@ FOR vertex IN OUTBOUND K_PATHS
168167
edges1, ANY edges2, edges3
169168
```
170169

171-
All collections in the list that do not specify their own direction will use the
170+
All collections in the list that do not specify their own direction use the
172171
direction defined after `IN` (here: `OUTBOUND`). This allows to use a different
173172
direction for each collection in your path search.
174173

175174
## Examples
176175

177-
We load an example graph to get a named graph that reflects some possible
178-
train connections in Europe and North America.
176+
You can load the `kShortestPathsGraph` example graph to get a named graph that
177+
reflects some possible train connections in Europe and North America.
179178

180179
![Train Connection Map](../../../images/train_map.png)
181180

@@ -192,7 +191,7 @@ db.places.toArray();
192191
db.connections.toArray();
193192
```
194193

195-
Suppose we want to query all routes from **Aberdeen** to **London**.
194+
Suppose you want to query all routes from **Aberdeen** to **London**.
196195

197196
```aql
198197
---
@@ -205,7 +204,7 @@ GRAPH 'kShortestPathsGraph'
205204
RETURN { places: p.vertices[*].label, travelTimes: p.edges[*].travelTime }
206205
```
207206

208-
If we ask for routes that don't exist we get an empty result
207+
If you ask for routes that don't exist, you get an empty result
209208
(from **Aberdeen** to **Toronto**):
210209

211210
```aql

site/content/3.11/aql/graphs/k-shortest-paths.md

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,27 @@ title: k Shortest Paths in AQL
33
menuTitle: k Shortest Paths
44
weight: 25
55
description: >-
6-
Determine a specified number of shortest paths in increasing path length or
7-
weight order
6+
Find a number of shortest paths in the order of increasing path length or weight
87
---
98
## General query idea
109

1110
This type of query finds the first *k* paths in order of length
12-
(or weight) between two given documents, *startVertex* and *targetVertex* in
11+
(or weight) between two given documents (*startVertex* and *targetVertex*) in
1312
your graph.
1413

15-
Every such path will be returned as a JSON object with three components:
14+
Every such path is returned as a JSON object with three components:
1615

1716
- an array containing the `vertices` on the path
1817
- an array containing the `edges` on the path
1918
- the `weight` of the path, that is the sum of all edge weights
2019

21-
If no `weightAttribute` is given, the weight of the path is just its length.
20+
If no `weightAttribute` is specified, the weight of the path is just its length.
2221

2322
{{< youtube id="XdITulJFdVo" >}}
2423

2524
**Example**
2625

27-
Let us take a look at a simple example to explain how it works.
28-
This is the graph that we are going to find some shortest path on:
26+
Here is an example graph to explain how the k Shortest Paths algorithm works:
2927

3028
![Train Connection Map](../../../images/train_map.png)
3129

@@ -35,9 +33,9 @@ between cities and are the edges of the graph. The numbers near the arrows
3533
describe how long it takes to get from one station to another. They are used
3634
as edge weights.
3735

38-
Let us assume that we want to go from **Aberdeen** to **London** by train.
36+
Let us assume that you want to go from **Aberdeen** to **London** by train.
3937

40-
We expect to see the following vertices on *the* shortest path, in this order:
38+
You expect to see the following vertices on *the* shortest path, in this order:
4139

4240
1. Aberdeen
4341
2. Leuchars
@@ -47,7 +45,7 @@ We expect to see the following vertices on *the* shortest path, in this order:
4745

4846
By the way, the weight of the path is: 1.5 + 1.5 + 3.5 + 1.8 = **8.3**.
4947

50-
Let us look at alternative paths next, for example because we know that the
48+
Let us look at alternative paths next, for example because you know that the
5149
direct connection between York and London does not operate currently.
5250
An alternative path, which is slightly longer, goes like this:
5351

@@ -62,7 +60,7 @@ An alternative path, which is slightly longer, goes like this:
6260
Its weight is: 1.5 + 1.5 + 3.5 + 2.0 + 1.5 = **10.0**.
6361

6462
Another route goes via Glasgow. There are seven stations on the path as well,
65-
however, it is quicker if we compare the edge weights:
63+
however, it is quicker if you compare the edge weights:
6664

6765
1. Aberdeen
6866
2. Leuchars
@@ -102,15 +100,15 @@ FOR path
102100
- `FOR`: Emits the variable **path** which contains one path as an object containing
103101
`vertices`, `edges`, and the `weight` of the path.
104102
- `IN` `OUTBOUND|INBOUND|ANY`: Defines in which direction
105-
edges are followed (outgoing, incoming, or both)
103+
edges are followed (outgoing, incoming, or both).
106104
- `K_SHORTEST_PATHS`: The keyword to compute k Shortest Paths
107105
- **startVertex** `TO` **targetVertex** (both string\|object): The two vertices between
108-
which the paths will be computed. This can be specified in the form of
106+
which the paths are computed. This can be specified in the form of
109107
a ID string or in the form of a document with the attribute `_id`. All other
110-
values will lead to a warning and an empty result. If one of the specified
108+
values lead to a warning and an empty result. If one of the specified
111109
documents does not exist, the result is empty as well and there is no warning.
112110
- `GRAPH` **graphName** (string): The name identifying the named graph. Its vertex and
113-
edge collections will be looked up.
111+
edge collections are looked up by the path search.
114112
- `OPTIONS` **options** (object, *optional*):
115113
See the [path search options](#path-search-options).
116114
- `LIMIT` (see [LIMIT operation](../high-level-operations/limit.md), *optional*):
@@ -175,14 +173,14 @@ FOR vertex IN OUTBOUND K_SHORTEST_PATHS
175173
edges1, ANY edges2, edges3
176174
```
177175

178-
All collections in the list that do not specify their own direction will use the
176+
All collections in the list that do not specify their own direction use the
179177
direction defined after `IN` (here: `OUTBOUND`). This allows to use a different
180178
direction for each collection in your path search.
181179

182180
## Examples
183181

184-
We load an example graph to get a named graph that reflects some possible
185-
train connections in Europe and North America.
182+
You can load the `kShortestPathsGraph` example graph to get a named graph that
183+
reflects some possible train connections in Europe and North America.
186184

187185
![Train Connection Map](../../../images/train_map.png)
188186

@@ -199,7 +197,7 @@ db.places.toArray();
199197
db.connections.toArray();
200198
```
201199

202-
Suppose we want to query a route from **Aberdeen** to **London**, and
200+
Suppose you want to query a route from **Aberdeen** to **London**, and
203201
compare the outputs of `SHORTEST_PATH` and `K_SHORTEST_PATHS` with
204202
`LIMIT 1`. Note that while `SHORTEST_PATH` and `K_SHORTEST_PATH` with
205203
`LIMIT 1` should return a path of the same length (or weight), they do
@@ -232,7 +230,7 @@ GRAPH 'kShortestPathsGraph'
232230
RETURN { places: p.vertices[*].label, travelTimes: p.edges[*].travelTime }
233231
```
234232

235-
With `K_SHORTEST_PATHS` we can ask for more than one option for a route:
233+
With `K_SHORTEST_PATHS`, you can ask for more than one option for a route:
236234

237235
```aql
238236
---
@@ -250,7 +248,7 @@ GRAPH 'kShortestPathsGraph'
250248
}
251249
```
252250

253-
If we ask for routes that don't exist we get an empty result
251+
If you ask for routes that don't exist, you get an empty result
254252
(from **Aberdeen** to **Toronto**):
255253

256254
```aql
@@ -269,9 +267,9 @@ GRAPH 'kShortestPathsGraph'
269267
}
270268
```
271269

272-
We can use the attribute *travelTime* that connections have as edge weights to
270+
You can use the `travelTime` attribute that connections have as edge weights to
273271
take into account which connections are quicker. A high default weight is set,
274-
to be used if an edge has no *travelTime* attribute (not the case with the
272+
to be used if an edge has no `travelTime` attribute (not the case with the
275273
example graph). This returns the top three routes with the fewest changes
276274
and favoring the least travel time for the connection **Saint Andrews**
277275
to **Cologne**:

0 commit comments

Comments
 (0)