Skip to content

Commit 065eebd

Browse files
Migrate from LightGraphs to Graphs.jl (#41)
* Migrate from LightGraphs to Graphs.jl
1 parent 8cdc596 commit 065eebd

21 files changed

+105
-106
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ jobs:
6161
julia --project=docs -e '
6262
using Documenter: DocMeta, doctest
6363
using SimpleValueGraphs
64-
DocMeta.setdocmeta!(SimpleValueGraphs, :DocTestSetup, :(using SimpleValueGraphs, LightGraphs, Random); recursive=true)
64+
DocMeta.setdocmeta!(SimpleValueGraphs, :DocTestSetup, :(using SimpleValueGraphs, Graphs, Random); recursive=true)
6565
doctest(SimpleValueGraphs)' # change MYPACKAGE to the name of your package
6666
- run: julia --project=docs docs/make.jl
6767
env:

Project.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
name = "SimpleValueGraphs"
22
uuid = "b43c691f-cac2-5415-8122-396fe16a49fc"
33
authors = ["Simon Schoelly <sischoel@gmail.com>"]
4-
version = "0.3.2"
4+
version = "0.4.0"
55

66
[deps]
77
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
8-
LightGraphs = "093fc24a-ae57-5d10-9952-331d41423f4d"
8+
Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"
99
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1010
Requires = "ae029012-a4dd-5104-9daa-d747884805df"
1111
SimpleTraits = "699a6c99-e7fa-54fc-8d76-47d257e15c1d"
@@ -15,8 +15,8 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
1515

1616
[compat]
1717
DataStructures = "0.18.9"
18-
LightGraphs = "1.3"
18+
Graphs = "1.4.1"
1919
Requires = "1.0"
2020
SimpleTraits = "0.9.3"
21-
SimpleWeightedGraphs = "1.1.1"
21+
SimpleWeightedGraphs = "1.2"
2222
julia = "1.5"

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
[![codecov](https://codecov.io/gh/simonschoelly/SimpleValueGraphs.jl/branch/master/graph/badge.svg)](https://codecov.io/gh/simonschoelly/SimpleValueGraphs.jl)
99
[![](https://img.shields.io/badge/chat-Zulip%23graphs-yellow)](https://julialang.zulipchat.com/#narrow/stream/228745-graphs)
1010

11-
SimpleValueGraphs is as [LightGraphs.jl](https://github.com/JuliaGraphs/LightGraphs.jl) compatible package for graphs with multiple, homogeneous vertex, edge and graph metadata. In particular it provides:
11+
SimpleValueGraphs is a [Graphs.jl](https://github.com/JuliaGraphs/Graphs.jl) compatible package for graphs with multiple, homogeneous vertex, edge and graph metadata. In particular it provides:
1212
- an abstract interface for graphs with metadata
1313
- concrete implementations of mutable graphs with metadata
1414

@@ -26,12 +26,12 @@ Compared to [MetaGraphs.jl](https://github.com/JuliaGraphs/MetaGraphs.jl) it has
2626
```julia
2727
using SimpleValueGraphs
2828

29-
using LightGraphs: smallgraph
29+
using Graphs: smallgraph
3030
using Plots
3131
using GraphRecipes: graphplot
3232
using Colors: RGB, Color
3333

34-
# Load a LightGraphs.SimpleGraph
34+
# Load a Graphs.SimpleGraph
3535
gs = smallgraph(:house)
3636

3737
# Convert to a ValGraph with vertex and edge values
@@ -58,25 +58,25 @@ graphplot(gv;
5858

5959
## Benchmarks
6060

61-
This is a comparison of running `LightGraphs.dijkstra_shortest_paths` on the [egonets-Facebook](https://snap.stanford.edu/data/egonets-Facebook.html) graph for multiple graph types.
61+
This is a comparison of running `Graphs.dijkstra_shortest_paths` on the [egonets-Facebook](https://snap.stanford.edu/data/egonets-Facebook.html) graph for multiple graph types.
6262

6363
| graph type | time (ms) |
6464
| ------------------------------------------------- | --------- |
65-
| LightGraphs.SimpleGraph + Matrix weights | 6.5 |
66-
| LightGraphs.SimpleGraph + SparseMatrixCSC weights | 11.4 |
65+
| Graphs.SimpleGraph + Matrix weights | 6.5 |
66+
| Graphs.SimpleGraph + SparseMatrixCSC weights | 11.4 |
6767
| SimpleWeightedGraphs.SimpleWeightedGraph | 11.7 |
6868
| MetaGraphs.MetaGraph | 141.9 |
6969
| SimpleValueGraphs.ValGraph | 12.4 |
7070

71-
Currently a lot of LightGraphs algorithm do not optimally work with graphs that store edge metadata
71+
Currently a lot of Graphs.jl algorithms do not optimally work with graphs that store edge metadata
7272
internally. The next benchmark is an optimized version of the same algorithm that can be found
7373
in `SimpleValueGraphs.Experimental.dijkstra_shortests_pasts`. Clearly, this is a huge improvement for
7474
`ValGraph` and `SimpleWeightedGraph`.
7575

7676
| graph type | time (ms) |
7777
| ------------------------------------------------- | --------- |
78-
| LightGraphs.SimpleGraph + Matrix weights | 6.8 |
79-
| LightGraphs.SimpleGraph + SparseMatrixCSC weights | 10.8 |
78+
| Graphs.SimpleGraph + Matrix weights | 6.8 |
79+
| Graphs.SimpleGraph + SparseMatrixCSC weights | 10.8 |
8080
| SimpleWeightedGraphs.SimpleWeightedGraph | 2.9 |
8181
| MetaGraphs.MetaGraph | 147.3 |
8282
| SimpleValueGraphs.ValGraph | 3.1 |

benchmarks/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[deps]
22
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
3-
LightGraphs = "093fc24a-ae57-5d10-9952-331d41423f4d"
3+
Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"
44
MetaGraphs = "626554b9-1ddb-594c-aa3c-2596fe9399a5"
55
SNAPDatasets = "fc66bc1b-447b-53fc-8f09-bc9cfb0b0c10"
66
SimpleValueGraphs = "b43c691f-cac2-5415-8122-396fe16a49fc"

benchmarks/benchmarks.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using BenchmarkTools
2-
using SimpleValueGraphs, LightGraphs
2+
using SimpleValueGraphs, Graphs
33
using SimpleWeightedGraphs, MetaGraphs
44
using SNAPDatasets: loadsnap, snap_graphs
55
using SparseArrays

docs/Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[deps]
22
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
3-
LightGraphs = "093fc24a-ae57-5d10-9952-331d41423f4d"
3+
Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"
44
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
55
SimpleValueGraphs = "b43c691f-cac2-5415-8122-396fe16a49fc"

docs/make.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using Documenter, SimpleValueGraphs
22

3-
DocMeta.setdocmeta!(SimpleValueGraphs, :DocTestSetup, :(using SimpleValueGraphs, LightGraphs, Random); recursive=true)
3+
DocMeta.setdocmeta!(SimpleValueGraphs, :DocTestSetup, :(using SimpleValueGraphs, Graphs, Random); recursive=true)
44
makedocs(
55
sitename = "SimpleValueGraphs.jl",
66
authors = "Simon Schoelly",

docs/src/custom-valuegraph-types.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
While this package provides some concrete graph types, one is often interested in creating
44
their own graph types. This section will explain how one can create a custom graph type that
55
will work well with the methods from as package as well as the ones from
6-
[LightGraphs.jl](https://github.com/JuliaGraphs/LightGraphs.jl)
6+
[Graphs.jl](https://github.com/JuliaGraphs/Graphs.jl)
77

88
## The AbstractValGraph type
99

1010
All value graphs should be subtypes of *AbstractValGraph* that has the signature
1111

1212
```julia
13-
AbstractValGraph{V <: Integer, V_VALS, E_VALS, G_VALS} <: LightGraphs.AbstractGraph{V}
13+
AbstractValGraph{V <: Integer, V_VALS, E_VALS, G_VALS} <: Graphs.AbstractGraph{V}
1414
```
1515
where the parameters have the following meaning:
1616
- `V` is the type used for indexing vertices, called the *eltype* of the graph. Should
@@ -29,8 +29,8 @@ MyGraphType{W} <: AbstractValGraph{Int, Tuple{}, Tuple{Int, W}, Tuple{}}
2929
is a graph type that has neither vertex nor graph values and two edge values,
3030
one of them of type `Int` and the other of type `W`.
3131

32-
As a subtype of `LightGraphs.AbstractGraph`, an `AbstractValGraph` should implement the
33-
[methods required by LightGraphs](https://github.com/JuliaGraphs/LightGraphs.jl) as well as some
32+
As a subtype of `Graphs.AbstractGraph`, an `AbstractValGraph` should implement the
33+
[methods required by Graphs.jl](https://github.com/JuliaGraphs/Graphs.jl) as well as some
3434
other methods. Luckily a lot of the methods required for `AbstractGraph` already have a default
3535
implementation, so the number of necessary methods is actually much shorter.
3636

docs/src/graphtypes.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ and three concrete implementations.
88
The abstract type `AbstractValGraph` denotes a graph that can have multiple vertex
99
and edge values. It has the signature
1010
```julia
11-
AbstractValGraph{V, V_VALS, E_VALS} <: LightGraphs.AbstractGraph{V}
11+
AbstractValGraph{V, V_VALS, E_VALS} <: Graphs.AbstractGraph{V}
1212
```
1313
where the parameters have the following meaning:
1414
- `V` is the type used for indexing vertices, called the *eltype* of the graph. Should
@@ -116,7 +116,7 @@ Graphs without any values an be created with
116116
```julia
117117
ValGraph{V = Int32}(n)
118118
```
119-
where `n` is the number of vertices. One notable difference to LightGraphs is that the
119+
where `n` is the number of vertices. One notable difference to Graphs.jl is that the
120120
eltype is not bases on the type of `n` but is always taken from the parameter `V`.
121121

122122
```julia
@@ -185,9 +185,9 @@ julia> g2 = ValDiGraph{Int8}(4;
185185
edge value types: ()
186186
```
187187

188-
#### Graph from LightGraphs SimpleGraphs
188+
#### Graph from Graphs.jl SimpleGraphs
189189

190-
One can also initialize a graph from a LightGraphs `SimpleGraph` or `SimpleDiGraph`. If
190+
One can also initialize a graph from a Graphs.jl `SimpleGraph` or `SimpleDiGraph`. If
191191
edge values are specified (with the `edgeval_types` keyword) we also need an initializer for
192192
edge values. We do that by using the `edgeval_init` keyword argument which can be
193193
either `undef` or a function `(s, d) -> values` that takes a source and target vertex and
@@ -199,7 +199,7 @@ Furthermore, if the eltype is not specified as a parameter, it is taken from the
199199
graph.
200200

201201
```julia
202-
julia> using LightGraphs: smallgraph, PathDiGraph
202+
julia> using Graphs.jl: smallgraph, PathDiGraph
203203

204204
julia> g_simple = smallgraph(:house)
205205
{5, 6} undirected simple Int64 graph

docs/src/matrices.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ that contain the topology of the graph.
66
## Adjacency matrices
77

88
The `adjacency_matrix` function creates an adjacency matrix from a value graph . In contrast
9-
to LightGraphs, this is just a immutable *matrix view* of the graph, i.e if the graph
9+
to Graphs.jl, this is just a immutable *matrix view* of the graph, i.e if the graph
1010
changes, then so does this matrix. Therefore to get a mutable adjacency matrix one has to convert
1111
it before to some other matrix type.
1212

1313
It is also possible to use the constructor `AdjacencyMatrix` to create a view of any
14-
`LightGraphs.AbstractGraph`.
14+
`Graphs.AbstractGraph`.
1515

1616
```julia
1717
julia> g1 = SimpleValueGraphs.swissmetro_graph();
@@ -65,8 +65,8 @@ julia> ValMatrix(g, :b, nothing)
6565
"xyz" nothing nothing
6666
```
6767
68-
One can also use the `LightGraphs.weights` function to obtain this matrix. If the graph
69-
does not have any edge values, this returns a `LightGraphs.DefaultDistance` instead.
68+
One can also use the `Graphs.weights` function to obtain this matrix. If the graph
69+
does not have any edge values, this returns a `Graphs.DefaultDistance` instead.
7070
7171
```julia
7272
julia> weights(g1, :a)

0 commit comments

Comments
 (0)