@@ -25,15 +25,16 @@ using GraphPlot
2525# Usage
2626## karate network
2727``` julia
28- g = graphfamous (" karate" )
28+ using LightGraphs: smallgraph
29+ g = smallgraph (:karate )
2930gplot (g)
3031
3132```
3233
3334## Add node label
3435``` julia
35- using Graphs
36- nodelabel = [1 : num_vertices (g)]
36+ using LightGraphs
37+ nodelabel = [1 : nv (g)]
3738gplot (g, nodelabel= nodelabel)
3839
3940```
@@ -46,7 +47,7 @@ gplot(g, nodelabel=nodelabel, nodelabeldist=1.5, nodelabelangleoffset=π/4)
4647## Control the node size
4748``` julia
4849# nodes size proportional to their degree
49- nodesize = [Graphs . out_degree (v, g ) for v in Graphs . vertices (g)]
50+ nodesize = [LightGraphs . out_degree (g, v ) for v in LightGraphs . vertices (g)]
5051gplot (g, nodesize= nodesize)
5152```
5253
@@ -56,7 +57,7 @@ Feed the keyword argument `nodefillc` a color array, ensure each node has a colo
5657using Colors
5758
5859# Generate n maximally distinguishable colors in LCHab space.
59- nodefillc = distinguishable_colors (num_vertices (g), colorant " blue" )
60+ nodefillc = distinguishable_colors (nv (g), colorant " blue" )
6061gplot (g, nodefillc= nodefillc, nodelabel= nodelabel, nodelabeldist= 1.8 , nodelabelangleoffset= π/ 4 )
6162```
6263
@@ -75,13 +76,13 @@ gplot(g, nodelabelsize=nodelabelsize, nodesize=nodesize, nodelabel=nodelabel)
7576
7677## Draw edge labels
7778``` julia
78- edgelabel = [1 : Graphs . num_edges (g)]
79+ edgelabel = [1 : LightGraphs . ne (g)]
7980gplot (g, edgelabel= edgelabel, nodelabel= nodelabel)
8081```
8182
8283## Adjust edge labels
8384``` julia
84- edgelabel = [1 : Graphs . num_edges (g)]
85+ edgelabel = [1 : LightGraphs . ne (g)]
8586gplot (g, edgelabel= edgelabel, nodelabel= nodelabel, edgelabeldistx= 0.5 , edgelabeldisty= 0.5 )
8687```
8788
@@ -119,9 +120,9 @@ gplot(g, layout=spectral_layout)
119120```
120121### shell layout
121122``` julia
122- nlist = Array ( Vector{Int}, 2 ) # two shells
123+ nlist = Vector {Vector{ Int}} (undef , 2 ) # two shells
123124nlist[1 ] = [1 : 5 ] # first shell
124- nlist[2 ] = [6 : num_vertices (g)] # second shell
125+ nlist[2 ] = [6 : nv (g)] # second shell
125126locs_x, locs_y = shell_layout (g, nlist)
126127gplot (g, locs_x, locs_y, nodelabel= nodelabel)
127128```
@@ -133,7 +134,7 @@ gplot(g, linetype="curve")
133134
134135## Save to figure
135136``` {execute="false"}
136- using Compose
137+ using Cairo, Compose
137138# save to pdf
138139draw(PDF("karate.pdf", 16cm, 16cm), gplot(g))
139140# save to png
0 commit comments