Skip to content

Commit 559fe35

Browse files
author
Vincent Landau
committed
LightGraphs => Graphs, some other minor changes to type names
1 parent b7457a4 commit 559fe35

15 files changed

+47
-45
lines changed

Project.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ version = "0.0.1"
55

66
[deps]
77
GeoData = "9b6fcbb8-86d6-11e9-1ce7-23a6bb139a78"
8-
LightGraphs = "093fc24a-ae57-5d10-9952-331d41423f4d"
8+
Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"
99
SimpleWeightedGraphs = "47aef6b3-ad0c-573a-a1e2-d07658019622"
1010
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
1111
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
1212

1313
[compat]
14+
GeoData = "0.5"
15+
Graphs = "1.4"
1416
julia = "1.6"

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
[![docs](https://img.shields.io/badge/docs-latest-blue.svg)](https://docs.circuitscape.org/SpatialGraphs.jl/latest) | [![Build Status](https://github.com/Circuitscape/SpatialGraphs.jl/workflows/CI/badge.svg)](https://github.com/Circuitscape/SpatialGraphs.jl/actions?query=workflow%3ACI) [![codecov](https://codecov.io/gh/Circuitscape/SpatialGraphs.jl/branch/main/graph/badge.svg?token=67OX4UPWOL)](https://codecov.io/gh/Circuitscape/SpatialGraphs.jl)
66

77
SpatialGraphs.jl introduces the `AbstractSpatialGraph`. `AbstractSpatialGraphs`
8-
are a subtype of `LightGraphs.AbstractGraph`, and can be weighted or directed.
9-
AbstractSpatialGraphs are AbstractGraphs, so methods from LightGraphs.jl work right
8+
are a subtype of `Graphs.AbstractGraph`, and can be weighted or directed.
9+
AbstractSpatialGraphs are AbstractGraphs, so methods from Graphs.jl work right
1010
out of the box.
1111

1212
`AbstractSpatialGraph`s themselves contain an `AbstractGraph` in addition to

docs/src/graphtypes.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ an `AbstractGraph`.
1212
AbstractSpatialGraph
1313
```
1414

15-
The `AbstractRasterGraph` type is as subtype of `AbstractSpatialGraph`. All
15+
The `AbstractRasterGraph` type is a subtype of `AbstractSpatialGraph`. All
1616
`AbstractRasterGraph` subtypes contain a field called `vertex_raster`, which is
1717
a `GeoData.GeoArray` that describes the spatial locations for the vertices in
1818
the graph. If your graph has 10 vertices, then the corresponding `vertex_raster`
@@ -30,8 +30,8 @@ SpatialGraphs.jl has raster graph types for undirected, directed, unweighted,
3030
and weighted graphs, each detailed below.
3131

3232
```@docs
33-
SimpleRasterGraph
34-
SimpleRasterDiGraph
33+
RasterGraph
34+
RasterDiGraph
3535
WeightedRasterGraph
3636
WeightedRasterDiGraph
3737
```

docs/src/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# SpatialGraphs.jl
22

33
SpatialGraphs.jl introduces the `AbstractSpatialGraph`. `AbstractSpatialGraphs`
4-
are a subtype of `LightGraphs.AbstractGraph`, and can be weighted or directed.
4+
are a subtype of `Graphs.AbstractGraph`, and can be weighted or directed.
55
SpatialGraphs.jl is useful for turning spatial data into graphs. This can be
66
useful for landscape connectivity analysis, hydrology, and other spatial
77
network processes. AbstractSpatialGraphs are AbstractGraphs, so methods from
8-
LightGraphs.jl work right out of the box. Go to [Graph Types](@ref graph_types)
8+
Graphs.jl work right out of the box. Go to [Graph Types](@ref graph_types)
99
for more details on the graph types implemented in this package.
1010

docs/src/userguide.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ data.
77

88
### Simple Graphs
99
```@docs
10-
simplerastergraph
10+
rastergraph
1111
make_simple_raster_graph
1212
```
1313

src/SpatialGraphs.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module SpatialGraphs
22

3-
using LightGraphs, SimpleWeightedGraphs, SparseArrays, GeoData
3+
using Graphs, SimpleWeightedGraphs, SparseArrays, GeoData
44

55
include("structs.jl")
66
include("graph_interface.jl")
@@ -9,12 +9,12 @@ include("utils.jl")
99
include("show.jl")
1010

1111
## Types and Structs
12-
export AbstractSpatialGraph, AbstractRasterGraph, SimpleRasterGraph,
13-
SimpleRasterDiGraph, WeightedRasterGraph, WeightedRasterDiGraph
12+
export AbstractSpatialGraph, AbstractRasterGraph, RasterGraph,
13+
RasterDiGraph, WeightedRasterGraph, WeightedRasterDiGraph
1414

1515
## Raster graph
1616
export make_weighted_raster_graph, weightedrastergraph,
17-
make_simple_raster_graph, simplerastergraph
17+
make_simple_raster_graph, rastergraph
1818

1919

2020
end # module

src/graph_interface.jl

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
## Methods for the LightGraphs ad SimpleWeightedGraphs interfaces
2-
## With these methods defined, functions from LightGraphs should "just work"
3-
import LightGraphs:
1+
## Methods for the Graphs ad SimpleWeightedGraphs interfaces
2+
## With these methods defined, functions from Graphs should "just work"
3+
import Graphs:
44
nv, ne, vertices, edges, eltype, edgetype, has_edge, has_vertex,
55
inneighbors, outneighbors, is_directed, add_edge!
66

@@ -9,7 +9,7 @@ import SimpleWeightedGraphs:
99

1010
import Base: zero
1111

12-
### LightGraphs interface
12+
### Graphs interface
1313
nv(g::AbstractSpatialGraph) = nv(g.graph)
1414
ne(g::AbstractSpatialGraph) = ne(g.graph)
1515
vertices(g::AbstractSpatialGraph) = vertices(g.graph)
@@ -22,13 +22,13 @@ inneighbors(g::AbstractSpatialGraph, v) = inneighbors(g.graph, v)
2222
outneighbors(g::AbstractSpatialGraph, v) = outneighbors(g.graph, v)
2323
is_directed(g::AbstractSpatialGraph) = is_directed(g.graph)
2424
function Base.zero(g::AbstractRasterGraph)
25-
if g.graph isa SimpleGraph
26-
SimpleRasterGraph(
25+
if g.graph isa Graph
26+
RasterGraph(
2727
zero(typeof(g.graph)),
2828
g.vertex_raster
2929
)
30-
elseif g.graph isa SimpleDiGraph
31-
SimpleRasterDiGraph(
30+
elseif g.graph isa DiGraph
31+
RasterDiGraph(
3232
zero(typeof(g.graph)),
3333
g.vertex_raster
3434
)

src/rastergraphs.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,14 @@ function weightedrastergraph(
119119
end
120120

121121
"""
122-
simplerastergraph(
122+
RasterGraph(
123123
raster::GeoArray;
124124
directed::Bool = true,
125125
condition::Function = is_data,
126126
cardinal_neighbors_only::Bool = false
127127
)
128128
129-
Construct a `SimpleRasterGraph` or `SimpleRasterDiGraph` (if
129+
Construct a `RasterGraph` or `RasterDiGraph` (if
130130
`directed = true`) from a raster dataset.
131131
132132
## Parameters
@@ -161,7 +161,7 @@ connected. Note that when determining weights between diagonal neighbors, the
161161
increased distance between them (as compared to the distance between cardinal
162162
neighbors) is accounted for.
163163
"""
164-
function simplerastergraph(
164+
function rastergraph(
165165
raster::GeoArray;
166166
condition::Function = is_data,
167167
directed::Bool = true,
@@ -177,9 +177,9 @@ function simplerastergraph(
177177
)
178178

179179
if directed
180-
sg = SimpleRasterDiGraph(g, v)
180+
sg = RasterDiGraph(g, v)
181181
else
182-
sg = SimpleRasterGraph(g, v)
182+
sg = RasterGraph(g, v)
183183
end
184184

185185
return sg
@@ -587,7 +587,7 @@ function make_raster_graph(
587587
)
588588
else
589589
n_nodes = max(maximum(sources), maximum(destinations))
590-
g = SimpleDiGraph(
590+
g = DiGraph(
591591
sparse(sources, destinations, 1, n_nodes, n_nodes, combine)
592592
)
593593
end
@@ -601,7 +601,7 @@ function make_raster_graph(
601601
)
602602
else
603603
n_nodes = max(maximum(sources), maximum(destinations))
604-
g = SimpleGraph(
604+
g = Graph(
605605
sparse(
606606
vcat(sources, destinations),
607607
vcat(destinations, sources),

src/structs.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,21 +42,21 @@ mutable struct WeightedRasterDiGraph{T<:Integer, U<:Real} <: AbstractRasterGraph
4242
end
4343

4444
"""
45-
SimpleRasterGraph{T}
45+
RasterGraph{T}
4646
4747
A composite type for a spatially referenced graph. Vertices are spatially referenced based on a raster.
4848
"""
49-
mutable struct SimpleRasterGraph{T<:Integer} <: AbstractRasterGraph{T}
50-
graph::SimpleGraph{T} # A SimpleGraph
49+
mutable struct RasterGraph{T<:Integer} <: AbstractRasterGraph{T}
50+
graph::Graph{T} # A Graph
5151
vertex_raster::GeoArray # A GeoArray raster, where a pixel's value denotes its vertex ID in the graph
5252
end
5353

5454
"""
55-
SimpleRasterDiGraph{T}
55+
RasterDiGraph{T}
5656
5757
A composite type for a spatially referenced directed graph. Vertices are spatially referenced based on a raster.
5858
"""
59-
mutable struct SimpleRasterDiGraph{T<:Integer} <: AbstractRasterGraph{T}
60-
graph::SimpleDiGraph{T} # A SimpleDiGraph
59+
mutable struct RasterDiGraph{T<:Integer} <: AbstractRasterGraph{T}
60+
graph::DiGraph{T} # A DiGraph
6161
vertex_raster::GeoArray # A GeoArray raster, where a pixel's value denotes its vertex ID in the graph
6262
end

test/lg_interface.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using SpatialGraphs, Test, GeoData, LightGraphs, SimpleWeightedGraphs
1+
using SpatialGraphs, Test, GeoData, Graphs, SimpleWeightedGraphs
22
## This script tests methods for the LightGraph interface that aren't already
33
## used in other tests
44

0 commit comments

Comments
 (0)