Skip to content

Commit 6042bcd

Browse files
nhz2etiennedeg
andauthored
Update Shortest paths docs (#118)
* Shortest paths docs * Update docs/src/first_steps/paths_traversal.md Co-authored-by: Etienne dg <[email protected]> * dijkstra docs update Co-authored-by: Etienne dg <[email protected]>
1 parent 9650d3d commit 6042bcd

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

docs/src/first_steps/paths_traversal.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,13 @@ The package also includes uniform random walks and self avoiding walks with the
3131
The following properties always hold for shortest path algorithms implemented here:
3232

3333
- The distance from a vertex to itself is always `0`.
34-
- The distance between two vertices with no connecting edge is always `Inf`.
34+
- The distance between two vertices with no connecting edge is always `Inf` or `typemax(eltype(distmx))`.
3535

36-
The `dijkstra_shortest_paths`, `desopo_pape_shortest_paths`, `floyd_warshall_shortest_paths`, `bellman_ford_shortest_paths`, and `yen_shortest_paths` functions return path states (subtypes of `Graphs.AbstractPathState`) that contain various information about the graph learned during traversal.
36+
The [`dijkstra_shortest_paths`](@ref), [`desopo_pape_shortest_paths`](@ref), [`floyd_warshall_shortest_paths`](@ref), [`bellman_ford_shortest_paths`](@ref), and [`yen_k_shortest_paths`](@ref) functions return path states (subtypes of `Graphs.AbstractPathState`) that contain various information about the graph learned during traversal.
3737

3838
The corresponding state types (with the exception of `YenState`) have the following common fields:
3939

4040
- `state.dists` holds a vector with the distances computed, indexed by source vertex.
4141
- `state.parents` holds a vector of parents of each vertex on the shortest paths (the parent of a source vertex is always `0`). `YenState` substitutes `.paths` for `.parents`.
4242

43-
In addition, the following information may be populated with the appropriate arguments to `dijkstra_shortest_paths`:
44-
45-
- `state.predecessors` holds a vector, indexed by vertex, of all the predecessors discovered during shortest-path calculations. This keeps track of all parents when there are multiple shortest paths available from the source.
46-
- `state.pathcounts` holds a vector, indexed by vertex, of the path counts discovered during traversal. This equals the length of each subvector in the `state.predecessors` output above.
43+
In addition, with the appropriate optional arguments, [`dijkstra_shortest_paths`](@ref) will return information on all possible shortest paths available from the source.

src/shortestpaths/dijkstra.jl

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,20 @@ Perform [Dijkstra's algorithm](http://en.wikipedia.org/wiki/Dijkstra%27s_algorit
1818
on a graph, computing shortest distances between `srcs` and all other vertices.
1919
Return a [`Graphs.DijkstraState`](@ref) that contains various traversal information.
2020
21+
2122
### Optional Arguments
22-
- `allpaths=false`: If true, returns a [`Graphs.DijkstraState`](@ref) that keeps track of all
23-
predecessors of a given vertex.
23+
* `allpaths=false`: If true,
24+
25+
`state.predecessors` holds a vector, indexed by vertex,
26+
of all the predecessors discovered during shortest-path calculations.
27+
This keeps track of all parents when there are multiple shortest paths available from the source.
28+
29+
`state.pathcounts` holds a vector, indexed by vertex, of the number of shortest paths from the source to that vertex.
30+
The path count of a source vertex is always `1.0`. The path count of an unreached vertex is always `0.0`.
31+
32+
* `trackvertices=false`: If true,
33+
34+
`state.closest_vertices` holds a vector of all vertices in the graph ordered from closest to farthest.
2435
2536
### Performance
2637
If using a sparse matrix for `distmx`, you *may* achieve better performance by passing in a transpose of its sparse transpose.

0 commit comments

Comments
 (0)