Skip to content
This repository has been archived by the owner on Oct 21, 2021. It is now read-only.

Add .dot rendering of vertex attributes #183

Closed
wants to merge 8 commits into from
5 changes: 4 additions & 1 deletion src/dot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,16 @@ function to_dot(graph::AbstractGraph, attrs::AttributeDict=AttributeDict())
end

# Write the dot representation of a graph to a stream.
function to_dot{G<:AbstractGraph}(graph::G, stream::IO,attrs::AttributeDict)
function to_dot{G<:AbstractGraph}(graph::G, stream::IO,attrs::AttributeDict=AttributeDict())
has_vertex_attrs = method_exists(attributes, (vertex_type(graph), G))
has_edge_attrs = method_exists(attributes, (edge_type(graph), G))

write(stream, "$(graph_type_string(graph)) graphname {\n")
write(stream, "$(to_dot_graph(attrs))")
if implements_edge_list(graph) && implements_vertex_map(graph)
for vtx in vertices(graph)
write(stream,"$(vertex_index(vtx,graph))\t$(to_dot(attributes(vtx,graph)))\n")
end
for edge in edges(graph)
write(stream,"$(vertex_index(source(edge), graph)) $(edge_op(graph)) $(vertex_index(target(edge), graph))\n")
end
Expand Down
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ tests = [


for t in tests
tp = joinpath(Pkg.dir("Graphs"),"test","$(t).jl")
tp = joinpath(dirname(@__FILE__), "$(t).jl")
println("running $(tp) ...")
include(tp)
end