-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug fix and tests for to_graphviz
with Diagram
objects
#850
Conversation
43691d6
to
7683928
Compare
@epatters I've rebased this after #858. Before I request a review, I have a question. As part of this, I am trying to extend the However, I cannot figure out why when I uncomment this line to import the method https://github.com/slwu89/Catlab.jl/blob/graphviz-diagram/src/graphs/NamedGraphs.jl#L14, Julia complains with the error |
The reason is that CategoricalAlgebra is loaded in Catlab after Graphs, i.e., CategoricalAlgebra depends on Graphs, not the other around. So any interoperability layer between the two should go in CategoricalAlgebra. In fact, I think the function you are looking for is already available on main: https://github.com/slwu89/Catlab.jl/blob/54b8e25ef13a7e125f36e687f02c58b9f1646cd1/src/categorical_algebra/FinCats.jl#L113 |
Ah, thanks @epatters for clearing that up! Yes I did see that julia> graph(SchWeightedGraph)
ERROR: MethodError: no method matching graph(::Presentation{ThSchema, Symbol}) But I think that should wait for another PR and this one should just get those tests for visualizing a diagram in. |
IIRC, you can just wrap the Presentation in a FinCat, i.e., call |
to_graphviz
for diagrams with anonymous objectsto_graphviz
with Diagram
objects
to_graphviz
with Diagram
objectsto_graphviz
with Diagram
objects
to_graphviz
with Diagram
objectsto_graphviz
with Diagram
objects
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks Sean!
@@ -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ᵥ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haha, this is why it's good to have tests. Thanks!
The method
to_graphviz_property_graph(d::Diagram; kw...)
would previous fail if given a diagram with anonymous ob/homs in the indexing category. It now checks if the graph associated to the indexing category is aNamedGraph
, if so it will use the names invname
, and otherwise empty names are used. This PR also adds tests for both the named and anonymous case, as it seemsto_graphviz
for diagrams was not previously being tested.