From 819aff8e810e8053bf95493f68fe5bf8c617a0b9 Mon Sep 17 00:00:00 2001 From: Simon Schoelly Date: Sun, 8 Mar 2020 23:39:44 +0100 Subject: [PATCH 1/4] Use smallgraph instead of graphfamous The graphfamous function of this package was deprecated a while ago and the karate was moved to LightGraphs. --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d1ca76c..b90d388 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,8 @@ using GraphPlot # Usage ## karate network ```julia -g = graphfamous("karate") +using LightGraphs: smallgraph +g = smallgraph(:karate) gplot(g) ``` From 0ec9af4e2942f7d728c10b487d1af735c1426d9a Mon Sep 17 00:00:00 2001 From: Simon Schoelly Date: Sun, 8 Mar 2020 23:41:57 +0100 Subject: [PATCH 2/4] Use LightGraphs instead of Graphs in README.md This readme still used mostly Graphs.jl instead of LightGraphs.jl. As the former package is deprecated and GraphPlots.jl does not work with it anymore, every occurrence of Graphs has changed to LightGraphs. Some functions functions such as num_vertices or out_degree had to be changed for that. --- README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index b90d388..49a1a33 100644 --- a/README.md +++ b/README.md @@ -33,8 +33,8 @@ gplot(g) ## Add node label ```julia -using Graphs -nodelabel = [1:num_vertices(g)] +using LightGraphs +nodelabel = [1:nv(g)] gplot(g, nodelabel=nodelabel) ``` @@ -47,7 +47,7 @@ gplot(g, nodelabel=nodelabel, nodelabeldist=1.5, nodelabelangleoffset=π/4) ## Control the node size ```julia # nodes size proportional to their degree -nodesize = [Graphs.out_degree(v, g) for v in Graphs.vertices(g)] +nodesize = [LightGraphs.out_degree(g, v) for v in LightGraphs.vertices(g)] gplot(g, nodesize=nodesize) ``` @@ -57,7 +57,7 @@ Feed the keyword argument `nodefillc` a color array, ensure each node has a colo using Colors # Generate n maximally distinguishable colors in LCHab space. -nodefillc = distinguishable_colors(num_vertices(g), colorant"blue") +nodefillc = distinguishable_colors(nv(g), colorant"blue") gplot(g, nodefillc=nodefillc, nodelabel=nodelabel, nodelabeldist=1.8, nodelabelangleoffset=π/4) ``` @@ -76,13 +76,13 @@ gplot(g, nodelabelsize=nodelabelsize, nodesize=nodesize, nodelabel=nodelabel) ## Draw edge labels ```julia -edgelabel = [1:Graphs.num_edges(g)] +edgelabel = [1:LightGraphs.ne(g)] gplot(g, edgelabel=edgelabel, nodelabel=nodelabel) ``` ## Adjust edge labels ```julia -edgelabel = [1:Graphs.num_edges(g)] +edgelabel = [1:LightGraphs.ne(g)] gplot(g, edgelabel=edgelabel, nodelabel=nodelabel, edgelabeldistx=0.5, edgelabeldisty=0.5) ``` @@ -122,7 +122,7 @@ gplot(g, layout=spectral_layout) ```julia nlist = Array(Vector{Int}, 2) # two shells nlist[1] = [1:5] # first shell -nlist[2] = [6:num_vertices(g)] # second shell +nlist[2] = [6:nv(g)] # second shell locs_x, locs_y = shell_layout(g, nlist) gplot(g, locs_x, locs_y, nodelabel=nodelabel) ``` From 282a9102f86de437ba1d320759e3a0043c5cc33b Mon Sep 17 00:00:00 2001 From: Simon Schoelly Date: Sun, 8 Mar 2020 23:50:18 +0100 Subject: [PATCH 3/4] Update outdated code for Vector creation --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 49a1a33..3e97bf3 100644 --- a/README.md +++ b/README.md @@ -120,7 +120,7 @@ gplot(g, layout=spectral_layout) ``` ### shell layout ```julia -nlist = Array(Vector{Int}, 2) # two shells +nlist = Vector{Vector{Int}}(undef, 2) # two shells nlist[1] = [1:5] # first shell nlist[2] = [6:nv(g)] # second shell locs_x, locs_y = shell_layout(g, nlist) From d390f28d04ae4a4a7d274e9b492c5e4df6dffcd4 Mon Sep 17 00:00:00 2001 From: Simon Schoelly Date: Sun, 8 Mar 2020 23:51:08 +0100 Subject: [PATCH 4/4] Explicitly import Cairo for drawing to file For drawing a graph to a file, it is not necessary to import Cairo before importing Compose. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3e97bf3..e80acc5 100644 --- a/README.md +++ b/README.md @@ -134,7 +134,7 @@ gplot(g, linetype="curve") ## Save to figure ```{execute="false"} -using Compose +using Cairo, Compose # save to pdf draw(PDF("karate.pdf", 16cm, 16cm), gplot(g)) # save to png