Skip to content

Commit 6f76b68

Browse files
committed
Abstract interface for todot.
Tests left as broken since order is changed
1 parent af19735 commit 6f76b68

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

src/services/AbstractDFG.jl

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,3 +182,39 @@ end
182182
Display and return to console the user factor identified by tag name.
183183
"""
184184
showFactor(fgl::G, fsym::Symbol) where G <: AbstractDFG = @show getFactor(fgl,fsym)
185+
186+
187+
"""
188+
$(SIGNATURES)
189+
Produces a dot-format of the graph for visualization.
190+
"""
191+
function toDot(dfg::AbstractDFG)::String
192+
@warn "Falling Back to convert to GraphsDFG"
193+
#TODO implement convert
194+
graphsdfg = GraphsDFG{AbstractParams}()
195+
DistributedFactorGraphs._copyIntoGraph!(dfg, graphsdfg, union(getVariableIds(dfg), getFactorIds(dfg)), true)
196+
197+
return toDot(graphsdfg)
198+
end
199+
200+
"""
201+
$(SIGNATURES)
202+
Produces a dot file of the graph for visualization.
203+
Download XDot to see the data
204+
205+
Note
206+
- Default location "/tmp/dfg.dot" -- MIGHT BE REMOVED
207+
- Can be viewed with the `xdot` system application.
208+
- Based on graphviz.org
209+
"""
210+
function toDotFile(dfg::AbstractDFG, fileName::String="/tmp/dfg.dot")::Nothing
211+
@warn "Falling Back to convert to GraphsDFG"
212+
#TODO implement convert
213+
graphsdfg = GraphsDFG{AbstractParams}()
214+
DistributedFactorGraphs._copyIntoGraph!(dfg, graphsdfg, union(getVariableIds(dfg), getFactorIds(dfg)), true)
215+
216+
open(fileName, "w") do fid
217+
write(fid,Graphs.to_dot(graphsdfg.g))
218+
end
219+
return nothing
220+
end

0 commit comments

Comments
 (0)