447 lines
20 KiB
Plaintext
447 lines
20 KiB
Plaintext
---
|
|
title: "A Game of Permutations, Part 2"
|
|
description: |
|
|
Permutohedra and some very large graphs
|
|
format:
|
|
html:
|
|
html-math-method: katex
|
|
jupyter: python3
|
|
date: "2022-01-18"
|
|
date-modified: "2025-07-04"
|
|
categories:
|
|
- graph theory
|
|
- group theory
|
|
- sorting algorithms
|
|
---
|
|
|
|
```{python}
|
|
#| echo: false
|
|
|
|
from IPython.display import Markdown
|
|
from tabulate import tabulate
|
|
|
|
from graph_data import complete, path, star
|
|
```
|
|
|
|
|
|
This post assumes you have read (or at least skimmed over parts of) the [first post](../1),
|
|
which talks about graphs and the symmetric group.
|
|
This post will contain some more "empirical" results, since I'm not an expert on graph theory.
|
|
However, one hardly needs to be an expert to learn or to make computations, observations, and predictions.
|
|
|
|
We left off talking about producing a group from a graph, so we begin now by considering how to do the reverse.
|
|
|
|
|
|
Cayley Graphs
|
|
-------------
|
|
|
|
For a given generating set, we can assign every element in the group it generates to a vertex in a graph.
|
|
Starting with each of the generators, we draw arrows from one vertex to the other when
|
|
the product of the initial vertex and a generator (in that order) is the product vertex.
|
|
If we continue until there are no more arrows to draw, the resulting figure is known as a
|
|
[Cayley graph](https://mathworld.wolfram.com/CayleyGraph.html).
|
|
|
|
Owing to the way in which they are generated, Cayley graphs have a few useful properties as graphs.
|
|
At every vertex, we have as many outward edges as we do generators in the generating set,
|
|
so the outward (and in fact, inward) degree of each vertex is the same.
|
|
In other words, it is a regular graph.
|
|
More than that, it is vertex-transitive, since labelling a single vertex's outward edges
|
|
will label that of the entire graph.
|
|
|
|
Cayley graphs can take a wide variety of shapes, which depend on the generating set used.
|
|
Their construction implies a labelling of vertices by permutations and an edge labelling
|
|
indicative of its generating set, but they can just as easily be abstract graphs separate
|
|
from the procedure that was used to generate them.
|
|
Here are a few examples of Cayley graphs made from elements of $S_4$:
|
|
|
|

|
|
|
|
In general, the Cayley graph is a directed graph.
|
|
However, if for every member of the generating set, we also include its inverse,
|
|
every directed edge will be matched by an edge in the opposite direction,
|
|
and the Cayley graph may be considered undirected.
|
|
|
|
|
|
Graphs to Graphs
|
|
----------------
|
|
|
|
Since all 2-cycles are their own inverse, the generating sets which include only them produce undirected Cayley graphs.
|
|
Furthermore, since the generating set can itself be thought of as a graph,
|
|
we may consider an operation from graphs to graphs that maps a swap diagram to its Cayley graph.
|
|
|
|
I've taken to calling this operation the "graph exponential"[^1] because of its apparent relationship
|
|
with the disjoint union.
|
|
Namely, it seems to be the case that $\exp( A \oplus B ) = \exp( A ) \times \exp( B )$,
|
|
where $\times$ signifies the
|
|
[Cartesian (box) product of graphs](https://en.wikipedia.org/wiki/Cartesian_product_of_graphs)[^2].
|
|
|
|
[^1]: Originally, I called this operation the "graph factorial", since it involves permutations
|
|
and the number of vertices in the resulting graph grows factorially.
|
|
While I believe this is a better name, some images in this article retain the earlier A! notation.
|
|
|
|
[^2]: Graphs have many product structures, such as the tensor product and strong product.
|
|
The Cartesian product is (categorically) more natural when paired with disjoint unions.
|
|
|
|

|
|
|
|
This operation is my own invention, so I am unsure whether or not
|
|
it constitutes anything useful.
|
|
In fact, the possible graphs grow so rapidly that computing anything about the exponential
|
|
of order 8 graphs starts to overwhelm a single computer.
|
|
|
|
A random graph will not generally correspond to an interesting generating set,
|
|
and therefore, will also generally have an uninteresting exponential graph.
|
|
Hence, I will continue with the examples used previously: paths, stars, and complete graphs.
|
|
They are among the simplest graphs one can consider, and as we will see shortly,
|
|
have exponentials which appear to have natural correspondences to other graph families.
|
|
|
|
|
|
Some Small Exponential Graphs
|
|
-----------------------------
|
|
|
|
Because of the difficulty in determining graph isomorphism, it is challenging for a computer to find a graph in an encyclopedia.
|
|
Computers think of graphs as a list of vertices and their outward edges,
|
|
but this implementation faces inherent labelling issues.
|
|
These persist even if the graph is described as a list of (un)ordered pairs,
|
|
an adjacency matrix, or an incidence matrix,
|
|
the latter two of which have very large memory footprints.
|
|
I was able to locate a project named the
|
|
[Encyclopedia of Finite Graphs](https://github.com/thoppe/Encyclopedia-of-Finite-Graphs),
|
|
but it is only able to build a database simple connected graphs which
|
|
can be queried by invariants (and is outdated since it uses Python 2).
|
|
|
|
However, as visual objects, humans can compare graphs fairly easily -- the name means "drawing" after all.
|
|
Exponentials of 3- and 4- graphs are neither so small as to be uninteresting nor so big as to be unparsable by humans.
|
|
|
|
### Order 3
|
|
|
|
<!-- TODO: Diagram contains old ! format -->
|
|

|
|
|
|
At this stage, we only really have two graphs to consider, since $P_3 = \bigstar_3$.
|
|
Immediately, one can see that $\exp( P_3 ) = \exp( \bigstar_3 ) = C_6$,
|
|
the 6-cycle graph (or hexagonal graph).
|
|
It is also apparent that $\exp( K_3 )$ is the utility graph, $K_{3,3}$.
|
|
|
|

|
|
|
|
We can again demonstrate the sum rule of the graph exponential with $\exp( P_3 \oplus P_2 )$.
|
|
Simplifying, since we know $\exp( P_3 ) = C_6$, the expression is $C_6 \times P_2 = \text{Prism}_6$,
|
|
the hexagonal prism graph.
|
|
|
|
|
|
### Order 4 (and beyond)
|
|
|
|
::: {layout-ncol="2"}
|
|

|
|
|
|

|
|
:::
|
|
|
|
<!-- TODO: blank? -->
|
|
![]()
|
|
|
|
With some effort, $\exp( P_4 )$ can be imagined as a projection of a 3D object,
|
|
the [truncated octahedron](https://en.wikipedia.org/wiki/Truncated_octahedron).
|
|
Because of its correspondence to a 3D solid, this graph is planar.
|
|
Both the hexagon and this solid belong to a class of polytopes called
|
|
[*permutohedra*](https://en.wikipedia.org/wiki/Permutohedron), which are figures
|
|
that are also formed by permutations of the coordinate (1, 2, 3, ..., *n*) in Euclidean space.
|
|
In fact, they are able to completely tessellate the $n-1$ dimensional subspace of
|
|
$\mathbb{R}^n$ where the coordinates sum to the $n-1$th triangular number.
|
|
Note that the previous graph in the sequence of $\exp(P_n)$, the hexagonal graph,
|
|
is visible in the truncated octahedron.
|
|
This can be seen in the orthographic projection obtained by the map $(x,y,z,w) \mapsto (x,y,z)$.
|
|
|
|
Technically, there is a distinction between the Cayley graphs and permutohedra since their labellings differ.
|
|
Both have edges generated by swaps, but in the latter case, there is a uniform
|
|
Euclidean metric between two vertices.
|
|
More information about the distinction can be found at this article on
|
|
[Wikimedia](https://commons.wikimedia.org/wiki/Category:Permutohedron_of_order_4_%28raytraced%29#Permutohedron_vs._Cayley_graph)[^3].
|
|
|
|
[^3]: Actually, if one considers a *right* Cayley graph, where each generator is right-multiplied
|
|
to the permutation at a node rather than left-multiplied, then a true correspondence is obtained.
|
|
|
|
Meanwhile, $\exp( \bigstar_4 )$ is more difficult to identify, at least without rearranging its vertices.
|
|
It turns out to be isomorphic to the [Nauru graph](https://mathworld.wolfram.com/NauruGraph.html),
|
|
a graph with many strange properties.
|
|
Notably, whereas the graph isomorphic to the permutohedron is obviously a spherical polyhedron,
|
|
the Nauru graph can be topologically embedded on a torus.
|
|
The Nauru graph also belongs to the family of
|
|
[permutation star graphs](https://mathworld.wolfram.com/PermutationStarGraph.html)
|
|
$PS_n$ (*n* = 4), which also includes the hexagonal graph (*n* = 3).
|
|
The MathWorld article confirms a correspondence, stating graphs of this form are generated by pairwise swaps.
|
|
|
|
My attempts at finding a graph isomorphic to $\exp( K_4 )$ have thus far ended in failure.
|
|
It is certainly *not* isomorphic to $K_{4,4}$, since this graph has 8 vertices,
|
|
as opposed to 24 in $\exp( K_4 )$.
|
|
|
|
|
|
### Graph Invariants
|
|
|
|
While I have managed to identify the families to which some of these graphs belong,
|
|
I am rather fond of computing (and conjecturing) sequences from objects.
|
|
Not only is it much easier to consult something like the OEIS for these quantities,
|
|
but when finding a matching sequence, there are ample articles to consult for more information.
|
|
By linking to their respective entries, I hope you'll consider reading more there.
|
|
|
|
Even though I have obtained these values empirically, I am certain that the sequences for
|
|
$\exp( P_n )$ and $\exp( \bigstar_n )$ match the corresponding OEIS entries.
|
|
I also have great confidence in the sequences I found for $\exp( K_n )$.
|
|
|
|
|
|
#### Edge Counts
|
|
|
|
Despite knowing how many vertices there are ($n!$, the order of the symmetric group), we don't necessarily know how many edges there are.
|
|
|
|
| *n* | $\#E(\exp( P_n ))$ | $\#E(\exp( \bigstar_n ))$ | $\#E(\exp( K_n ))$ |
|
|
|------|--------------------|---------------------------|--------------------|
|
|
| 3 | 6 | 6 | 9 |
|
|
| 4 | 36 | 36 | 72 |
|
|
| 5 | 240 | 240 | 600 |
|
|
| 6 | 1800 | 1800 | 5400 |
|
|
| 7 | 15120 | 15120 | 52920 |
|
|
| Rule | Second column of Lah numbers $L(n,2) = n!{(n-1)(n-2) \over 4}$ [OEIS A001286](http://oeis.org/A001286) | Same as previous | $n!{n(n-1) \over 4}$ [OEIS 001809](http://oeis.org/A001809) |
|
|
|
|
|
|
#### Radius and Distance Classes
|
|
|
|
The radius of a graph is the smallest possible distance which separates two maximally-separated vertices.
|
|
Due to vertex transitivity, the greatest distance between two vertices is the same for every vertex.
|
|
|
|
| *n* | $r(\exp( P_n ))$ | $r(\exp( \bigstar_n ))$ | $r(\exp( K_n ))$ |
|
|
|------|------------------|-------------------------|------------------|
|
|
| 3 | 3 | 3 | 2 |
|
|
| 4 | 6 | 4 | 3 |
|
|
| 5 | 10 | 6 | 4 |
|
|
| 6 | 15 | 7 | 5 |
|
|
| 7 | 21 | 9 | 6 |
|
|
| Rule | Triangular numbers $\Delta_{n-1} = {n(n-1) \over 2}$ [OEIS A00021](http://oeis.org/A000217) | Integers not congruent to 2 (mod 3) $\lfloor {n-1 \over 2} \rfloor + n -\ 1$ [OEIS A032766](http://oeis.org/A032766) | *n* - 1 |
|
|
|
|
More information can be gathered about distances on the graph than these reductive quantities.
|
|
If a vertex is distinguished and the remaining vertices are partitioned into classes by their distances from it,
|
|
then the size of each class will be the same for every vertex.
|
|
Including the vertex itself (which is distance 0 away), there will be $r + 1$ such classes,
|
|
where r is the radius.
|
|
In the case of these graphs, they are a partition of the factorial numbers.
|
|
|
|
```{python}
|
|
#| echo: false
|
|
#| classes: plain
|
|
|
|
mahonian = [
|
|
[1, 2, 2, 1],
|
|
[1, 3, 5, 6, 5, 3, 1],
|
|
[1, 4, 9, 15, 20, 22, 20, 15, 9, 4, 1],
|
|
[1, 5, 14, 29, 49, 71, 90, 101, 101, 90, 71, 49, 29, 14, 5, 1],
|
|
[1, 6, 20, 49, 98, 169, 259, 359, 455, 531, 573, 573, 531, 455, 359, 259, 169, 98, 49, 20, 6, 1],
|
|
]
|
|
|
|
whitney_second_kind = [
|
|
[1, 2, 2, 1],
|
|
[1, 3, 6, 9, 5],
|
|
[1, 4, 12, 30, 44, 26, 3],
|
|
[1, 5, 20, 70, 170, 250, 169, 35],
|
|
[1, 6, 30, 135, 460, 1110, 1689, 1254, 340, 15],
|
|
]
|
|
|
|
stirling_second_kind = [
|
|
[1, 3, 2],
|
|
[1, 6, 11, 6],
|
|
[1, 10, 35, 50, 24],
|
|
[1, 15, 85, 225, 274, 120],
|
|
[1, 21, 175, 735, 1624, 1764, 720],
|
|
]
|
|
|
|
half_break = lambda x: str(x[:len(x) // 2])[:-1] + "<br>" + str(x[len(x) // 2:])[1:]
|
|
|
|
Markdown(tabulate(
|
|
[
|
|
[i, j if i <= 5 else half_break(j), k, l]
|
|
for i, j, k, l in zip(range(3,8), mahonian, whitney_second_kind, stirling_second_kind)
|
|
],
|
|
headers=[
|
|
"*n*",
|
|
r"$\text{dists}(\exp( P_n ))$",
|
|
r"$\text{dists}(\exp( \bigstar_n ))$",
|
|
r"$\text{dists}(\exp( K_n ))$"
|
|
]
|
|
))
|
|
```
|
|
|
|
I am certain that the appearance of the Stirling numbers here is legitimate, since these numbers count the number of permutations of *n* objects with *k* disjoint cycles.
|
|
Obviously, the identity element is distance 1 from all 2-cycles since they are all in the generating set; likewise, all 3-cycles are distance 2 from the identity (but distance 1 from the 2-cycles), and so on until the entire graph has been mapped.
|
|
The shapes induced by these classes were used to create the diagrams of $\exp( K_3 )$ and $\exp( K_4 )$ above.
|
|
|
|
|
|
#### Spectrum
|
|
|
|
The eigenvalues of the adjacency matrix of a graph can be interesting
|
|
and sometimes help in identifying a graph.
|
|
Unfortunately, eigenvalues are not necessarily integers, and therefore not easily
|
|
found in the OEIS (though they are always real for graphs).
|
|
|
|
```{python}
|
|
#| echo: false
|
|
#| classes: plain
|
|
|
|
Markdown(tabulate(
|
|
[
|
|
[i, pathG.to_markdown(), starG.to_markdown(), completeG.to_markdown()]
|
|
for i in range(3, 9)
|
|
for pathG, starG, completeG in (
|
|
[path.path_spectra[i], star.star_spectra[i], complete.complete_spectra[i]],
|
|
)
|
|
],
|
|
headers=[
|
|
"*n*",
|
|
r"$\text{Spec}(\exp( P_n ))$",
|
|
r"$\text{Spec}(\exp( \bigstar_n )$",
|
|
r"$\text{Spec}(\exp( K_n ))$"
|
|
]
|
|
))
|
|
```
|
|
|
|
From what I have been able to identify, the spectrum of an exponential graph is symmetric about 0,
|
|
by which I mean that the characteristic polynomial is even.
|
|
This has been the case for all graphs I have tried testing, even outside these graph families.
|
|
|
|
Since all eigenvalues of $\exp( \bigstar_n )$ calculated are integers, it appears they are integral graphs,
|
|
a fact of which I am reasonably sure because of the correspondence to permutation star graphs.
|
|
Additionally, the eigenvalues are very conveniently the integers up to $n-1$ and down to $-n+1$.
|
|
Unfortunately, despite the ease of reading the eigenvalues themselves,
|
|
there isn't an OEIS entry for the multiplicities.
|
|
I was able to identify the multiplicity of the 0 eigenvalue with
|
|
[OEIS A217213](http://oeis.org/A217213), which counts orderings on Dyck paths.
|
|
If this is truly the sequence being generated, it means there is a 1:1 correspondence between
|
|
these orderings and a basis of the nullspace of the adjacency matrix.
|
|
|
|
It seems to be the case that $\exp( K_n )$ are also integral graphs.
|
|
Perplexingly, the multiplicities for each of the eigenvalues appear to be perfect powers.
|
|
This is the case until n = 8, which ruins the pattern because neither of
|
|
$9864 = 2^3 \cdot 3^2 \cdot 137$ or $6125 = 5^3 \cdot 7^2$ are perfect powers.
|
|
I find both this and the fact that such a large prime appears among the factorization
|
|
of the former rather creepy[^4].
|
|
All other primes appearing in the factorization of the other numbers are small -- 2, 3, 5, and 7.
|
|
|
|
[^4]: Some physicists are fond of 137 for its closeness to the reciprocal
|
|
of the fine structure constant (a bit of harmless numerology).
|
|
|
|
|
|
#### Notes about Spectral Computation
|
|
|
|
For *n* = 3 through 6, exactly computing the spectrum
|
|
(or more accurately, the characteristic polynomial)
|
|
is possible, although it takes upwards of 10 minutes for *n* = 6 on my machine using `sympy`.
|
|
The spectra of *n* = 7, 8 are marked with an asterisk because they were computed numerically,
|
|
which still took nearly 8 hours in the case of the latter.
|
|
In fact, these graphs grow so quickly that it becomes nearly impossible to compute
|
|
the spectrum without an explicit formula.
|
|
|
|
For *n* = 8, even storing the adjacency matrix in memory is a problem.
|
|
Assuming the use of single-precision floating point, this behemoth of a matrix is
|
|
$(8!)^2 \cdot 4 \text{ bytes} = 6.5\text{GB}$.
|
|
This doesn't even factor in additional space requirements for eigenvalue algorithms,
|
|
and is the reason I certainly won't be attempting to compute the spectrum for *n* = 9.
|
|
|
|
|
|
Gallery of Adjacency Matrices
|
|
-----------------------------
|
|
|
|
The patterns in adjacency matrices depend on an enumeration of $S_n$ so that the vertices
|
|
can be labelled from 1 to *n*!.
|
|
While this is a fascinating topic unto itself, this post is already long enough,
|
|
and I feel comfortable with just sharing the pictures.
|
|
|
|
|
|
### [Plain Changes](https://en.wikipedia.org/wiki/Steinhaus%E2%80%93Johnson%E2%80%93Trotter_algorithm)
|
|
|
|
::: {layout-ncol="3"}
|
|

|
|
|
|

|
|
|
|

|
|
|
|

|
|
|
|

|
|
|
|

|
|
:::
|
|
|
|
|
|
### [Heap's Algorithm](https://en.wikipedia.org/wiki/Heap%27s_algorithm)[^1]
|
|
|
|
::: {layout-ncol="3"}
|
|

|
|
|
|

|
|
|
|

|
|
|
|

|
|
|
|

|
|
|
|

|
|
:::
|
|
|
|
[^5]: GHC's `Data.List.permutations` is slightly different from Heap's algorithm as displayed on Wikipedia
|
|
|
|
|
|
Closing
|
|
-------
|
|
|
|
As previously stated, I am only mostly sure of the validity of the exponential law for graphs.
|
|
It *seems* too good to be true, but testing it directly on some graphs by comparing the spectra
|
|
of the exponential of the sum against the product of the exponentials shows that they are at least cospectral.
|
|
Try it yourself, preferably with a better tool than [the ones I made in Haskell](https://github.com/queue-miscreant/SymmetricGraph).
|
|
|
|
From the articles I was able to find, permutation star graphs have applications to parallel computing,
|
|
which is somewhat ironic considering how little care I had for the topic when writing this article.
|
|
If I needed ruthless efficiency, I probably could have used a library with GPU algorithms
|
|
(or taken a stab at writing a shader myself).
|
|
However, I *was* able to use this as a learning experience regarding mutable objects in Haskell.
|
|
With only immutable objects (and enough garbage to create an island in the Pacific),
|
|
I was running out of memory even with 16GB of RAM and 16GB of swap.
|
|
Introducing mutability not only brought improvements in space, but also a great deal of speedup,
|
|
enough to make rendering adjacency matrix images of order 8 graphs just barely doable within
|
|
a reasonable time span.
|
|
|
|
Said images are cursed.
|
|
Remember, as raw bitmaps, these files are on the order of *gigabytes* big.
|
|
On a much weaker computer than I used to render the images, merely opening my file explorer
|
|
to the folder containing *the folder containing* the images
|
|
caused its all-too-eager thumbnailer to run.
|
|
It started to consume all of my system resources, crashing all of my browser's tabs,
|
|
distorting audio, and locking up the computer.
|
|
Despite this, PNG is a wonderful format that is able to compress them down to just 4MB,
|
|
which demonstrates just how sparse these matrices are.
|
|
|
|
Despite everything I was able to find about permutation star graphs and permutohedra,
|
|
I was surprised that there is no information about the Cayley graphs generated by *all*
|
|
2-cycles (or at least information which is easy to find).
|
|
This is especially disappointing considering the phantom pattern which gets destroyed by 137,
|
|
and I would love to know more about why this happens in the first place.
|
|
|
|
Graph diagrams made with GeoGebra and NetworkX (GraphViz).
|
|
|
|
|
|
### Additional Links
|
|
|
|
- [Whitney Numbers of the Second Kind for the Star Poset (Paper from ScienceDirect)](https://www.sciencedirect.com/science/article/pii/S0195669813801278)
|
|
- This article includes a section about representing a list of generators as a graph,
|
|
making me wonder if someone has tried defining this operation before
|
|
- [Whitney Numbers (Josh Cooper's Mathpages)](https://people.math.sc.edu/cooper/graph.html)
|
|
- [The Many Faces of the Nauru Graph (Blogpost by David Eppstein)](https://11011110.github.io/blog/2007/12/12/many-faces-of.html)
|