Skip to content

Commit

Permalink
fix invis_edges forwarding and add tests to cover graphviz for finite…
Browse files Browse the repository at this point in the history
… sets
  • Loading branch information
slwu89 committed Mar 6, 2024
1 parent 2cbb770 commit a212604
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/graphics/GraphvizGraphs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,8 @@ A simple default style is applied. For more control over the visual appearance,
first convert the graph to a property graph, define the Graphviz attributes as
needed, and finally convert the property graph to a Graphviz graph.
"""
function to_graphviz(g::HasBipartiteVertices; kw...)
to_graphviz(to_graphviz_property_graph(g); kw...)
function to_graphviz(g::HasBipartiteVertices; invis_edges::Bool=true, kw...)
to_graphviz(to_graphviz_property_graph(g; kw...); invis_edges)
end

function to_graphviz_property_graph(g::AbstractBipartiteGraph;
Expand Down
17 changes: 17 additions & 0 deletions test/graphics/GraphvizGraphs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -234,4 +234,21 @@ gv = to_graphviz(f, draw_codom=true)
@test gv.directed
@test length(stmts(gv, Graphviz.Subgraph)) == 2

# Functions between finite sets
###############################

A = FinSet(4)
B = FinSet(3)
f = FinFunction([1,3,2,2], A, B)

fv = to_graphviz(f, graph_attrs=Dict(:splines=>"false"))
@test length(stmts(fv, Graphviz.Subgraph)) == 2
fv1, fv2 = stmts(fv, Graphviz.Subgraph)

@test length(stmts(fv1, Graphviz.Edge)) == length(A) - 1
@test length(stmts(fv2, Graphviz.Edge)) == length(B) - 1
@test length(stmts(fv, Graphviz.Edge)) == 4
@test length(stmts(fv1, Graphviz.Node)) == length(A)
@test length(stmts(fv2, Graphviz.Node)) == length(B)

end

0 comments on commit a212604

Please sign in to comment.