Skip to content

Commit 118b548

Browse files
committed
Simpler toDot tests
So all produce the same output and it is easier to verify. Removed todot from plottingTest.jl
1 parent 1ffbe36 commit 118b548

File tree

4 files changed

+20
-22
lines changed

4 files changed

+20
-22
lines changed

Project.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ julia = "0.7, 1"
2929

3030
[extras]
3131
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
32+
GraphPlot = "a2cc645c-3eea-5389-862e-a155d0052231"
3233

3334
[targets]
34-
test = ["Test"]
35+
test = ["Test", "GraphPlot"]

src/MetaGraphsDFG/services/MetaGraphsDFG.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -533,11 +533,12 @@ function getAdjacencyMatrixSparse(dfg::MetaGraphsDFG)::Tuple{LightGraphs.SparseM
533533
return adjvf, v_labels, f_labels
534534
end
535535

536+
#FIXME remove _ when issue #86 is resolved, for now force dispach to generic toDot
536537
"""
537538
$(SIGNATURES)
538539
Produces a dot-format of the graph for visualization.
539540
"""
540-
function toDot(dfg::MetaGraphsDFG)::String
541+
function _toDot(dfg::MetaGraphsDFG)::String
541542
@error "toDot(dfg::MetaGraphsDFG) is not sopported yet, see https://github.com/JuliaGraphs/MetaGraphs.jl/issues/86"
542543
m = PipeBuffer()
543544
MetaGraphs.savedot(m, dfg.g)
@@ -556,7 +557,7 @@ Note
556557
- Can be viewed with the `xdot` system application.
557558
- Based on graphviz.org
558559
"""
559-
function toDotFile(dfg::MetaGraphsDFG, fileName::String="/tmp/dfg.dot")::Nothing
560+
function _toDotFile(dfg::MetaGraphsDFG, fileName::String="/tmp/dfg.dot")::Nothing
560561
@error "toDotFile(dfg::MetaGraphsDFG,filename) is not supported yet, see https://github.com/JuliaGraphs/MetaGraphs.jl/issues/86"
561562
open(fileName, "w") do fid
562563
MetaGraphs.savedot(fid, dfg.g)

test/interfaceTests.jl

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -285,14 +285,17 @@ end
285285
end
286286

287287
@testset "Producing Dot Files" begin
288-
if testDFGAPI != GraphsDFG
289-
@warn "Skipping non Graphs.jl toDot functions"
290-
@test_skip 1==0#toDot(dfg)
291-
@test_skip 1==0#toDotFile(dfg, "something.dot")
292-
else
293-
@test toDot(dfg) == "graph graphname {\n18 [\"label\"=\"x8x9f1\",\"shape\"=\"ellipse\",\"fillcolor\"=\"blue\",\"color\"=\"blue\"]\n2 [\"label\"=\"x2\",\"shape\"=\"box\",\"fillcolor\"=\"red\",\"color\"=\"red\"]\n2 -- 11\n2 -- 12\n16 [\"label\"=\"x6x7f1\",\"shape\"=\"ellipse\",\"fillcolor\"=\"blue\",\"color\"=\"blue\"]\n11 [\"label\"=\"x1x2f1\",\"shape\"=\"ellipse\",\"fillcolor\"=\"blue\",\"color\"=\"blue\"]\n7 [\"label\"=\"x7\",\"shape\"=\"box\",\"fillcolor\"=\"red\",\"color\"=\"red\"]\n7 -- 16\n7 -- 17\n9 [\"label\"=\"x9\",\"shape\"=\"box\",\"fillcolor\"=\"red\",\"color\"=\"red\"]\n9 -- 18\n9 -- 19\n10 [\"label\"=\"x10\",\"shape\"=\"box\",\"fillcolor\"=\"red\",\"color\"=\"red\"]\n10 -- 19\n19 [\"label\"=\"x9x10f1\",\"shape\"=\"ellipse\",\"fillcolor\"=\"blue\",\"color\"=\"blue\"]\n17 [\"label\"=\"x7x8f1\",\"shape\"=\"ellipse\",\"fillcolor\"=\"blue\",\"color\"=\"blue\"]\n8 [\"label\"=\"x8\",\"shape\"=\"box\",\"fillcolor\"=\"red\",\"color\"=\"red\"]\n8 -- 17\n8 -- 18\n6 [\"label\"=\"x6\",\"shape\"=\"box\",\"fillcolor\"=\"red\",\"color\"=\"red\"]\n6 -- 15\n6 -- 16\n4 [\"label\"=\"x4\",\"shape\"=\"box\",\"fillcolor\"=\"red\",\"color\"=\"red\"]\n4 -- 13\n4 -- 14\n3 [\"label\"=\"x3\",\"shape\"=\"box\",\"fillcolor\"=\"red\",\"color\"=\"red\"]\n3 -- 12\n3 -- 13\n5 [\"label\"=\"x5\",\"shape\"=\"box\",\"fillcolor\"=\"red\",\"color\"=\"red\"]\n5 -- 14\n5 -- 15\n13 [\"label\"=\"x3x4f1\",\"shape\"=\"ellipse\",\"fillcolor\"=\"blue\",\"color\"=\"blue\"]\n14 [\"label\"=\"x4x5f1\",\"shape\"=\"ellipse\",\"fillcolor\"=\"blue\",\"color\"=\"blue\"]\n15 [\"label\"=\"x5x6f1\",\"shape\"=\"ellipse\",\"fillcolor\"=\"blue\",\"color\"=\"blue\"]\n12 [\"label\"=\"x2x3f1\",\"shape\"=\"ellipse\",\"fillcolor\"=\"blue\",\"color\"=\"blue\"]\n1 [\"label\"=\"x1\",\"shape\"=\"box\",\"fillcolor\"=\"red\",\"color\"=\"red\"]\n1 -- 11\n}\n"
288+
# create a simpler graph for dot testing
289+
dotdfg = testDFGAPI{NoSolverParams}()
290+
v1 = DFGVariable(:a)
291+
v2 = DFGVariable(:b)
292+
f1 = DFGFactor{Int, :Symbol}(:f1)
293+
addVariable!(dotdfg, v1)
294+
addVariable!(dotdfg, v2)
295+
addFactor!(dotdfg, [v1, v2], f1)
296+
297+
@test toDot(dotdfg) == "graph graphname {\n2 [\"label\"=\"b\",\"shape\"=\"box\",\"fillcolor\"=\"red\",\"color\"=\"red\"]\n2 -- 3\n3 [\"label\"=\"f1\",\"shape\"=\"ellipse\",\"fillcolor\"=\"blue\",\"color\"=\"blue\"]\n1 [\"label\"=\"a\",\"shape\"=\"box\",\"fillcolor\"=\"red\",\"color\"=\"red\"]\n1 -- 3\n}\n"
298+
@test toDotFile(dotdfg, "something.dot") == nothing
299+
Base.rm("something.dot")
294300

295-
@test toDotFile(dfg, "something.dot") == nothing
296-
Base.rm("something.dot")
297-
end
298301
end

test/plottingTest.jl

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,15 @@
1-
# using GraphPlot
1+
using GraphPlot
22
using DistributedFactorGraphs
3-
using DistributedFactorGraphs.DFGPlots
3+
# using DistributedFactorGraphs.DFGPlots
44
using Test
55

66
# Now make a complex graph for connectivity tests
77
numNodes = 10
88
dfg = GraphsDFG{NoSolverParams}()
99
verts = map(n -> DFGVariable(Symbol("x$n")), 1:numNodes)
10-
#change ready and backendset for x7,x8 for improved tests on x7x8f1
11-
verts[7].ready = 1
12-
verts[8].backendset = 1
1310
map(v -> addVariable!(dfg, v), verts)
1411
map(n -> addFactor!(dfg, [verts[n], verts[n+1]], DFGFactor{Int, :Symbol}(Symbol("x$(n)x$(n+1)f1"))), 1:(numNodes-1))
1512

16-
# Using toDot
17-
dot = toDot(dfg)
18-
@test dot != nothing
19-
20-
# Using GraphViz plotting
13+
# Using GraphPlot plotting
2114
plot = dfgplot(dfg)
2215
@test plot != nothing

0 commit comments

Comments
 (0)