2
$\begingroup$

In GAP when we draw a cayley graph of a group using "CayleyGraph" command we get a list. Is there a way to visualize that cayley graph like a figure?

Or else is there any other software that has the ability to visualize?

$\endgroup$
2
  • 1
    $\begingroup$ There is a graphical package called XGAP. I am not sure that there is a specific comment for drawing a Cayley graph. $\endgroup$ Oct 2, 2018 at 8:24
  • 1
    $\begingroup$ xgap (nor Gap.app) doesn't draw Cayley graphs "out of the box". An interested person with some programming experience could probably add such functionality (perhaps using Alexander's code to get started) without too much trouble. $\endgroup$ Oct 4, 2018 at 20:55

2 Answers 2

6
$\begingroup$

A standard tool for visualizing graphs is the graphviz software. The following GAP program

# usage: PrintCayleyGraph(filename,group[,generatornames]);
PrintCayleyGraph:=function(arg)
local f,g,gens,ngens,epi,r,nams,nnams,vert,kind,p,i,j,e,ed;
  f:=arg[1];
  g:=arg[2];
  gens:=GeneratorsOfGroup(g);
  r:=Length(gens);
  if Length(arg)>2 then
    nams:=arg[3];
  else
    nams:=List([1..r],x->CHARS_LALPHA{[x]});
  fi;
  ngens:=[];
  nnams:=[];
  kind:=[]; # what kind of arrow
  for i in [1..r] do
    if Order(gens[i])=2 then
      kind[i]:=2;
      Add(ngens,gens[i]);
      Add(nnams,nams[i]);
    else
      p:=Position(gens,gens[i]^-1);
      if p<i then
        kind[i]:=-p;
      else
        kind[i]:=1;
        Add(ngens,gens[i]);
        Add(nnams,nams[i]);
      fi;
    fi;
  od;
  gens:=ngens;
  g:=GroupWithGenerators(gens);
  epi:=EpimorphismFromFreeGroup(g:names:=nnams);
  PrintTo(f,"digraph cayley {\nsize = \"6,6\";\n");
  e:=Elements(g);
  e:=ShallowCopy(e);
  if IsPermGroup(g) then
    SortBy(e,x->1^x);
  fi;
  vert:=List([1..Length(e)],x->Concatenation("\"v",String(x),"\""));
  for i in [1..Length(e)] do
    if IsOne(e[i]) then
      p:="1";
    else
      p:=String(Factorization(g,e[i]));
    fi;
    AppendTo(f,vert[i]," [label=\"",i,":",p,"\"\];\n");
  od;
  ed:=[];
  for i in [1..Length(e)] do
    for j in [1..Length(gens)] do
      p:=Position(e,e[i]*gens[j]);
      if kind[j]=1 then
        Add(ed,[Set([i,p]),i,p,Concatenation("[label=\"",nams[j],"\"];\n")]);
      elif kind[j]=2 and p>i then
        Add(ed,[Set([i,p]),i,p,
        Concatenation("[label=\"",nams[j],"\",arrowhead=none];\n")]);
      fi;
    od;
  od;
  Sort(ed); # to try to get same shape
  for i in ed do
    AppendTo(f,"  ",vert[i[2]]," -> ",vert[i[3]],i[4]);
  od;

  AppendTo(f,"}\n");
end;

takes a group, and prints out its cayley graph in this format. For example,

gap> g:=Group((1,2,3,4),(1,3));;
gap> PrintCayleyGraph("d8cay.dot",g,["a","b"]);

produces a file d8cay.dot that when read processed by graphviz produces a picture like (here I used the program OmniGraffle (Mac only) to rearrange vertices and add shadow) the following. enter image description here

$\endgroup$
4
$\begingroup$

I'm working on a GAP package to do just what you're talking about in the context of Jupyter notebooks. The package is in its early phases, but it can already produce a bunch of different kinds of visualizations. Repository:

https://github.com/nathancarter/jupyter-viz

I'm glad to talk by email and answer further questions.

$\endgroup$
7
  • $\begingroup$ Ok, thank you very much. I will check it and ask my further questions through email. $\endgroup$ Oct 3, 2018 at 16:25
  • $\begingroup$ And thank you very much again for everyone helped. $\endgroup$ Oct 3, 2018 at 16:26
  • $\begingroup$ @BuddhiniAngelika we can also try to set up this package available via mybinder, or via Docker for Windows users (the JupyterKernel package for GAP is not usable on Windows yet). $\endgroup$ Oct 3, 2018 at 21:29
  • $\begingroup$ Thanks Alexander Konovalov. I got an opportunity to have a different operating system installed. So can you please mention the version of MacOs or Linux you'll are using? I will also get the same so that I'll be able to execute the previous programs too successfully.(hopefully if I get the opportunity as I'm thinking). $\endgroup$ Oct 4, 2018 at 16:28
  • 1
    $\begingroup$ Please use @username to ping me (see meta.stackexchange.com/questions/43019/…) - otherwise I will see this only if I will revisit the question, and that's not guaranteed. GAP works on all recent macOS (except that we haven't heard yet from most recent macOC mojave released a couple of weeks ago, but I expect that even if there will be any problems, they will be resolved). It works on all post popular Linux distributions - Ubuntu, Debian, etc. - choose one who which you have a better support locally. $\endgroup$ Oct 14, 2018 at 13:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.