I've been using XGAP to view the subgroup lattices of various groups, and I am interested in their properties as simple graphs. I need a program that, given a group G, can output the subgroup lattice of G as a simple graph; that is, as a set V of vertices and a set E of edges.

Does such a function exist?

I have looked into GRAPE and DIGRAPH to no avail.


You might look at DotFileLatticeSubgroups, which outputs the subgroup lattice to a dot file visualizable by GraphViz. It'd be easy to modify this (or alternatively, to postprocess its output) to get a list of vertices and edges. I agree that it'd be nice to have a clean way to get a list of edges out of a subgroup lattice sheet. Perhaps something under the Poset menu?

PS: You mention xgap. If you have a Mac handy, you might enjoy my slightly more modern take, Gap.app

UPDATE: I wrote a function that will take a GraphicSubgroupLattice and return a list of edges of the represented Hasse diagram. To use it, type
then get the subgroups you'd like to look at in the Hasse diagram (e.g. by doing Subgroups | All Subgroups), then type
I expect that it will also work with other poset objects in xgap/Gap.app, but have not tested it.

The function follows.

  local Gr, lev, cl, H, M;


  for lev in L!.levels do
    for cl in lev!.classes do
      for H in cl do
        for M in H!.maximals do
          AddSet(Gr, [M!.label, H!.label]);
  return Gr;
  • 1
    $\begingroup$ One of the packages DIGRAPH, GRAPE, YAGS specialising in graphs might be able to construct a graph starting from a dot file. $\endgroup$ Sep 8 '20 at 11:28

Here is a way to construct such a graph with the GRAPE package, starting with subgroup class representatives as seeds:

gap> G:=SymmetricGroup(4);; # or whatever group you want
gap> cl:=ConjugacyClassesSubgroups(G);;
gap> reps:=List(cl,Representative);;
gap> gamma:=Graph(G,reps,OnPoints,IsSubset);;

Here we use that the group G acts on its subgroups, reps contains representatives of all orbits, the action of a group element on a subgroup is by OnPoints (i.e. via the ^ operator), and the edge relation we want is given by IsSubset. (If you want to revert the relation use

function(x,y) return IsSubset(y,x);end

instead. If you want to make the graph undirected use

function(x,y) return IsSubset(y,x) or IsSubset(y,x);end

instead. Now the graph gamma contains a component names that gives the correspondence of subgroups to index numbers.

  • $\begingroup$ Thank you so much for the template! This is close to what I'm looking for. I forgot to specify that I am looking to get the graph of the Hasse diagram for subgroup lattices. The issue is this program connects the group to all of its subgroups (and all subgroups to every subgroup they are contained in). I will adjust by running an index test. $\endgroup$ Sep 7 '20 at 23:42

I don't know if such a function exists in GAP proper, but you can definitely use sage to do it. Sage has a wrapper for GAP, which will let you use all the features you're used to, in addition to many more (which might be relevant in this situation).

In particular, the following code should do what you want. You can modify it to return a DiGraph object, a Poset, or any number of things. In particular, if you want to work with the vertex and edge sets directly, there's methods for that. Take a look at the graph library for more info. You can also check out this blog which has some details on working with subgroup lattices in sage. Keep in mind, though, that the blog was written back when sage used python 2.7, so you'll have to make some cosmetic changes to get the example code to run.

def subgroupLatticeAsGraph(G):
    subs = G.subgroups()
    areRelated = lambda H,K: H != K and (H.is_subgroup(K) or K.is_subgroup(H))
    return Graph([subs, areRelated])

I hope this helps ^_^


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.