diff --git a/Project.toml b/Project.toml index 9492a04..1825216 100644 --- a/Project.toml +++ b/Project.toml @@ -1,13 +1,13 @@ name = "LightOSM" uuid = "d1922b25-af4e-4ba3-84af-fe9bea896051" authors = ["Jack Chan "] -version = "0.1.18" +version = "0.1.19" [deps] DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8" +Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6" HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3" JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" -LightGraphs = "093fc24a-ae57-5d10-9952-331d41423f4d" LightXML = "9c8b4983-aa76-5018-a973-4c85ecc9e179" MetaGraphs = "626554b9-1ddb-594c-aa3c-2596fe9399a5" NearestNeighbors = "b8a86587-4115-5ab1-83bc-aa920d37bbce" @@ -19,13 +19,13 @@ Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" [compat] DataStructures = "0.17.20, 0.18" +Graphs = "1.4.0" HTTP = "0.8.17, 0.9" JSON = "0.21.0" -LightGraphs = "1.3.3" LightXML = "0.9.0" -MetaGraphs = "0.6.5" +MetaGraphs = "0.7.0" NearestNeighbors = "0.4.6" Parameters = "0.12.1" -SimpleWeightedGraphs = "1.1.1" -StaticGraphs = "0.2.0" +SimpleWeightedGraphs = "1.2.0" +StaticGraphs = "0.3.0" julia = "1" diff --git a/benchmark/benchmarks.jl b/benchmark/benchmarks.jl index d2a1d25..6e6be44 100644 --- a/benchmark/benchmarks.jl +++ b/benchmark/benchmarks.jl @@ -2,7 +2,7 @@ using Random using BenchmarkTools using LightOSM using OpenStreetMapX -using LightGraphs +using Graphs using DataStructures using JSON @@ -59,7 +59,7 @@ function lg_shortest_path(g::LightOSM.OSMGraph, o_d_indices, algorithm) if algorithm == :astar for (o, d) in o_d_indices try - LightGraphs.a_star(g.graph, o, d, g.weights) + Graphs.a_star(g.graph, o, d, g.weights) catch # Error exception will be thrown if path does not exist from origin to destination node end @@ -67,8 +67,8 @@ function lg_shortest_path(g::LightOSM.OSMGraph, o_d_indices, algorithm) elseif algorithm == :dijkstra for (o, d) in o_d_indices try - state = LightGraphs.dijkstra_shortest_paths(g.graph, o, g.weights) - LightGraphs.enumerate_paths(state, d) + state = Graphs.dijkstra_shortest_paths(g.graph, o, g.weights) + Graphs.enumerate_paths(state, d) catch # Error exception will be thrown if path does not exist from origin to destination node end diff --git a/src/LightOSM.jl b/src/LightOSM.jl index 4752b07..3c9a37d 100644 --- a/src/LightOSM.jl +++ b/src/LightOSM.jl @@ -4,7 +4,7 @@ using Parameters using DataStructures: DefaultDict, OrderedDict, MutableLinkedList, PriorityQueue, dequeue!, dequeue_pair! using Statistics: mean using SparseArrays: SparseMatrixCSC, sparse -using LightGraphs: AbstractGraph, DiGraph, nv, outneighbors, weakly_connected_components, vertices +using Graphs: AbstractGraph, DiGraph, nv, outneighbors, weakly_connected_components, vertices using StaticGraphs: StaticDiGraph using SimpleWeightedGraphs: SimpleWeightedDiGraph using MetaGraphs: MetaDiGraph diff --git a/src/graph.jl b/src/graph.jl index e0f7efd..96467b0 100644 --- a/src/graph.jl +++ b/src/graph.jl @@ -13,7 +13,7 @@ Creates an `OSMGraph` object from download OpenStreetMap network data, use with - `osm_data_object::Symbol`: OpenStreetMap network data parsed as either XML or Dictionary object depending on the download method. - `network_type::Symbol=:drive`: Network type filter, pick from `:drive`, `:drive_service`, `:walk`, `:bike`, `:all`, `:all_private`, `:none`, `:rail`, must match the network type used to download `osm_data_object`. - `weight_type::Symbol=:time`: Weight type for graph edges, pick from `:distance` (km), `:time` (hours), `:lane_efficiency` (time scaled by number of lanes). -- `graph_type::Symbol=:static`: Type of `LightGraphs.AbstractGraph`, pick from `:static` (StaticDiGraph), `:light` (DiGraph), `:simple_weighted` (SimpleWeightedDiGraph), `:meta` (MetaDiGraph). +- `graph_type::Symbol=:static`: Type of `Graphs.AbstractGraph`, pick from `:static` (StaticDiGraph), `:light` (DiGraph), `:simple_weighted` (SimpleWeightedDiGraph), `:meta` (MetaDiGraph). - `precompute_dijkstra_states::Bool=false`: Set true to precompute dijkstra parent states for every source node in the graph, *NOTE* this may take a while and may not be possible for graphs with large amount of nodes due to memory limits. - `largest_connected_component::Bool=true`: Set true to keep only the largest connected components in the network. @@ -63,7 +63,7 @@ Creates an `OSMGraph` object from a downloaded OpenStreetMap network data file, - `file_path::String`: OpenStreetMap network data file location. - `network_type::Symbol=:drive`: Network type filter, pick from `:drive`, `:drive_service`, `:walk`, `:bike`, `:all`, `:all_private`, `:none`, `:rail`, must match the network type used to download `osm_data_object`. - `weight_type::Symbol=:time`: Weight type for graph edges, pick from `:distance` (km), `:time` (hours), `:lane_efficiency` (time scaled by number of lanes). -- `graph_type::Symbol=:static`: Type of `LightGraphs.AbstractGraph`, pick from `:static` (StaticDiGraph), `:light` (DiGraph), `:simple_weighted` (SimpleWeightedDiGraph), `:meta` (MetaDiGraph). +- `graph_type::Symbol=:static`: Type of `Graphs.AbstractGraph`, pick from `:static` (StaticDiGraph), `:light` (DiGraph), `:simple_weighted` (SimpleWeightedDiGraph), `:meta` (MetaDiGraph). - `precompute_dijkstra_states::Bool=false`: Set true to precompute dijkstra parent states for every source node in the graph, *NOTE* this may take a while and may not be possible for graphs with large amount of nodes due to memory limits. - `largest_connected_component::Bool=true`: Set true to keep only the largest connected components in the network. @@ -111,7 +111,7 @@ Downloads OpenStreetMap network data and creates an `OSMGraph` object. - `download_format::Symbol=:json`: Download format, either `:osm`, `:xml` or `json`. - `save_to_file_location::Union{String,Nothing}=nothing`: Specify a file location to save downloaded data to disk. - `weight_type::Symbol=:time`: Weight type for graph edges, pick from `:distance` (km), `:time` (hours), `:lane_efficiency` (time scaled by number of lanes). -- `graph_type::Symbol=:static`: Type of `LightGraphs.AbstractGraph`, pick from `:static` (StaticDiGraph), `:light` (DiGraph), `:simple_weighted` (SimpleWeightedDiGraph), `:meta` (MetaDiGraph). +- `graph_type::Symbol=:static`: Type of `Graphs.AbstractGraph`, pick from `:static` (StaticDiGraph), `:light` (DiGraph), `:simple_weighted` (SimpleWeightedDiGraph), `:meta` (MetaDiGraph). - `precompute_dijkstra_states::Bool=false`: Set true to precompute dijkstra parent states for every source node in the graph, *NOTE* this may take a while and may not be possible for graphs with large amount of nodes due to memory limits. - `largest_connected_component::Bool=true`: Set true to keep only the largest connected components in the network. @@ -360,7 +360,7 @@ function add_weights!(g::OSMGraph, weight_type::Symbol=:distance) end """ -Adds a LightGraphs.AbstractGraph object to `OSMGraph`. +Adds a Graphs.AbstractGraph object to `OSMGraph`. """ function add_graph!(g::OSMGraph, graph_type::Symbol=:static) if graph_type == :light diff --git a/src/traversal.jl b/src/traversal.jl index b9bec64..ccfcaca 100644 --- a/src/traversal.jl +++ b/src/traversal.jl @@ -7,12 +7,12 @@ heuristic::Function=h(u, v) = 0.0, )::Vector{U} where {T <: Real,U <: Integer,V <: Integer,W <: Integer} -A* shortest path algorithm taken and adapted from `LightGraphs.jl`. This version improves runtime +A* shortest path algorithm taken and adapted from `Graphs.jl`. This version improves runtime speed, memory usage, has a more flexible heruistic function, and accounts for OpenStreetMap turn restrictions. # Arguments -- `g::AbstractGraph{U}`: LightGraphs abstract graph object. +- `g::AbstractGraph{U}`: Graphs abstract graph object. - `src::W`: Source vertex. - `goal::Union{W,Nothing}=nothing`: Optional target vertex as a break condition. - `distmx::AbstractMatrix{T}=weights(g)`: Optional weight matrix.