Skip to content

Commit 1cc29c8

Browse files
author
Jose Storopoli
committed
Implement changes from #24
1 parent c469cc6 commit 1cc29c8

File tree

3 files changed

+10
-13
lines changed

3 files changed

+10
-13
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ SimpleTraits = "699a6c99-e7fa-54fc-8d76-47d257e15c1d"
1111
[compat]
1212
EzXML = "1"
1313
Graphs = "1.4"
14-
ParserCombinator = "2"
14+
ParserCombinator = "2.1"
1515
Requires = "1"
1616
SimpleTraits = "0.9"
1717
julia = "1"

src/DOT/Dot.jl

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,27 +58,24 @@ function _dot_read_one_graph(pg::Parsers.DOT.Graph)
5858
return g
5959
end
6060

61+
_name(pg::Parsers.DOT.Graph) =
62+
pg.id !== nothing ? pg.id.id :
63+
Parsers.DOT.StringID(pg.directed ? "digraph" : "graph")
64+
6165
function loaddot(io::IO, gname::String)
6266
p = Parsers.DOT.parse_dot(read(io, String))
6367
for pg in p
64-
isdir = pg.directed
65-
possname = isdir ? Parsers.DOT.StringID("digraph") : Parsers.DOT.StringID("graph")
66-
name = get(pg.id, possname).id
67-
name == gname && return _dot_read_one_graph(pg)
68+
_name(pg) == gname && return _dot_read_one_graph(pg)
6869
end
6970
error("Graph $gname not found")
7071
end
7172

7273
function loaddot_mult(io::IO)
7374
p = Parsers.DOT.parse_dot(read(io, String))
74-
7575
graphs = Dict{String,AbstractGraph}()
7676

7777
for pg in p
78-
isdir = pg.directed
79-
possname = isdir ? Parsers.DOT.StringID("digraph") : Parsers.DOT.StringID("graph")
80-
name = get(pg.id, possname).id
81-
graphs[name] = _dot_read_one_graph(pg)
78+
graphs[_name(pg)] = _dot_read_one_graph(pg)
8279
end
8380
return graphs
8481
end

test/graphio.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ function gettempname()
1919
(f, fio) = mktemp()
2020
close(fio)
2121
return f
22-
end
23-
22+
end
23+
2424
function read_test(format::Graphs.AbstractGraphFormat, g::Graphs.AbstractGraph, gname::String="g",
2525
fname::AbstractString=""; testfail=false)
2626
@test loadgraph(fname, gname, format) == g
@@ -33,7 +33,7 @@ end
3333
function read_test_mult(format::Graphs.AbstractGraphFormat, d::Dict{String,G}, fname::AbstractString="") where G<: AbstractGraph
3434
rd = loadgraphs(fname, format)
3535
@test rd == d
36-
36+
3737
end
3838

3939
function write_test(format::Graphs.AbstractGraphFormat, g::Graphs.AbstractGraph, gname::String="g",

0 commit comments

Comments
 (0)