using Catlab.WiringDiagrams, Catlab.Graphics using Catlab.Theories A, B = Ob(FreeSymmetricMonoidalCategory, :A, :B) f = Hom(:f, A, B) g = Hom(:g, B, A) h = Hom(:h, otimes(A,B), otimes(A,B)); to_graphviz(f) to_graphviz(compose(f,g)) to_graphviz(otimes(f,g)) to_graphviz(compose(braid(A,A), otimes(f,f), braid(B,B))) composite = compose(otimes(g,f), h, otimes(f,g)) to_graphviz(composite) to_graphviz(composite, orientation=LeftToRight) to_graphviz(composite, orientation=BottomToTop) to_graphviz(composite, outer_ports=false) A, B = Ob(FreeBiproductCategory, :A, :B) f = Hom(:f, A, B) g = Hom(:g, B, A); f1 = compose(mcopy(A), otimes(f,f)) to_graphviz(f1) f2 = compose(mcopy(A), otimes(f,f), mmerge(B)) to_graphviz(f2) to_graphviz(add_junctions!(to_wiring_diagram(f1))) to_graphviz(add_junctions!(to_wiring_diagram(f2))) A, B, X, Y = Ob(FreeTracedMonoidalCategory, :A, :B, :X, :Y) f = Hom(:f, otimes(X,A), otimes(X,B)) to_graphviz(trace(X, A, B, f)) to_graphviz(trace(X, A, B, f), orientation=LeftToRight) g, h = Hom(:g, A, A), Hom(:h, B, B) trace_naturality = trace(X, A, B, compose(otimes(id(X),g), f, otimes(id(X),h))) to_graphviz(trace_naturality, orientation=LeftToRight) using Catlab.Programs: @relation diagram = @relation (x,z) where (x,y,z) begin R(x,y) S(y,z) end to_graphviz(diagram, box_labels=:name) diagram = @relation (x,y,z) where (w,x,y,z) begin R(x,w) S(y,w) T(z,w) end to_graphviz(diagram, box_labels=:name) to_graphviz(diagram, box_labels=:name, port_labels=false, junction_labels=:variable) to_graphviz(diagram, box_labels=:name, port_labels=false, implicit_junctions=true) A, B, C = Ob(FreeSymmetricMonoidalCategory, :A, :B, :C) f, g = Hom(:f, A, B), Hom(:g, B, C) to_graphviz(compose(f,g), labels = true, label_attr=:headlabel, node_attrs = Dict( :fontname => "Courier", ), edge_attrs = Dict( :fontname => "Courier", :labelangle => "25", :labeldistance => "2", ), cell_attrs = Dict( :bgcolor => "lavender", ) ) using Catlab.Graphics: Graphviz graph = to_graphviz(compose(f,g)) Graphviz.pprint(graph) import JSON3 JSON3.read(Graphviz.run_graphviz(graph, format="json0"))