@@ -5,36 +5,32 @@ module TikzGraphs
5
5
export plot, Layouts
6
6
import LightGraphs: DiGraph, Graph, vertices, edges, src, dst
7
7
8
- using Compat
9
- import Compat. String
10
-
11
- preamble = readstring (joinpath (dirname (@__FILE__ ), " .." , " src" , " preamble.tex" ))
8
+ preamble = read (joinpath (dirname (@__FILE__ ), " .." , " src" , " preamble.tex" ), String)
12
9
13
10
const AbstractGraph = Union{Graph, DiGraph}
14
11
15
12
using TikzPictures
16
13
17
14
module Layouts
18
- using Compat
19
15
export Layered, Spring, SimpleNecklace
20
16
21
- @compat abstract type Layout end
17
+ abstract type Layout end
22
18
23
- immutable Layered <: Layout end
19
+ struct Layered <: Layout end
24
20
25
- immutable Spring <: Layout
21
+ struct Spring <: Layout
26
22
randomSeed
27
23
Spring (;randomSeed= 42 ) = new (randomSeed)
28
24
end
29
25
30
- immutable SimpleNecklace <: Layout
26
+ struct SimpleNecklace <: Layout
31
27
end
32
28
end
33
29
34
30
using . Layouts
35
31
36
- plot {T<:AbstractString} (g, layout:: Layouts.Layout , labels:: Vector{T} = map (string, vertices (g)); args... ) = plot (g; layout= layout, labels= labels, args... )
37
- plot {T<:AbstractString} (g, labels:: Vector{T} ; args... ) = plot (g; layout= Layered (), labels= labels, args... )
32
+ plot (g, layout:: Layouts.Layout , labels:: Vector{T} = map (string, vertices (g)); args... ) where {T <: AbstractString } = plot (g; layout= layout, labels= labels, args... )
33
+ plot (g, labels:: Vector{T} ; args... ) where {T <: AbstractString } = plot (g; layout= Layered (), labels= labels, args... )
38
34
39
35
function edgeHelper (o:: IOBuffer , a, b, edge_labels, edge_styles, edge_style)
40
36
print (o, " [$(edge_style) ," )
59
55
edge_str (g:: DiGraph ) = " ->"
60
56
edge_str (g:: Graph ) = " --"
61
57
62
- function plot {T<:AbstractString} (g:: AbstractGraph ; layout:: Layouts.Layout = Layered (), labels:: Vector{T} = map (string, vertices (g)), edge_labels:: Dict = Dict (), node_styles:: Dict = Dict (), node_style= " " , edge_styles:: Dict = Dict (), edge_style= " " , options= " " )
58
+ function plot (g:: AbstractGraph ; layout:: Layouts.Layout = Layered (), labels:: Vector{T} = map (string, vertices (g)), edge_labels:: Dict = Dict (), node_styles:: Dict = Dict (), node_style= " " , edge_styles:: Dict = Dict (), edge_style= " " , options= " " ) where T <: AbstractString
63
59
o = IOBuffer ()
64
60
println (o, " \\ graph [$(layoutname (layout)) , $(options_str (layout)) ] {" )
65
61
for v in vertices (g)
0 commit comments