AlgebraicJulia / Catlab.jl

A framework for applied category theory in the Julia language
https://www.algebraicjulia.org
MIT License
614 stars 58 forks source link

Reformat Tuple node labels in Graphviz graphs #731

Closed slwu89 closed 1 year ago

slwu89 commented 1 year ago

This is a very small PR that just lets to_graphviz work with node_labels using labels that are Tuples. The reason this is useful is that some operations can change the types of labels on the resulting object. For example, taking the product of a LabeledGraph{Symbol} and LabeledGraph{String} results in a new label of type Tuple{Symbol, String}. This just makes the internal functions in the GraphvizGraphs module break those tuples down into a string for plotting, it's mostly useful for pedagogy.

github-actions[bot] commented 1 year ago

Review Checklist

Does this PR follow the development guidelines? Following is a partial checklist:

Tests

Documentation

Other

slwu89 commented 1 year ago

Thanks Sean! I'm little leery of changing the display of standard Julia types, as it might seem arbitrary or unexpected to some users, but I can see the appeal when the attribute types come from product operations. So I'm inclined to go ahead with this, but for consistency, whatever transformation is applied to the node labels should also be applied to the edge labels, since edge attributes can just as easily be involved in products.

Thanks for pointing out that missing element @epatters! It's now applied to the edge labels as well with a test.