Skip to content

Commit

Permalink
Transition from LightGraphs to Graphs
Browse files Browse the repository at this point in the history
  • Loading branch information
Mal Miller authored and captchanjack committed Nov 11, 2021
1 parent 6631bdf commit 4b2d85d
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
12 changes: 6 additions & 6 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
name = "LightOSM"
uuid = "d1922b25-af4e-4ba3-84af-fe9bea896051"
authors = ["Jack Chan <[email protected]>"]
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"
Expand All @@ -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"
8 changes: 4 additions & 4 deletions benchmark/benchmarks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ using Random
using BenchmarkTools
using LightOSM
using OpenStreetMapX
using LightGraphs
using Graphs
using DataStructures
using JSON

Expand Down Expand Up @@ -59,16 +59,16 @@ 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
end
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
Expand Down
2 changes: 1 addition & 1 deletion src/LightOSM.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/graph.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/traversal.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

2 comments on commit 4b2d85d

@captchanjack
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/48600

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.1.19 -m "<description of version>" 4b2d85db8554d3d1dc43278fea6aa9a77cc852ea
git push origin v0.1.19

Please sign in to comment.