semigroups / Semigroups

The GAP package Semigroups
https://semigroups.github.io/Semigroups/
Other
23 stars 35 forks source link

Better dot #1007

Open james-d-mitchell opened 5 months ago

james-d-mitchell commented 5 months ago

This is just a proof of concept, not intended to be merged just yet.

james-d-mitchell commented 3 months ago

This will probably fail until both:

https://github.com/digraphs/graphviz/pull/21

and

https://github.com/digraphs/Digraphs/pull/644

are merged.

james-d-mitchell commented 3 months ago

Here's a badly edited bug that currently exists in this PR and should be fixed before merging:

gap> F := FreeMonoid("c", "d");
<free monoid on the generators [ c, d ]>
gap> AssignGeneratorVariables(F);
#I  Assigned the global variables [ c, d ]
gap> R := ParseRelations([c, d], "c^2=c, dc=d, cd^2=d^2, d^5=d^2");
[ [ c^2, c ], [ d*c, d ], [ c*d^2, d^2 ], [ d^5, d^2 ] ]
gap> S := F / R;
<fp monoid with 2 generators and 4 relations of length 20>
gap> Splash(DotLeftCayleyDigraph(S));
#I  Using GeneratorsOfMonoid not GeneratorsOfSemigroup for the Cayley graph
gap> AsSemigroup(S);
<fp monoid with 2 generators and 4 relations of length 20>
gap> AsSemigroup(IsFpSemigroup, S);
<fp semigroup with 3 generators and 9 relations of length 36>
gap> Splash(DotLeftCayleyDigraph(S));
#I  Using GeneratorsOfMonoid not GeneratorsOfSemigroup for the Cayley graph
gap> S := last2;
<fp monoid with 2 generators and 4 relations of length 20>
gap> Splash(DotLeftCayleyDigraph(S));
#I  Using GeneratorsOfMonoid not GeneratorsOfSemigroup for the Cayley graph
gap> S := last2;
<fp semigroup with 3 generators and 9 relations of length 36>
gap> Splash(DotLeftCayleyDigraph(S));
Error: not well-formed (invalid token) in line 2
... <td align="right" port="port1"><identity ...> ...
gap> Print(DotLeftCayleyDigraph(S))
> ;
//dot
digraph hgn {
    node [shape=circle] node [shape="box"]
    1 [color="#00ff00", label="<identity ...>", style=filled]
    2 [color="#ff00ff", label=c, style=filled]
    3 [color="#007fff", label=d, style=filled]
    4 [label=cd]
    5 [label="d^2"]
    6 [label="d^3"]
    7 [label="d^4"]
    1 -> 1 [color="#00ff00"]
    1 -> 2 [color="#ff00ff"]
    1 -> 3 [color="#007fff"]
    2 -> 2 [color="#00ff00"]
    2 -> 2 [color="#ff00ff"]
    2 -> 3 [color="#007fff"]
    3 -> 3 [color="#00ff00"]
    3 -> 4 [color="#ff00ff"]
    3 -> 5 [color="#007fff"]
    4 -> 4 [color="#00ff00"]
    4 -> 4 [color="#ff00ff"]
    4 -> 5 [color="#007fff"]
    5 -> 5 [color="#00ff00"]
    5 -> 5 [color="#ff00ff"]
    5 -> 6 [color="#007fff"]
    6 -> 6 [color="#00ff00"]
    6 -> 6 [color="#ff00ff"]
    6 -> 7 [color="#007fff"]
    7 -> 7 [color="#00ff00"]
    7 -> 7 [color="#ff00ff"]
    7 -> 5 [color="#007fff"]
// legend context
    node [shape=plaintext]
subgraph legend {
    head [label=<<table border="0" cellpadding="2" cellspacing="0" cellborder="0">
<tr><td align="right" port="port1"><identity ...>&nbsp;</td></tr>
<tr><td align="right" port="port2">c&nbsp;</td></tr>
<tr><td align="right" port="port3">d&nbsp;</td></tr>
</table>>
]
    tail [label=<<table border="0" cellpadding="2" cellspacing="0" cellborder="0">
<tr><td align="right" port="port1">&nbsp;</td></tr>
<tr><td align="right" port="port2">&nbsp;</td></tr>
<tr><td align="right" port="port3">&nbsp;</td></tr>
</table>>
]
    head:port1:e
    tail:port1:w
    head:port1:e -> tail:port1:w [color="#00ff00", constraint=false]
    head:port2:e
    tail:port2:w
    head:port2:e -> tail:port2:w [color="#ff00ff", constraint=false]
    head:port3:e
    tail:port3:w
    head:port3:e -> tail:port3:w [color="#007fff", constraint=false]
}
    node [shape=circle] node [shape="box"]

}