@@ -10,83 +10,93 @@ a Compose tree of the graph layout
10
10
`G`
11
11
Graph to draw
12
12
13
+ `locs_x, locs_y`
14
+ Locations of the nodes. Can be any units you want,
15
+ but will be normalized and centered anyway. If not provided, will
16
+ be obtained from `layout` kwarg.
17
+
18
+ **Keyword Arguments**
19
+
13
20
`layout`
14
- Optional. Layout algorithm. Currently can be one of [`random_layout`,
21
+ Layout algorithm. Currently can be one of [`random_layout`,
15
22
`circular_layout`, `spring_layout`, `shell_layout`, `stressmajorize_layout`,
16
23
`spectral_layout`].
17
24
Default: `spring_layout`
18
25
19
- `locs_x, locs_y`
20
- Locations of the nodes. Can be any units you want,
21
- but will be normalized and centered anyway
22
-
23
26
`NODESIZE`
24
- Optional. Max size for the nodes. Default: `3.0/sqrt(N)`
27
+ Max size for the nodes. Default: `3.0/sqrt(N)`
25
28
26
29
`nodesize`
27
- Optional. Relative size for the nodes, can be a Vector. Default: `1.0`
30
+ Relative size for the nodes, can be a Vector. Default: `1.0`
28
31
29
32
`nodelabel`
30
- Optional. Labels for the vertices, a Vector or nothing. Default: `nothing`
33
+ Labels for the vertices, a Vector or nothing. Default: `nothing`
31
34
32
35
`nodelabelc`
33
- Optional. Color for the node labels, can be a Vector. Default: `colorant"black"`
36
+ Color for the node labels, can be a Vector. Default: `colorant"black"`
34
37
35
38
`nodelabeldist`
36
- Optional. Distances for the node labels from center of nodes. Default: `0.0`
39
+ Distances for the node labels from center of nodes. Default: `0.0`
37
40
38
41
`nodelabelangleoffset`
39
- Optional. Angle offset for the node labels. Default: `π/4.0`
42
+ Angle offset for the node labels. Default: `π/4.0`
40
43
41
44
`NODELABELSIZE`
42
- Optional. Largest fontsize for the vertice labels. Default: `4.0`
45
+ Largest fontsize for the vertice labels. Default: `4.0`
43
46
44
47
`nodelabelsize`
45
- Optional. Relative fontsize for the vertice labels, can be a Vector. Default: `1.0`
48
+ Relative fontsize for the vertice labels, can be a Vector. Default: `1.0`
46
49
47
50
`nodefillc`
48
- Optional. Color to fill the nodes with, can be a Vector. Default: `colorant"turquoise"`
51
+ Color to fill the nodes with, can be a Vector. Default: `colorant"turquoise"`
49
52
50
53
`nodestrokec`
51
- Optional. Color for the nodes stroke, can be a Vector. Default: `nothing`
54
+ Color for the nodes stroke, can be a Vector. Default: `nothing`
52
55
53
56
`nodestrokelw`
54
- Optional. Line width for the nodes stroke, can be a Vector. Default: `0.0`
57
+ Line width for the nodes stroke, can be a Vector. Default: `0.0`
55
58
56
59
`edgelabel`
57
- Optional. Labels for the edges, a Vector or nothing. Default: `[]`
60
+ Labels for the edges, a Vector or nothing. Default: `[]`
58
61
59
62
`edgelabelc`
60
- Optional. Color for the edge labels, can be a Vector. Default: `colorant"black"`
63
+ Color for the edge labels, can be a Vector. Default: `colorant"black"`
61
64
62
65
`edgelabeldistx, edgelabeldisty`
63
- Optional. Distance for the edge label from center of edge. Default: `0.0`
66
+ Distance for the edge label from center of edge. Default: `0.0`
64
67
65
68
`EDGELABELSIZE`
66
- Optional. Largest fontsize for the edge labels. Default: `4.0`
69
+ Largest fontsize for the edge labels. Default: `4.0`
67
70
68
71
`edgelabelsize`
69
- Optional. Relative fontsize for the edge labels, can be a Vector. Default: `1.0`
72
+ Relative fontsize for the edge labels, can be a Vector. Default: `1.0`
70
73
71
74
`EDGELINEWIDTH`
72
- Optional. Max line width for the edges. Default: `0.25/sqrt(N)`
75
+ Max line width for the edges. Default: `0.25/sqrt(N)`
73
76
74
77
`edgelinewidth`
75
- Optional. Relative line width for the edges, can be a Vector. Default: `1.0`
78
+ Relative line width for the edges, can be a Vector. Default: `1.0`
76
79
77
80
`edgestrokec`
78
- Optional. Color for the edge strokes, can be a Vector. Default: `colorant"lightgray"`
81
+ Color for the edge strokes, can be a Vector. Default: `colorant"lightgray"`
79
82
80
83
`arrowlengthfrac`
81
- Optional. Fraction of line length to use for arrows.
84
+ Fraction of line length to use for arrows.
82
85
Equal to 0 for undirected graphs. Default: `0.1` for the directed graphs
83
86
84
87
`arrowangleoffset`
85
- Optional. Angular width in radians for the arrows. Default: `π/9 (20 degrees)`
88
+ Angular width in radians for the arrows. Default: `π/9 (20 degrees)`
89
+
90
+ `linetype`
91
+ Type of line used for edges ("straight", "curve"). Default: "straight"
92
+
93
+ `outangle`
94
+ Angular width in radians for the edges (only used if `linetype = "curve`).
95
+ Default: `π/5 (36 degrees)`
86
96
87
97
"""
88
98
function gplot (g:: AbstractGraph{T} ,
89
- locs_x_in:: Vector{R } , locs_y_in:: Vector{R } ;
99
+ locs_x_in:: Vector{R1 } , locs_y_in:: Vector{R2 } ;
90
100
nodelabel = nothing ,
91
101
nodelabelc = colorant " black" ,
92
102
nodelabelsize = 1.0 ,
@@ -108,9 +118,9 @@ function gplot(g::AbstractGraph{T},
108
118
nodestrokec = nothing ,
109
119
nodestrokelw = 0.0 ,
110
120
arrowlengthfrac = is_directed (g) ? 0.1 : 0.0 ,
111
- arrowangleoffset = π / 9.0 ,
121
+ arrowangleoffset = π / 9 ,
112
122
linetype = " straight" ,
113
- outangle = pi / 5 ) where {T <: Integer , R <: Real }
123
+ outangle = π / 5 ) where {T <: Integer , R1 <: Real , R2 <: Real }
114
124
115
125
length (locs_x_in) != length (locs_y_in) && error (" Vectors must be same length" )
116
126
N = nv (g)
@@ -231,25 +241,25 @@ end
231
241
232
242
# take from [Gadfly.jl](https://github.com/dcjones/Gadfly.jl)
233
243
function open_file (filename)
234
- if Sys. KERNEL == :Darwin
244
+ if Sys. isapple () # apple
235
245
run (` open $(filename) ` )
236
- elseif Sys. KERNEL == :Linux || Sys. KERNEL == :FreeBSD
246
+ elseif Sys. islinux () || Sys. isbsd () # linux
237
247
run (` xdg-open $(filename) ` )
238
- elseif Sys. KERNEL == :Windows
248
+ elseif Sys. iswindows () # windows
239
249
run (` $(ENV [" COMSPEC" ]) /c start $(filename) ` )
240
250
else
241
251
@warn (" Showing plots is not supported on OS $(string (Sys. KERNEL)) " )
242
252
end
243
253
end
244
254
245
255
# taken from [Gadfly.jl](https://github.com/dcjones/Gadfly.jl)
246
- function gplothtml (g; layout :: Function = spring_layout, keyargs... )
256
+ function gplothtml (args ... ; keyargs... )
247
257
filename = string (tempname (), " .html" )
248
258
output = open (filename, " w" )
249
259
250
260
plot_output = IOBuffer ()
251
261
draw (SVGJS (plot_output, Compose. default_graphic_width,
252
- Compose. default_graphic_width, false ), gplot (g, layout (g) ... ; keyargs... ))
262
+ Compose. default_graphic_width, false ), gplot (args ... ; keyargs... ))
253
263
plotsvg = String (take! (plot_output))
254
264
255
265
write (output,
0 commit comments