@@ -10,83 +10,93 @@ a Compose tree of the graph layout
1010`G`
1111Graph to draw
1212
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+
1320`layout`
14- Optional. Layout algorithm. Currently can be one of [`random_layout`,
21+ Layout algorithm. Currently can be one of [`random_layout`,
1522`circular_layout`, `spring_layout`, `shell_layout`, `stressmajorize_layout`,
1623`spectral_layout`].
1724Default: `spring_layout`
1825
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-
2326`NODESIZE`
24- Optional. Max size for the nodes. Default: `3.0/sqrt(N)`
27+ Max size for the nodes. Default: `3.0/sqrt(N)`
2528
2629`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`
2831
2932`nodelabel`
30- Optional. Labels for the vertices, a Vector or nothing. Default: `nothing`
33+ Labels for the vertices, a Vector or nothing. Default: `nothing`
3134
3235`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"`
3437
3538`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`
3740
3841`nodelabelangleoffset`
39- Optional. Angle offset for the node labels. Default: `π/4.0`
42+ Angle offset for the node labels. Default: `π/4.0`
4043
4144`NODELABELSIZE`
42- Optional. Largest fontsize for the vertice labels. Default: `4.0`
45+ Largest fontsize for the vertice labels. Default: `4.0`
4346
4447`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`
4649
4750`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"`
4952
5053`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`
5255
5356`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`
5558
5659`edgelabel`
57- Optional. Labels for the edges, a Vector or nothing. Default: `[]`
60+ Labels for the edges, a Vector or nothing. Default: `[]`
5861
5962`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"`
6164
6265`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`
6467
6568`EDGELABELSIZE`
66- Optional. Largest fontsize for the edge labels. Default: `4.0`
69+ Largest fontsize for the edge labels. Default: `4.0`
6770
6871`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`
7073
7174`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)`
7376
7477`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`
7679
7780`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"`
7982
8083`arrowlengthfrac`
81- Optional. Fraction of line length to use for arrows.
84+ Fraction of line length to use for arrows.
8285Equal to 0 for undirected graphs. Default: `0.1` for the directed graphs
8386
8487`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)`
8696
8797"""
8898function 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 } ;
90100 nodelabel = nothing ,
91101 nodelabelc = colorant " black" ,
92102 nodelabelsize = 1.0 ,
@@ -108,9 +118,9 @@ function gplot(g::AbstractGraph{T},
108118 nodestrokec = nothing ,
109119 nodestrokelw = 0.0 ,
110120 arrowlengthfrac = is_directed (g) ? 0.1 : 0.0 ,
111- arrowangleoffset = π / 9.0 ,
121+ arrowangleoffset = π / 9 ,
112122 linetype = " straight" ,
113- outangle = pi / 5 ) where {T <: Integer , R <: Real }
123+ outangle = π / 5 ) where {T <: Integer , R1 <: Real , R2 <: Real }
114124
115125 length (locs_x_in) != length (locs_y_in) && error (" Vectors must be same length" )
116126 N = nv (g)
@@ -231,25 +241,25 @@ end
231241
232242# take from [Gadfly.jl](https://github.com/dcjones/Gadfly.jl)
233243function open_file (filename)
234- if Sys. KERNEL == :Darwin
244+ if Sys. isapple () # apple
235245 run (` open $(filename) ` )
236- elseif Sys. KERNEL == :Linux || Sys. KERNEL == :FreeBSD
246+ elseif Sys. islinux () || Sys. isbsd () # linux
237247 run (` xdg-open $(filename) ` )
238- elseif Sys. KERNEL == :Windows
248+ elseif Sys. iswindows () # windows
239249 run (` $(ENV [" COMSPEC" ]) /c start $(filename) ` )
240250 else
241251 @warn (" Showing plots is not supported on OS $(string (Sys. KERNEL)) " )
242252 end
243253end
244254
245255# taken from [Gadfly.jl](https://github.com/dcjones/Gadfly.jl)
246- function gplothtml (g; layout :: Function = spring_layout, keyargs... )
256+ function gplothtml (args ... ; keyargs... )
247257 filename = string (tempname (), " .html" )
248258 output = open (filename, " w" )
249259
250260 plot_output = IOBuffer ()
251261 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... ))
253263 plotsvg = String (take! (plot_output))
254264
255265 write (output,
0 commit comments