diff --git a/Project.toml b/Project.toml index eabf91f..6755835 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "MetaGraphsNext" uuid = "fa8bd995-216d-47f1-8a91-f3b68fbeb377" -version = "0.5.0" +version = "0.6.0-DEV" [deps] Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6" diff --git a/src/MetaGraphsNext.jl b/src/MetaGraphsNext.jl index a23271b..a0998e7 100644 --- a/src/MetaGraphsNext.jl +++ b/src/MetaGraphsNext.jl @@ -1,7 +1,7 @@ """ MetaGraphsNext -A package for graphs with vertex labels and metadata in Julia. Its main export is the [`MetaGraph`](@ref) type. +A package for graphs with vertex labels and metadata in Julia. Its main export is the `MetaGraph` type. """ module MetaGraphsNext diff --git a/src/persistence.jl b/src/persistence.jl index 7bb6bd3..cf7fd8e 100644 --- a/src/persistence.jl +++ b/src/persistence.jl @@ -70,18 +70,24 @@ function savedot(io::IO, meta_graph::MetaGraph) for label in keys(meta_graph.vertex_properties) write(io, " ") + write(io, '"') write(io, label) + write(io, '"') show_meta_list(io, meta_graph[label]) write(io, '\n') end for (label_1, label_2) in keys(edge_data) write(io, " ") + write(io, '"') write(io, label_1) + write(io, '"') write(io, ' ') write(io, dash) write(io, ' ') + write(io, '"') write(io, label_2) + write(io, '"') show_meta_list(io, edge_data[arrange(meta_graph, label_1, label_2)]) write(io, "\n") end diff --git a/test/tutorial/3_files.jl b/test/tutorial/3_files.jl index f5372d5..f4442f7 100644 --- a/test/tutorial/3_files.jl +++ b/test/tutorial/3_files.jl @@ -34,8 +34,16 @@ simple_str = mktemp() do file, io read(file, String) end -print(simple_str) #md -@test simple_str == "graph T {\n a\n b\n a -- b\n}\n" #src +simple_str_true = """ +graph T { + "a" + "b" + "a" -- "b" +} +""" + +simple_str == simple_str_true +@test simple_str == simple_str_true #src #- @@ -58,6 +66,44 @@ complicated_str = mktemp() do file, io read(file, String) end -print(complicated_str) #md -@test complicated_str == #src - "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 +complicated_str_true = """ +digraph G { + tagged = true + "a" [code_1 = 1, code_2 = 2] + "b" [code = 2] + "a" -> "b" [code = 12] +} +""" + +@test complicated_str == complicated_str_true #src + +#- + +with_spaces = MetaGraph( + DiGraph(); + label_type=String, + vertex_data_type=Dict{Symbol,String}, + edge_data_type=Dict{Symbol,String}, +) + +with_spaces["a b"] = Dict(:label => "A B") + +with_spaces["c d"] = Dict(:label => "C D") + +with_spaces["a b", "c d"] = Dict(:label => "A B to C D") + +with_spaces_str = mktemp() do file, io + savegraph(file, with_spaces, DOTFormat()) + read(file, String) +end + +with_spaces_str_true = """ +digraph G { + "a b" [label = "A B"] + "c d" [label = "C D"] + "a b" -> "c d" [label = "A B to C D"] +} +""" + +with_spaces_str == with_spaces_str_true +@test with_spaces_str == with_spaces_str_true #src