Skip to content

Commit 9e734d5

Browse files
committed
Migrate from LightGraphs to Graphs.jl
1 parent b2a5b0b commit 9e734d5

File tree

8 files changed

+47
-47
lines changed

8 files changed

+47
-47
lines changed

Project.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
name = "GraphPlot"
22
uuid = "a2cc645c-3eea-5389-862e-a155d0052231"
33
authors = ["JuliaGraphs"]
4-
version = "0.4.4"
4+
version = "0.5.0"
55

66
[deps]
77
ArnoldiMethod = "ec485272-7323-5ecc-a04f-4719b315124d"
88
ColorTypes = "3da002f7-5984-5a60-b8a6-cbb66c0b333f"
99
Colors = "5ae59095-9a9b-59fe-a467-6f913c188581"
1010
Compose = "a81c6b42-2e10-5240-aca2-a61377ecd94b"
1111
DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab"
12-
LightGraphs = "093fc24a-ae57-5d10-9952-331d41423f4d"
12+
Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"
1313
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1414
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
1515
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
@@ -19,7 +19,7 @@ ArnoldiMethod = "0.0.4, 0.1"
1919
ColorTypes = "0.9, 0.10"
2020
Colors = "0.11, 0.12"
2121
Compose = "0.8, 0.9"
22-
LightGraphs = "1.1"
22+
Graphs = "1.4"
2323
VisualRegressionTests = "0.3, 1"
2424
julia = "1.3"
2525

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ using GraphPlot
2525
# Usage
2626
## karate network
2727
```julia
28-
using LightGraphs: smallgraph
28+
using Graphs: smallgraph
2929
g = smallgraph(:karate)
3030
gplot(g)
3131

3232
```
3333

3434
## Add node label
3535
```julia
36-
using LightGraphs
36+
using Graphs
3737
nodelabel = 1:nv(g)
3838
gplot(g, nodelabel=nodelabel)
3939

@@ -47,7 +47,7 @@ gplot(g, nodelabel=nodelabel, nodelabeldist=1.5, nodelabelangleoffset=π/4)
4747
## Control the node size
4848
```julia
4949
# nodes size proportional to their degree
50-
nodesize = [LightGraphs.outdegree(g, v) for v in LightGraphs.vertices(g)]
50+
nodesize = [Graphs.outdegree(g, v) for v in Graphs.vertices(g)]
5151
gplot(g, nodesize=nodesize)
5252
```
5353

@@ -76,13 +76,13 @@ gplot(g, nodelabelsize=nodelabelsize, nodesize=nodesize, nodelabel=nodelabel)
7676

7777
## Draw edge labels
7878
```julia
79-
edgelabel = 1:LightGraphs.ne(g)
79+
edgelabel = 1:Graphs.ne(g)
8080
gplot(g, edgelabel=edgelabel, nodelabel=nodelabel)
8181
```
8282

8383
## Adjust edge labels
8484
```julia
85-
edgelabel = 1:LightGraphs.ne(g)
85+
edgelabel = 1:Graphs.ne(g)
8686
gplot(g, edgelabel=edgelabel, nodelabel=nodelabel, edgelabeldistx=0.5, edgelabeldisty=0.5)
8787
```
8888

@@ -142,9 +142,9 @@ draw(PNG("karate.png", 16cm, 16cm), gplot(g))
142142
# save to svg
143143
draw(SVG("karate.svg", 16cm, 16cm), gplot(g))
144144
```
145-
# LightGraphs integration
145+
# Graphs.jl integration
146146
```julia
147-
using LightGraphs
147+
using Graphs
148148
h = watts_strogatz(50, 6, 0.3)
149149
gplot(h)
150150
```

examples/graphplot.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
"outputs": [],
5050
"source": [
5151
"# load needed package firstly\n",
52-
"using LightGraphs\n",
52+
"using Graphs\n",
5353
"using GraphPlot"
5454
]
5555
},
@@ -12127,7 +12127,7 @@
1212712127
}
1212812128
},
1212912129
"source": [
12130-
"# Native LightGraphs integration"
12130+
"# Native Graphs.jl integration"
1213112131
]
1213212132
},
1213312133
{

src/GraphPlot.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module GraphPlot
22

33
using Compose # for plotting features
4-
using LightGraphs
4+
using Graphs
55

66
const gadflyjs = joinpath(dirname(Base.source_path()), "gadfly.js")
77

src/collapse_plot.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@ function community_layout(g::AbstractGraph, membership::Vector{Int})
6464
end
6565

6666
function collapse_layout(g::AbstractGraph, membership::Vector{Int})
67-
lightg = LightGraphs.SimpleGraph(nv(g))
67+
sg = Graphs.SimpleGraph(nv(g))
6868
for e in edges(g)
6969
u = src(e)
7070
v = dst(e)
71-
LightGraphs.add_edge!(lightg, u, v)
71+
Graphs.add_edge!(sg, u, v)
7272
end
7373
N = length(membership)
7474
lx = zeros(N)
@@ -84,7 +84,7 @@ function collapse_layout(g::AbstractGraph, membership::Vector{Int})
8484
h, w = collapse_graph(g, membership)
8585
clx, cly = spring_layout(h)
8686
for (lbl, nodes) in comms
87-
subg = lightg[nodes]
87+
subg = sg[nodes]
8888
sublx, subly = spring_layout(subg)
8989
θ = range(0, stop=2pi, length=(length(nodes) + 1))[1:end-1]
9090
for (idx, node) in enumerate(nodes)

src/deprecations.jl

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,49 @@
11
using Base: depwarn
22

33

4-
function _nv(g)
5-
depwarn("`GraphPlot._nv(g)` is deprectated. Use `LightGraphs.nv(g)` instead.", :_nv)
6-
return LightGraphs.nv(g)
4+
function _nv(g)
5+
depwarn("`GraphPlot._nv(g)` is deprectated. Use `Graphs.nv(g)` instead.", :_nv)
6+
return Graphs.nv(g)
77
end
88

9-
function _ne(g)
10-
depwarn("`GraphPlot._ne(g)` is deprectated. Use `LightGraphs.ne(g)` instead.", :_ne)
11-
return LightGraphs.ne(g)
9+
function _ne(g)
10+
depwarn("`GraphPlot._ne(g)` is deprectated. Use `Graphs.ne(g)` instead.", :_ne)
11+
return Graphs.ne(g)
1212
end
1313

14-
function _vertices(g)
15-
depwarn("`GraphPlot._vertices(g)` is deprectated. Use `LightGraphs.vertices(g)` instead.", :_vertices)
16-
return LightGraphs.vertices(g)
14+
function _vertices(g)
15+
depwarn("`GraphPlot._vertices(g)` is deprectated. Use `Graphs.vertices(g)` instead.", :_vertices)
16+
return Graphs.vertices(g)
1717
end
1818

19-
function _edges(g)
20-
depwarn("`GraphPlot._edges(g)` is deprectated. Use `LightGraphs.edges(g)` instead.", :_edges)
21-
return LightGraphs.edges(g)
19+
function _edges(g)
20+
depwarn("`GraphPlot._edges(g)` is deprectated. Use `Graphs.edges(g)` instead.", :_edges)
21+
return Graphs.edges(g)
2222
end
2323

24-
function _src_index(e, g)
25-
depwarn("`GraphPlot._src_index(g)` is deprectated. Use `LightGraphs.src(e)` instead.", :_src_index)
26-
return LightGraphs.src(e)
24+
function _src_index(e, g)
25+
depwarn("`GraphPlot._src_index(g)` is deprectated. Use `Graphs.src(e)` instead.", :_src_index)
26+
return Graphs.src(e)
2727
end
2828

29-
function _dst_index(e, g)
30-
depwarn("`GraphPlot._dst_index(g)` is deprectated. Use `LightGraphs.dst(e)` instead.", :_dst_index)
31-
return LightGraphs.dst(e)
29+
function _dst_index(e, g)
30+
depwarn("`GraphPlot._dst_index(g)` is deprectated. Use `Graphs.dst(e)` instead.", :_dst_index)
31+
return Graphs.dst(e)
3232
end
3333

34-
function _adjacency_matrix(g)
35-
depwarn("`GraphPlot._adjacency_matrix(g)` is deprectated. Use `LightGraphs.adjacency_matrix(g)` instead.", :_adjacency_matrix)
36-
return LightGraphs.adjacency_matrix(g)
34+
function _adjacency_matrix(g)
35+
depwarn("`GraphPlot._adjacency_matrix(g)` is deprectated. Use `Graphs.adjacency_matrix(g)` instead.", :_adjacency_matrix)
36+
return Graphs.adjacency_matrix(g)
3737
end
3838

39-
function _is_directed(g)
40-
depwarn("`GraphPlot._is_directed(g)` is deprectated. Use `LightGraphs.is_directed(g)` instead.", :_is_directed)
41-
return LightGraphs.is_directed(g)
39+
function _is_directed(g)
40+
depwarn("`GraphPlot._is_directed(g)` is deprectated. Use `Graphs.is_directed(g)` instead.", :_is_directed)
41+
return Graphs.is_directed(g)
4242
end
4343

44-
function _laplacian_matrix(g)
45-
depwarn("`GraphPlot._laplacian_matrix(g)` is deprectated. Use `LightGraphs.laplacian_matrix(g)` instead.", :_laplacian_matrix)
46-
return LightGraphs.laplacian_matrix(g)
44+
function _laplacian_matrix(g)
45+
depwarn("`GraphPlot._laplacian_matrix(g)` is deprectated. Use `Graphs.laplacian_matrix(g)` instead.", :_laplacian_matrix)
46+
return Graphs.laplacian_matrix(g)
4747
end
4848

4949

src/layout.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ function _spectral(A::SparseMatrixCSC)
280280
data = vec(sum(A, dims=1))
281281
D = sparse(Base.OneTo(length(data)), Base.OneTo(length(data)), data)
282282
L = D - A
283-
eigenvalues, eigenvectors = LightGraphs.LinAlg.eigs(L, nev=3, which=SR())
283+
eigenvalues, eigenvectors = Graphs.LinAlg.eigs(L, nev=3, which=SR())
284284
index = sortperm(real(eigenvalues))[2:3]
285285
return real(eigenvectors[:, index[1]]), real(eigenvectors[:, index[2]])
286286
end

test/runtests.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
(Sys.islinux() || Sys.iswindows()) && import ImageMagick
44

55
using GraphPlot
6-
using LightGraphs
6+
using Graphs
77
using Cairo
88
using Colors
99
using Compose
@@ -19,7 +19,7 @@ datadir = joinpath(@__DIR__, "data")
1919

2020

2121

22-
# TODO smallgraph(:karate) has already been added to LightGraphs
22+
# TODO smallgraph(:karate) has already been added to Graphs
2323
# but as there hasn't been any new version tagged, we relay on this instead
2424
karate_edges = Edge.([
2525
1 => 2, 1 => 3, 1 => 4, 1 => 5, 1 => 6, 1 => 7,
@@ -39,7 +39,7 @@ karate_edges = Edge.([
3939
# graphs to test
4040
#g = smallgraph(:karate)
4141
g = SimpleGraph(karate_edges)
42-
h = LightGraphs.WheelGraph(10)
42+
h = Graphs.WheelGraph(10)
4343

4444
test_layout(g::AbstractGraph; kws...) = spring_layout(g, 2017, kws...)
4545

0 commit comments

Comments
 (0)