@@ -25,15 +25,16 @@ using GraphPlot
25
25
# Usage
26
26
## karate network
27
27
``` julia
28
- g = graphfamous (" karate" )
28
+ using LightGraphs: smallgraph
29
+ g = smallgraph (:karate )
29
30
gplot (g)
30
31
31
32
```
32
33
33
34
## Add node label
34
35
``` julia
35
- using Graphs
36
- nodelabel = [1 : num_vertices (g)]
36
+ using LightGraphs
37
+ nodelabel = [1 : nv (g)]
37
38
gplot (g, nodelabel= nodelabel)
38
39
39
40
```
@@ -46,7 +47,7 @@ gplot(g, nodelabel=nodelabel, nodelabeldist=1.5, nodelabelangleoffset=π/4)
46
47
## Control the node size
47
48
``` julia
48
49
# 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)]
50
51
gplot (g, nodesize= nodesize)
51
52
```
52
53
@@ -56,7 +57,7 @@ Feed the keyword argument `nodefillc` a color array, ensure each node has a colo
56
57
using Colors
57
58
58
59
# 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" )
60
61
gplot (g, nodefillc= nodefillc, nodelabel= nodelabel, nodelabeldist= 1.8 , nodelabelangleoffset= π/ 4 )
61
62
```
62
63
@@ -75,13 +76,13 @@ gplot(g, nodelabelsize=nodelabelsize, nodesize=nodesize, nodelabel=nodelabel)
75
76
76
77
## Draw edge labels
77
78
``` julia
78
- edgelabel = [1 : Graphs . num_edges (g)]
79
+ edgelabel = [1 : LightGraphs . ne (g)]
79
80
gplot (g, edgelabel= edgelabel, nodelabel= nodelabel)
80
81
```
81
82
82
83
## Adjust edge labels
83
84
``` julia
84
- edgelabel = [1 : Graphs . num_edges (g)]
85
+ edgelabel = [1 : LightGraphs . ne (g)]
85
86
gplot (g, edgelabel= edgelabel, nodelabel= nodelabel, edgelabeldistx= 0.5 , edgelabeldisty= 0.5 )
86
87
```
87
88
@@ -119,9 +120,9 @@ gplot(g, layout=spectral_layout)
119
120
```
120
121
### shell layout
121
122
``` julia
122
- nlist = Array ( Vector{Int}, 2 ) # two shells
123
+ nlist = Vector {Vector{ Int}} (undef , 2 ) # two shells
123
124
nlist[1 ] = [1 : 5 ] # first shell
124
- nlist[2 ] = [6 : num_vertices (g)] # second shell
125
+ nlist[2 ] = [6 : nv (g)] # second shell
125
126
locs_x, locs_y = shell_layout (g, nlist)
126
127
gplot (g, locs_x, locs_y, nodelabel= nodelabel)
127
128
```
@@ -133,7 +134,7 @@ gplot(g, linetype="curve")
133
134
134
135
## Save to figure
135
136
``` {execute="false"}
136
- using Compose
137
+ using Cairo, Compose
137
138
# save to pdf
138
139
draw(PDF("karate.pdf", 16cm, 16cm), gplot(g))
139
140
# save to png
0 commit comments