Skip to content

Commit

Permalink
Update dijkstra.jl (sbromberger#1120)
Browse files Browse the repository at this point in the history
* Update dijkstra.jl

Clarify performance tip

* Update dijkstra.jl

per @jpfairbanks, change "creating" to "realizing".
  • Loading branch information
sbromberger authored Jan 26, 2019
1 parent fbc6db0 commit 3f71acd
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/shortestpaths/dijkstra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,13 @@ Return a [`LightGraphs.DijkstraState`](@ref) that contains various traversal inf
predecessors of a given vertex.
### Performance
Use a matrix type for `distmx` that is implemented in [row-major matrix format](https://en.wikipedia.org/wiki/Row-_and_column-major_order)
for better run-time.
Eg. Set the type of `distmx` to `Transpose{Int64, SparseMatrixCSC{Int64,Int64}}`
instead of `SparseMatrixCSC{Int64,Int64}`.
If using a sparse matrix for `distmx`, you *may* achieve better performance by passing in a transpose of its sparse transpose.
That is, assuming `D` is the sparse distance matrix:
```
D = transpose(sparse(transpose(D)))
```
Be aware that realizing the sparse transpose of `D` incurs a heavy one-time penalty, so this strategy should only be used
when multiple calls to `dijkstra_shortest_paths` with the distance matrix are planned.
# Examples
```jldoctest
Expand Down

0 comments on commit 3f71acd

Please sign in to comment.