diff --git a/doc/examples.xml b/doc/examples.xml
index f9a2c9c6a..a2bc87912 100644
--- a/doc/examples.xml
+++ b/doc/examples.xml
@@ -1083,7 +1083,7 @@ true]]>
Hanoi graph. The Hanoi graph's vertices represent the possible states
of the 'Tower of Hanoi' puzzle on three 'towers', while its edges represent
possible moves. The Hanoi graph has 3^n vertices, and
- Binomial(3, 3) * (3^n - 1) / 2 undirected edges.
+ 3 * (3^n - 1) / 2 undirected edges.
The Hanoi graph is Hamiltonian. The graph superficially resembles the
Sierpinski triangle. The graph is also a 'penny graph' - a graph whose
diff --git a/gap/examples.gi b/gap/examples.gi
index a5d0e4be4..e26ca9b87 100644
--- a/gap/examples.gi
+++ b/gap/examples.gi
@@ -1251,22 +1251,29 @@ InstallMethod(HalvedCubeGraph, "for a function and an integer",
InstallMethod(HanoiGraphCons, "for IsMutableDigraph and an integer",
[IsMutableDigraph, IsPosInt],
function(_, n)
- local D, nrVert, prevNrVert, exp, i;
+ local e, D, nrVert, prevNrVert, anchor1, anchor2, anchor3, i;
D := Digraph(IsMutableDigraph, []);
nrVert := 3 ^ n;
DigraphAddVertices(D, nrVert);
- DigraphAddEdges(D, [[1, 2], [2, 3], [3, 1]]);
+ e := [[1, 2], [2, 3], [3, 1]];
+ # Anchors correspond to the top, bottom left and bottom right node of the
+ # current graph.
+ anchor1 := 1;
+ anchor2 := 2;
+ anchor3 := 3;
prevNrVert := 1;
- exp := 1;
+ # Starting from the triangle graph G := C_3, itteratively triplicate G, and
+ # connect each copy using their anchors.
for i in [2 .. n] do
prevNrVert := prevNrVert * 3;
- DigraphAddEdges(D, Concatenation(DigraphEdges(D) + prevNrVert,
- DigraphEdges(D) + (2 * prevNrVert)));
- DigraphAddEdge(D, prevNrVert / 2 + (1 / 2), prevNrVert + 1);
- DigraphAddEdge(D, prevNrVert, 2 * prevNrVert + 1);
- DigraphAddEdge(D, 2 * prevNrVert, prevNrVert * 3 - exp);
- exp := exp * 2;
+ Append(e, Concatenation(e + prevNrVert, e + (2 * prevNrVert)));
+ Add(e, [anchor2, anchor1 + prevNrVert]);
+ Add(e, [anchor3, anchor1 + (2 * prevNrVert)]);
+ Add(e, [anchor3 + prevNrVert, anchor2 + (2 * prevNrVert)]);
+ anchor2 := anchor2 + prevNrVert;
+ anchor3 := anchor3 + (2 * prevNrVert);
od;
+ DigraphAddEdges(D, e);
return DigraphSymmetricClosure(D);
end);
diff --git a/tst/standard/examples.tst b/tst/standard/examples.tst
index e3307afbd..d52bf344e 100644
--- a/tst/standard/examples.tst
+++ b/tst/standard/examples.tst
@@ -575,9 +575,15 @@ gap> D := HanoiGraph(1);
gap> IsIsomorphicDigraph(D, CycleGraph(3));
true
-gap> HanoiGraph(4);
+gap> gr := HanoiGraph(4);
+gap> IsPlanarDigraph(gr);
+true
+gap> IsHamiltonianDigraph(gr);
+true
+gap> IsPlanarDigraph(DigraphMutableCopy(gr));
+true
gap> HanoiGraph(0);
Error, no method found! For debugging hints type ?Recovery from NoMethodFound
Error, no 1st choice method found for `HanoiGraph' on 1 arguments