Group Theory

Visualising S4 in Mathematica Without Losing Your Mind

Group theory stops feeling abstract the moment you can see it. Mathematica's `CayleyGraph` function will draw the entire symmetric group on four letters in a single picture, and once you know what the colours mean, the structure clicks.

The command builds a graph where every node is a permutation and every edge is a generator. Two colours separate the two operations that span the whole group. That's the whole tour in one image.

At a glance

  • S4 is the set of every way to rearrange four items.
  • Mathematica's `CayleyGraph` draws the group with one call.
  • Two generators, a swap and a rotation, generate the whole group.
  • Blue arrows are the swap; green arrows are the rotation.
  • Green edges close into diamonds because four rotations bring you home.

What's a Cayley graph, briefly

A Cayley graph is a portrait of a group. Each node is one group element. Each edge says "multiply by this generator". When a generator is its own inverse, the edge runs both ways. When it isn't, you walk the long way around.

For S4, the elements are every rearrangement of four items. Mathematica lists them in lexicographical order, so the first node is the identity (nothing moves) and the last node is the reverse arrangement.

The two generators

The S4 graph shown uses a pair of generators. The first swaps the first two slots of the permutation. That swap undoes itself, so blue arrows always come in pairs running both directions. The second rotates the entries one step, turning the identity into a shifted version of itself. Rotation isn't self-inverse, so green arrows go one way only.

Every green edge sits on a diamond because applying the rotation four times cycles you right back to where you started.

Why this matters

The headline insight: any permutation of four elements can be reached from the identity by combining these two operations. That's the practical meaning of "the two generators generate the group". You don't need every permutation as a generator; two are plenty.

That generalises. Most interesting groups have a small generating set, and Cayley graphs reveal which generators give the cleanest picture. The tidier the diagram, the easier the group is to think about.

Worked example: tracing a permutation

Say you want to reach the permutation that puts the second item first and the first item second, then leaves the last two alone. From the identity, take a blue edge to swap the first two entries. You're now in a state where the first two are exchanged. From there, follow a chain of green arrows (rotations) until you land on the target. On the live Mathematica image, hovering over a node shows the exact arrangement it stands for, so you can click through the path.

Our analysis

The static image is decorative; the live version inside Mathematica is the actual teaching tool. Hover labels turn the graph from a poster into a map you can walk around. That small interactivity is what makes the picture useful rather than just pretty.

Generator choice matters more than people expect. Swap-plus-rotation is a popular pick because it yields a graph with clean two-colour structure. A different generating set would describe the same group but draw a tangled image instead. Useful lesson: the same mathematical object can look radically different depending on how you draw it.

For students, the practical takeaway is that `CayleyGraph` is a low-effort on-ramp to group intuition. For researchers, it's a fast sanity check on a candidate generating set before committing to deeper analysis.

What to watch next

Watch for similar visualisation tools in other systems. SageMath, GAP, and a few Python libraries can render Cayley graphs of their own. The Mathematica version is convenient because the language ships with group-theory primitives built in. If you teach group theory, try `CayleyGraph` on S3, S5, or the dihedral groups as a quick classroom demo.

Key takeaways

  • `CayleyGraph` renders the full structure of S4 in a single image.
  • A swap and a rotation together generate the entire group.
  • Blue arrows are self-inverse pairs; green arrows close into four-cycles.
  • Hover labels in the live graph reveal the permutation each node represents.
  • Generator choice drives how clean the picture looks.

Frequently asked questions

Do I need Mathematica for this?

For the exact `CayleyGraph` command, yes. SageMath and GAP can produce comparable pictures.

Why only two generators?

Two are enough to span S4. Every rearrangement can be built from a swap plus a rotation.

Can S4 be drawn other ways?

Yes. Any generator set gives a valid Cayley graph, but the picture changes with the choice.

What does the first node represent?

The identity permutation, where every element stays in its original slot.

Why do green arrows form diamonds?

Four rotations return you to the start, so green edges always close into a four-step loop.

Source: johndcook.com

Related