diff --git a/src/graphics/GraphvizCategories.jl b/src/graphics/GraphvizCategories.jl index d78b1d12b..bea2c06ee 100644 --- a/src/graphics/GraphvizCategories.jl +++ b/src/graphics/GraphvizCategories.jl @@ -93,7 +93,7 @@ function to_graphviz_property_graph(d::Diagram; kw...) pg = to_graphviz_property_graph(g; kw...) for v in vertices(g) tᵥ = ob_map(d, v) - labels = has_vertex_names(g) ? [tᵥ] : [vertex_name(g,v), tᵥ] + labels = has_vertex_names(g) ? [vertex_name(g,v), tᵥ] : [tᵥ] set_vprop!(pg, v, :label, join(labels, ":")) end for e in edges(g) diff --git a/test/graphics/GraphvizCategories.jl b/test/graphics/GraphvizCategories.jl index 11cd6dbb4..872e32ee6 100644 --- a/test/graphics/GraphvizCategories.jl +++ b/test/graphics/GraphvizCategories.jl @@ -69,4 +69,39 @@ gv = to_graphviz(f) @test length(stmts(gv, Graphviz.Subgraph)) == 2 @test length(stmts(gv, Graphviz.Edge)) == 4 +# Diagrams +########## + +# Diagram with anonymous objects in J +C = FinCat(@acset Graph begin + V = 3 + E = 2 + src = [1,2] + tgt = [3,3] +end) +D = FinDomFunctor([:E,:E,:V], [:tgt,:src], C, FinCat(SchSymmetricGraph)) +d = Diagram{id}(D) + +gv = to_graphviz(d, node_labels=true) + +@test stmts(gv, Graphviz.Node, :label) == ["E","E","V"] +@test stmts(gv, Graphviz.Edge, :label) == ["tgt","src"] + +# Diagram with named objects in J +C = FinCat(@acset NamedGraph{Symbol,Symbol} begin + V = 3 + E = 2 + src = [1,2] + tgt = [3,3] + vname = [:e1,:e2,:v] + ename = [:t,:s] +end) +D = FinDomFunctor([:E,:E,:V], [:tgt,:src], C, FinCat(SchSymmetricGraph)) +d = Diagram{id}(D) + +gv = to_graphviz(d, node_labels=true) + +@test stmts(gv, Graphviz.Node, :label) == ["e1:E","e2:E","v:V"] +@test stmts(gv, Graphviz.Edge, :label) == ["tgt","src"] + end