Skip to content

Commit ad20f2e

Browse files
committed
Merge branch 'master' of git://github.com/JuliaGraphs/GraphPlot.jl into fruchterman_reingold
2 parents bf20ed0 + 23f73a3 commit ad20f2e

File tree

6 files changed

+45
-8
lines changed

6 files changed

+45
-8
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
*.jl.cov
22
*.jl.mem
33
*.svg
4+
Manifest.toml

.travis.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ matrix:
1414
notifications:
1515
email: false
1616
# uncomment the following lines to override the default test script
17-
script:
18-
- if [[ -a .git/shallow ]]; then git fetch --unshallow; fi
19-
- julia -e 'using Pkg; Pkg.clone(pwd()); Pkg.build("GraphPlot"); Pkg.test("GraphPlot"; coverage=true)'
17+
2018
after_success:
2119
# push coverage results to Codecov
2220
- julia -e 'using Pkg; cd(Pkg.dir("GraphPlot")); Pkg.add("Coverage"); using Coverage; Codecov.submit(Codecov.process_folder())'

Project.toml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name = "GraphPlot"
2+
uuid = "a2cc645c-3eea-5389-862e-a155d0052231"
3+
authors = ["JuliaGraphs"]
4+
version = "0.4.0"
5+
6+
[deps]
7+
ArnoldiMethod = "ec485272-7323-5ecc-a04f-4719b315124d"
8+
ColorTypes = "3da002f7-5984-5a60-b8a6-cbb66c0b333f"
9+
Colors = "5ae59095-9a9b-59fe-a467-6f913c188581"
10+
Compose = "a81c6b42-2e10-5240-aca2-a61377ecd94b"
11+
DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab"
12+
LightGraphs = "093fc24a-ae57-5d10-9952-331d41423f4d"
13+
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
14+
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
15+
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
16+
17+
[extras]
18+
Cairo = "159f3aea-2a34-519c-b102-8c37f9878175"
19+
ImageMagick = "6218d12a-5da1-5696-b52f-db25d2ecc6d1"
20+
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
21+
VisualRegressionTests = "34922c18-7c2a-561c-bac1-01e79b2c4c92"
22+
23+
[targets]
24+
test = ["Test", "Cairo", "ImageMagick", "VisualRegressionTests"]
25+
26+
[compat]
27+
"Compose" = "0.7"
28+
"LightGraphs" = "1.1"
29+
"VisualRegressionTests" = "0.2"

src/layout.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ Number of iterations we apply the forces
9292
*INITTEMP*
9393
Initial "temperature", controls movement per iteration
9494
95+
*seed*
96+
Integer seed for pseudorandom generation of locations (default = 0).
97+
9598
**Examples**
9699
```
97100
julia> g = smallgraph(:karate)
@@ -169,6 +172,12 @@ function spring_layout(g::AbstractGraph,
169172
return locs_x, locs_y
170173
end
171174

175+
using Random: MersenneTwister
176+
function spring_layout(g::AbstractGraph; seed::Integer=0, kws...)
177+
rng = MersenneTwister(seed)
178+
spring_layout(g, 2 .* rand(rng, nv(g)) .- 1.0, 2 .* rand(rng,nv(g)) .- 1.0; kws...)
179+
end
180+
172181
"""
173182
This function is copy from [IainNZ](https://github.com/IainNZ)'s [GraphLayout.jl](https://github.com/IainNZ/GraphLayout.jl)
174183

src/plot.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ a Compose tree of the graph layout
1111
Graph to draw
1212
1313
`layout`
14-
Optional. Layout algorithm. Currently can be one of [random_layout,
15-
circular_layout, spring_layout, shell_layout, stressmajorize_layout,
16-
spectral_layout].
14+
Optional. Layout algorithm. Currently can be one of [`random_layout`,
15+
`circular_layout`, `spring_layout`, `shell_layout`, `stressmajorize_layout`,
16+
`spectral_layout`].
1717
Default: `spring_layout`
1818
1919
`locs_x, locs_y`

test/runtests.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ g = smallgraph(karate_edges)
4141
h = LightGraphs.WheelGraph(10)
4242

4343

44+
test_layout(g::AbstractGraph; kws...) = spring_layout(g; seed=2017, kws...)
4445

4546
# plot and save function for visual regression tests
4647
function plot_and_save(fname, g; gplot_kwargs...)
47-
Random.seed!(2017)
48-
draw(PNG(fname, 8inch, 8inch), gplot(g; gplot_kwargs...))
48+
draw(PNG(fname, 8inch, 8inch), gplot(g; layout=test_layout, gplot_kwargs...))
4949
end
5050

5151
@testset "Karate Net" begin

0 commit comments

Comments
 (0)