Skip to content

Commit 5c98f33

Browse files
authored
Merge pull request #62 from Paalon/master
Add double quotations for labels for savedot
2 parents 063399b + a650dc0 commit 5c98f33

File tree

4 files changed

+59
-7
lines changed

4 files changed

+59
-7
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "MetaGraphsNext"
22
uuid = "fa8bd995-216d-47f1-8a91-f3b68fbeb377"
3-
version = "0.5.0"
3+
version = "0.6.0-DEV"
44

55
[deps]
66
Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"

src/MetaGraphsNext.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
22
MetaGraphsNext
33
4-
A package for graphs with vertex labels and metadata in Julia. Its main export is the [`MetaGraph`](@ref) type.
4+
A package for graphs with vertex labels and metadata in Julia. Its main export is the `MetaGraph` type.
55
"""
66
module MetaGraphsNext
77

src/persistence.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,18 +70,24 @@ function savedot(io::IO, meta_graph::MetaGraph)
7070

7171
for label in keys(meta_graph.vertex_properties)
7272
write(io, " ")
73+
write(io, '"')
7374
write(io, label)
75+
write(io, '"')
7476
show_meta_list(io, meta_graph[label])
7577
write(io, '\n')
7678
end
7779

7880
for (label_1, label_2) in keys(edge_data)
7981
write(io, " ")
82+
write(io, '"')
8083
write(io, label_1)
84+
write(io, '"')
8185
write(io, ' ')
8286
write(io, dash)
8387
write(io, ' ')
88+
write(io, '"')
8489
write(io, label_2)
90+
write(io, '"')
8591
show_meta_list(io, edge_data[arrange(meta_graph, label_1, label_2)])
8692
write(io, "\n")
8793
end

test/tutorial/3_files.jl

Lines changed: 51 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,16 @@ simple_str = mktemp() do file, io
3434
read(file, String)
3535
end
3636

37-
print(simple_str) #md
38-
@test simple_str == "graph T {\n a\n b\n a -- b\n}\n" #src
37+
simple_str_true = """
38+
graph T {
39+
"a"
40+
"b"
41+
"a" -- "b"
42+
}
43+
"""
44+
45+
simple_str == simple_str_true
46+
@test simple_str == simple_str_true #src
3947

4048
#-
4149

@@ -58,6 +66,44 @@ complicated_str = mktemp() do file, io
5866
read(file, String)
5967
end
6068

61-
print(complicated_str) #md
62-
@test complicated_str == #src
63-
"digraph G {\n tagged = true\n a [code_1 = 1, code_2 = 2]\n b [code = 2]\n a -> b [code = 12]\n}\n" #src
69+
complicated_str_true = """
70+
digraph G {
71+
tagged = true
72+
"a" [code_1 = 1, code_2 = 2]
73+
"b" [code = 2]
74+
"a" -> "b" [code = 12]
75+
}
76+
"""
77+
78+
@test complicated_str == complicated_str_true #src
79+
80+
#-
81+
82+
with_spaces = MetaGraph(
83+
DiGraph();
84+
label_type=String,
85+
vertex_data_type=Dict{Symbol,String},
86+
edge_data_type=Dict{Symbol,String},
87+
)
88+
89+
with_spaces["a b"] = Dict(:label => "A B")
90+
91+
with_spaces["c d"] = Dict(:label => "C D")
92+
93+
with_spaces["a b", "c d"] = Dict(:label => "A B to C D")
94+
95+
with_spaces_str = mktemp() do file, io
96+
savegraph(file, with_spaces, DOTFormat())
97+
read(file, String)
98+
end
99+
100+
with_spaces_str_true = """
101+
digraph G {
102+
"a b" [label = "A B"]
103+
"c d" [label = "C D"]
104+
"a b" -> "c d" [label = "A B to C D"]
105+
}
106+
"""
107+
108+
with_spaces_str == with_spaces_str_true
109+
@test with_spaces_str == with_spaces_str_true #src

0 commit comments

Comments
 (0)