From 6839975c6047846238648c967883b0e0595d3f29 Mon Sep 17 00:00:00 2001 From: Ben Spiers Date: Wed, 24 Feb 2021 12:26:31 +0000 Subject: [PATCH] Implemented several infinite families of graphs --- doc/examples.xml | 840 ++++++++++++++++++++++++++++++++++ doc/z-chap2.xml | 23 + gap/examples.gd | 96 ++++ gap/examples.gi | 920 ++++++++++++++++++++++++++++++++++++++ tst/standard/examples.tst | 325 ++++++++++++++ 5 files changed, 2204 insertions(+) diff --git a/doc/examples.xml b/doc/examples.xml index 61b3e2c29..1655a36b6 100644 --- a/doc/examples.xml +++ b/doc/examples.xml @@ -350,6 +350,43 @@ gap> LollipopGraph(IsMutableDigraph, 3, 8); <#/GAPDoc> +<#GAPDoc Label="GearGraph"> + + + A digraph. + + If n is a positive integer at least 3, then this operation + returns the Gear graph with 2n + 1 vertices and + 3n undirected edges. The nth Gear graph is the 2nth + Cycle graph with one additional central vertex, to which every other + vertex of the cycle is connected. The Gear graph is a symmetric digraph. + A Gear graph is a Matchstick graph, that is it is simple with a planar + graph embedding, and is a unit-distance graph (that is, it can be embedded + into the Euclidean plane with vertices being distinct points and edges + having length 1).

+ + If the optional first argument filt is present, then this should + specify the category or representation the digraph being created will + belong to. For example, if filt is , + then the digraph being created will be mutable, if filt is , then the digraph will be immutable. + If the optional first argument filt is not present, then is used by default.

+ + See https://mathworld.wolfram.com/GearGraph.html for further + details. + + D := GearGraph(4); + +gap> ChromaticNumber(D); +2 +gap> IsVertexTransitive(D); +false]]> + + +<#/GAPDoc> + <#GAPDoc Label="KingsGraph"> @@ -408,6 +445,85 @@ gap> OutNeighbors(D); <#/GAPDoc> +<#GAPDoc Label="PrismGraph"> + + + A digraph. + + If n is a positive integer at least 3, then this operation returns + the Prism graph that is the skeleton of the n-prism. It has + 2n vertices and 3n undirected edges. The Prism graph is a + symmetric digraph. The nth Prism graph is isomorphic to the graph + Cartesian product of the 2nd Path graph and the nth Cycle + graph, isomorphic to the generalised Petersen graph GP(n,1). If + n is odd then the Prism graph is isomorphic to the Circulant graph + Ci(2n, [2,n]). The Prism graph is Hamiltonian.

+ + If the optional first argument filt is present, then this should + specify the category or representation the digraph being created will + belong to. For example, if filt is , + then the digraph being created will be mutable, if filt is , then the digraph will be immutable. + If the optional first argument filt is not present, then is used by default.

+ + See https://mathworld.wolfram.com/PrismGraph.html for further + details. + + D := PrismGraph(4); + +gap> IsHamiltonianDigraph(D); +true +gap> D := PrismGraph(5); + +gap> IsIsomorphicDigraph(D, CirculantGraph(10, [2, 5])); +true]]> + + +<#/GAPDoc> + +<#GAPDoc Label="MobiusLadderGraph"> + + + A digraph. + + If n is a positive integer at least 4, then this operation returns + the Mobius Ladder graph that is obtained by introducing a 'twist' + in the nth Prism graph, similar to the construction of a Mobius + strip. The Mobius ladder graph is isomorphic to the Circulant graph + Ci(2n, [1, n]). The Mobius ladders are cubic, symmetric, + Hamiltonian, vertex-transitive, and graceful. They are also non-planar + and apex, meaning removing a single vertex produces a planar graph.

+ + If the optional first argument filt is present, then this should + specify the category or representation the digraph being created will + belong to. For example, if filt is , + then the digraph being created will be mutable, if filt is , then the digraph will be immutable. + If the optional first argument filt is not present, then is used by default.

+ + See https://mathworld.wolfram.com/MoebiusLadder.html for further + details. + + D := MobiusLadderGraph(7); + +gap> IsHamiltonianDigraph(D); +true +gap> IsVertexTransitive(D); +true +gap> IsPlanarDigraph(D); +false +gap> D2 := DigraphRemoveVertex(D, 1); + +gap> IsPlanarDigraph(D2); +true]]> + + +<#/GAPDoc> + <#GAPDoc Label="SquareGridGraph"> @@ -452,6 +568,118 @@ gap> GridGraph(IsMutable, 3, 4); <#/GAPDoc> +<#GAPDoc Label="WalshHadamardGraph"> + + + A digraph. + + If n is a positive integer at least 1, then this operation returns + the Hadamard graph constructed from the nth Hadamard matrix + (of dimension 2^n) as constructed by Joseph Walsh. A Hadamard matrix + is a square matrix with entries either 1 or -1, such that all the rows are + mutually orthogonal. The nth Hadamard graph is a graph on 4n + matrices split into four categories r_i+, r_i-, c_i+, c_i-. If + h_ij are the elements of the nth Walsh matrix, then if + h_ij = 1 then (r_i+, c_j+) and (r_i-, c_j-) are edges, + if h_ij = -1 then (r_i+, c_j-) and (r_i-, c_j+) are + edges. Walsh Hadamard graphs are distance transitive and distance + regular.

+ + If the optional first argument filt is present, then this should + specify the category or representation the digraph being created will + belong to. For example, if filt is , + then the digraph being created will be mutable, if filt is , then the digraph will be immutable. + If the optional first argument filt is not present, then is used by default.

+ + See https://mathworld.wolfram.com/HadamardGraph.html for further + details. + + D := WalshHadamardGraph(5); + +gap> IsDistanceRegularDigraph(D); +true]]> + + +<#/GAPDoc> + +<#GAPDoc Label="HalvedCubeGraph"> + + + A digraph. + + If n is a positive integer at least 1, then this operation returns + the nth Halved Cube graph, the graph of the n- + demihypercube. The vertices of the graph are those of the nth- + hypercube, with two vertices adjacent if and only if they are at distance + 1 or 2 from each other. Equivalent constructions are as the second graph + power of the n-1th hypercube graph, or as with vertices labelled as + the binary numbers where two vertices are adjacent if they differ in a + single bit, or with vertices labelled with the subset of binary numbers + with even Hamming weight, with edges connecting vertices with Hamming + distance exactly 2. The Halved Cube graph is distance regular and contains + a Hamiltonian cycle.

+ + If the optional first argument filt is present, then this should + specify the category or representation the digraph being created will + belong to. For example, if filt is , + then the digraph being created will be mutable, if filt is , then the digraph will be immutable. + If the optional first argument filt is not present, then is used by default.

+ + See https://mathworld.wolfram.com/HalvedCubeGraph.html for further + details. + + D := HalvedCubeGraph(3); + +gap> IsDistanceRegularDigraph(D); +true +gap> IsHamiltonianDigraph(D); +true]]> + + +<#/GAPDoc> + +<#GAPDoc Label="WheelGraph"> + + + A digraph. + + If n is a positive integer at least 4, then this operation returns + the nth Wheel graph. The Wheel graph is formed from an + n-1 Cycle graph with a single additional vertex adjacent to all + vertices of the cycle. The graph has n vertices and 2(n-1) + edges. Wheel graphs are the skeletons of n-1 pyramids, and are + self-dual. If n is odd, then the chromatic number of the Wheel + graph is 3 and the Wheel graph is perfect, and it is 4 otherwise. The + Wheel graph is also Hamiltonian and planar.

+ + If the optional first argument filt is present, then this should + specify the category or representation the digraph being created will + belong to. For example, if filt is , + then the digraph being created will be mutable, if filt is , then the digraph will be immutable. + If the optional first argument filt is not present, then is used by default.

+ + See https://mathworld.wolfram.com/WheelGraph.html for further + details. + + D := WheelGraph(8); + +gap> ChromaticNumber(D); +4 +gap> IsHamiltonianDigraph(D); +true]]> + + +<#/GAPDoc> + <#GAPDoc Label="TriangularGridGraph"> @@ -493,6 +721,39 @@ gap> TriangularGridGraph(IsMutable, 3, 3); <#/GAPDoc> +<#GAPDoc Label="HypercubeGraph"> + + + A digraph. + + If n is a non-negative integer, then this operation returns the + nth Hypercube graph. The graph has 2^n vertices and + 2^(n-1)n edges. It is formed from the vertices and edges of the + n-dimensional hypercube. Alternatively, the graph can be constructed + by labelling each vertex with the binary numbers, with two vertices + adjacent if they have Hamming distance exactly one. The Hypercube graphs + are Hamiltonian, distance-transitive and therefore distance-regular, and + bipartite.

+ + If the optional first argument filt is present, then this should + specify the category or representation the digraph being created will + belong to. For example, if filt is , + then the digraph being created will be mutable, if filt is , then the digraph will be immutable. + If the optional first argument filt is not present, then is used by default.

+ + See https://mathworld.wolfram.com/HypercubeGraph.html for further + details. + + D := HypercubeGraph(5); + +]]> + + +<#/GAPDoc> + <#GAPDoc Label="StarDigraph"> @@ -529,6 +790,88 @@ true <#/GAPDoc> +<#GAPDoc Label="LindgrenSousselierGraph"> + + + A digraph. + + If n is an integer greater than 0, then this operation returns the + nth Lindgren-Sousselier graph, an infinite family of + hyophamiltonian graphs - a graph that is non-Hamiltonian but removing + any vector gives a Hamiltonian graph. The graph has 6n+4 vertices + and 15 + 10(n-1) undirected edges. The first Lindgren-Sousselier + graph is the Petersen graph, and is in fact the smallest hyophamiltonian + graph.

+ + If the optional first argument filt is present, then this should + specify the category or representation the digraph being created will + belong to. For example, if filt is , + then the digraph being created will be mutable, if filt is , then the digraph will be immutable. + If the optional first argument filt is not present, then is used by default.

+ + See https://mathworld.wolfram.com/HypohamiltonianGraph.html for further + details. + + D := LindgrenSousselierGraph(3); + +gap> IsHamiltonianDigraph(D); +false +gap> IsHamiltonianDigraph(DigraphRemoveVertex(D, 1)); +true +gap> IsIsomorphicDigraph(LindgrenSousselierGraph(1), PetersenGraph()); +true]]> + + +<#/GAPDoc> + +<#GAPDoc Label="KneserGraph"> + + + A digraph. + + If n and k are integers greater than 0, with k less + than n, then this operation returns the (n,k)th + Kneser graph. The Kneser graph's vertices correspond to the k- + element subsets of a set of n elements, with two vertices being + adjacent if and only if the subsets are disjoint. The graph has + Binomial(n, k) vertices and (1/2) * Binomial(n, k) * + Binomial(n - k, k) edges. Kneser graphs are regular, edge transitive, + and vertex transitive. If k is 1, then the graph is the complete + graph on n vertices. If (n, k) is (2m - 1, n -1), then + the graph is the mth Odd graph. The Petersen graph is the + (5, 2)th Kneser graph.

+ + If n >= 2k then the graph's chromatic number is n - 2k + 2, + and otherwise is 1. The Kneser graph contains a Hamiltonian cycle if + n >= ((3 + 5 ^ 0.5) / 2)k + 1. The graph has clique number equal to + the floor of n / k.

+ + If the optional first argument filt is present, then this should + specify the category or representation the digraph being created will + belong to. For example, if filt is , + then the digraph being created will be mutable, if filt is , then the digraph will be immutable. + If the optional first argument filt is not present, then is used by default.

+ + See https://mathworld.wolfram.com/KneserGraph.html for further + details. + + D := KneserGraph(7, 3); + +gap> IsRegularDigraph(D); +true +gap> ChromaticNumber(D); +3gap> CliqueNumber(D); +2]]> + + +<#/GAPDoc> + <#GAPDoc Label="KnightsGraph"> @@ -573,6 +916,86 @@ gap> KnightsGraph(IsMutable, 3, 9); <#/GAPDoc> +<#GAPDoc Label="MycielskiGraph"> + + + A digraph. + + If n is an integer greater than 1, then this operation returns the + nth Mycielski graph. The Mycielskian of a triangle-free graph + is a construction that adds vertices and edges to produce a new graph that + is still triangle-free but has a larger chromatic number. The Mycielski + graphs are a series of graphs with this construction repeated, starting + with the complete graph on two vertices. The graph has 3 * 2^(n-2) -1 + vertices, with the number of edges being + (18 - 27 * 2 ^ n + 14 * 3 ^ n) / 36.

+ + The Mycielski graph has chromatic number equal to n, clique number + equal to 2, and is Hamiltonian. The graph is in fact the graph with + chromatic number n with the least possible vertices.

+ + If the optional first argument filt is present, then this should + specify the category or representation the digraph being created will + belong to. For example, if filt is , + then the digraph being created will be mutable, if filt is , then the digraph will be immutable. + If the optional first argument filt is not present, then is used by default.

+ + See https://mathworld.wolfram.com/MycielskiGraph.html for further + details. + + D := MycielskiGraph(4); + +gap> ChromaticNumber(D); +4 +gap> CliqueNumber(D); +2]]> + + +<#/GAPDoc> + +<#GAPDoc Label="OddGraph"> + + + A digraph. + + If n is an integer greater than 0, then this operation returns the + nth Odd graph. The Odd graph has vertices labelled with the + n - 1-subsets of a 2n - 1-set, with two vertices adjacent if + and only if their subsets are disjoint. The nth Odd graph is the + (2n - 1, n - 1)th Kneser graph. The graph has + Binomial(2n - 1, n -1) vertices and + n * Binomial(2n - 1, n - 1) / 2 edges.

+ + The Odd graph is regular and distance transitive (and therefore distance + regular). They have chromatic number equal to 3, and all Odd graphs with + n greater than 3 are Hamiltonian. They are also vertex and edge + transitive.

+ + If the optional first argument filt is present, then this should + specify the category or representation the digraph being created will + belong to. For example, if filt is , + then the digraph being created will be mutable, if filt is , then the digraph will be immutable. + If the optional first argument filt is not present, then is used by default.

+ + See https://mathworld.wolfram.com/OddGraph.html for further + details. + + D := OddGraph(4); + +gap> IsIsomorphicDigraph(D, KneserGraph(7, 3)); +true +gap> ChromaticNumber(D); +3]]> + + +<#/GAPDoc> + <#GAPDoc Label="HaarGraph"> @@ -620,6 +1043,85 @@ ent sizes 5 and 5> <#/GAPDoc> +<#GAPDoc Label="AndrasfaiGraph"> + + + A digraph. + + If n is an integer greater than 0, then this operation returns the + nth Andrasfai graph. The Andrasfai graph is a Circulant graph + with 3n - 1 vertices. The indices of the Andrasfai graph are given by + the numbers between 1 and 3n - 1 that are congruent to + 1 mod 3 (that is, for each index j, vertex i is + adjacent to the i + jth and i - j vertices). The graph has + 6(3n - 1) edges. The graph is triangle free.

+ + As a Circulant graph, the Andrasfai graph is biconnected, cyclic, + Hamiltonian, regular, and vertex transitive.

+ + If the optional first argument filt is present, then this should + specify the category or representation the digraph being created will + belong to. For example, if filt is , + then the digraph being created will be mutable, if filt is , then the digraph will be immutable. + If the optional first argument filt is not present, then is used by default.

+ + See https://mathworld.wolfram.com/OddGraph.html for further + details. + + D := AndrasfaiGraph(4); + +gap> IsBiconnectedDigraph(D); +true +gap> IsIsomorphicDigraph(D, CirculantGraph(11, [1, 4, 7, 10])); +true]]> + + +<#/GAPDoc> + +<#GAPDoc Label="CirculantGraph"> + + + A digraph. + + If n is an integer greater than 1, and par is a list of + integers that are contained in [1 .. n] then this operation returns + a Circulant graph. The Circulant graph is a graph on n + vertices, where for each element j of par, the ith + vertex is adjacent to the (i + j)th and (i - j)th + vertices.

+ + If par is [1], then the graph is the nth Cyclic graph. + If par is [1, 2, . . ., Int(n / 2)], then the graph is the + complete graph on n vertices. If n is at least 4 and + par is [1, n] then the graph is the nth Mobius Ladder + graph.

+ + A Circulant graph is biconnected, cyclic, Hamiltonian, regular, and vertex + transitive.

+ + If the optional first argument filt is present, then this should + specify the category or representation the digraph being created will + belong to. For example, if filt is , + then the digraph being created will be mutable, if filt is , then the digraph will be immutable. + If the optional first argument filt is not present, then is used by default.

+ + See https://mathworld.wolfram.com/OddGraph.html for further + details. + + D := CirculantGraph(6, [1, 2, 3]); + +gap> IsIsomorphicDigraph(D, CompleteDigraph(6)); +true]]> + + +<#/GAPDoc> + <#GAPDoc Label="BananaTree"> @@ -669,6 +1171,88 @@ gap> D := BananaTree(3, 4); <#/GAPDoc> +<#GAPDoc Label="KellerGraph"> + + + A digraph. + + If n is an integer at least 0 then this operation returns the + nth or n-dimensional Keller graph. The graph has + vertices given by the n-tuples on the set [0, 1, 2, 3]. + Two vertices are adjacent if their respective tuples are such that they + differ in at least two coordinates and in at least one coordinate the + difference between the two is 2 mod 4. The Keller graph has + 4 ^ n vertices.

+ + The Keller graphs were constructed with the intention of finding + counterexamples to Keller's conjecture + (https://mathworld.wolfram.com/KellersConjecture.html), and has + been used since for testing maximum clique algorithms.

+ + If n is 1 then the graph is empty, for n greater than 1 the + chromatic number of the Keller graph is 2^n and the graph is + Hamiltonian.

+ + If the optional first argument filt is present, then this should + specify the category or representation the digraph being created will + belong to. For example, if filt is , + then the digraph being created will be mutable, if filt is , then the digraph will be immutable. + If the optional first argument filt is not present, then is used by default.

+ + See https://mathworld.wolfram.com/KellerGraph.html for further + details. + + D := CirculantGraph(6, [1, 2, 3]); + +gap> IsIsomorphicDigraph(D, CompleteDigraph(6)); +true]]> + + +<#/GAPDoc> + +<#GAPDoc Label="PermutationStarGraph"> + + + A digraph. + + If n is an integer at greater than 0 and k is an integer + greater than 1, and k less than or equal to n, then this + operation returns the (n, k)th Permutation Star graph. The + vertices of the graph are given by the k-length ordered subsets of + an n-set, with two vertices being adjacent if one is labelled + p1 p2 p3 ... pi ... pk, and the other is either labelled + pi p2 p3 ... p1 ... pk, or labelled x p2 p3 ... pi ... pk + where x is in [1 .. n] and is not equal to p1. The + graph has n! / (n - k)! vertices.

+ + The Permutation Star graph is regular and vertex transitive. It has diameter + 2k - 1 if k less than or equal to Int(n / 2), and + diameter Int((n - 1) / 2) + k if k >= Int(n / 2) + 1. +

+ + If the optional first argument filt is present, then this should + specify the category or representation the digraph being created will + belong to. For example, if filt is , + then the digraph being created will be mutable, if filt is , then the digraph will be immutable. + If the optional first argument filt is not present, then is used by default.

+ + See https://mathworld.wolfram.com/PermutationStarGraph.html for + further details. + + D := PermutationStarGraph(6, 2); + +gap> DigraphDiameter(D); +3]]> + + +<#/GAPDoc> + <#GAPDoc Label="TadpoleDigraph"> @@ -706,6 +1290,72 @@ true <#/GAPDoc> +<#GAPDoc Label="WindmillGraph"> + + + A digraph. + + If n and m are integers greater than 1 then this operation + returns the (n, m)th Windmill graph. The Windmill graph is + formed from m copies of the Complete graph on n vertices with + one shared vertex. The graph has (n - 1) * m + 1 vertices and + m * n * (n - 1) / 2 undirected edges. The Windmill graph has + chromatic number n and diameter 2.

+ + If the optional first argument filt is present, then this should + specify the category or representation the digraph being created will + belong to. For example, if filt is , + then the digraph being created will be mutable, if filt is , then the digraph will be immutable. + If the optional first argument filt is not present, then is used by default.

+ + See https://mathworld.wolfram.com/WindmillGraph.html for + further details. + + D := WindmillGraph(4, 3); + +gap> ChromaticNumber(D); +4]]> + + +<#/GAPDoc> + +<#GAPDoc Label="StackedPrismGraph"> + + + A digraph. + + If n is an integer at least 3 and k is a positive integer then + this operation returns the (n, k)th Stacked Prism graph. The + graph is k concentric n-Cycle graphs connected by spokes. + The Stacked Prism is the graph Cartesian product of the nth Cycle + graph and the kth Path graph. The graph has nk vertices and + n(2k - 1) undirected edges. If k is 1 then the graph is the + nth Cycle graph, if k is 2 then the graph is the Prism graph. +

+ + If the optional first argument filt is present, then this should + specify the category or representation the digraph being created will + belong to. For example, if filt is , + then the digraph being created will be mutable, if filt is , then the digraph will be immutable. + If the optional first argument filt is not present, then is used by default.

+ + See https://mathworld.wolfram.com/StackedPrismGraph.html for + further details. + + D := StackedPrismGraph(5, 2); + +gap> IsIsomorphicDigraph(D, PrismGraph(5)); +true]]> + + +<#/GAPDoc> + <#GAPDoc Label="BookDigraph"> @@ -743,3 +1393,193 @@ true <#/GAPDoc> + +<#GAPDoc Label="WebGraph"> + + + A digraph. + + If n is an integer at least 3 then this operation returns the + nth Web graph. The Web graph is the (n, 3)th + Stacked Prism graph with the edges of the outer cycle removed. The graph + has 3n vertices and 4n undirected edges.

+ + If the optional first argument filt is present, then this should + specify the category or representation the digraph being created will + belong to. For example, if filt is , + then the digraph being created will be mutable, if filt is , then the digraph will be immutable. + If the optional first argument filt is not present, then is used by default.

+ + See https://mathworld.wolfram.com/WebGraph.html for + further details. + + D := WebGraph(5); +]]> + + +<#/GAPDoc> + +<#GAPDoc Label="HanoiGraph"> + + + A digraph. + + If n is positive integer then this operation returns the nth + 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 + (1/2) * Binomial(3, 3) * (3^n - 1) undirected edges.

+ + The Hanoi graph is Hamiltonian. The graph superficially resembles the + Sierpinski triangle. The graph is also a 'penny graph' - a graph whose + vertices can be considered to be non-overlapping unit circles on a flat + surface, with two vertices adjacent only if the unit circles touch at a + single point. Thus the Hanoi graph is planar.

+ + If the optional first argument filt is present, then this should + specify the category or representation the digraph being created will + belong to. For example, if filt is , + then the digraph being created will be mutable, if filt is , then the digraph will be immutable. + If the optional first argument filt is not present, then is used by default.

+ + See https://mathworld.wolfram.com/HanoiGraph.html for + further details. + + D := HanoiGraph(5); + +gap> IsPlanarDigraph(D); +true]]> + + +<#/GAPDoc> + +<#GAPDoc Label="BondyGraph"> + + + A digraph. + + If n is a non-negative integer then this operation returns the + nth Bondy graph. The Bondy graphs are a family of + hypohamiltonian graphs: a graph which is not Hamiltonian itself but the + removal of any vertex produces a Hamiltonian graph. The Bondy graphs are + the (3 * (2 * n + 1) + 2, 2)th Generalised Petersen graphs, and have + 12n + 10 vertices and 15 + 18n undirected edges.

+ + If the optional first argument filt is present, then this should + specify the category or representation the digraph being created will + belong to. For example, if filt is , + then the digraph being created will be mutable, if filt is , then the digraph will be immutable. + If the optional first argument filt is not present, then is used by default.

+ + See https://mathworld.wolfram.com/HypohamiltonianGraph.html for + further details. + + D := BondyGraph(1); + +gap> IsHamiltonianDigraph(D); +false +gap> G := List([1 .. 22], x -> DigraphRemoveVertex(D, x)); +gap> ForAll(G, x -> IsHamiltonianDigraph(x)); +true]]> + + +<#/GAPDoc> + +<#GAPDoc Label="BinomialTreeGraph"> + + + A digraph. + + If n is a positive integer then this operation returns the + nth Binomial Tree graph. The Binomial Tree graph has n + vertices and n-1 undirected edges. The vertices of the Binomial Tree + graph are the numbers from 1 to n in binary representation, with a + vertex v having as a direct parent the vertex with binary + representation the same as v but with the lowest 1-bit cleared. For + example, the vertex 011 has parent 010, and the vertex + 010 has parent 000.

+ + If the optional first argument filt is present, then this should + specify the category or representation the digraph being created will + belong to. For example, if filt is , + then the digraph being created will be mutable, if filt is , then the digraph will be immutable. + If the optional first argument filt is not present, then is used by default.

+ + See https://metacpan.org/pod/Graph::Maker::BinomialTree for + further details. + + D := BinomialTreeGraph(9); +]]> + + +<#/GAPDoc> + +<#GAPDoc Label="CycleGraph"> + + + A digraph. + + If n is an integer greater than 2 then this operation returns the + nth Cycle graph, consisting of the cycle on n vertices. + The Cycle graph, unlike the Cycle digraph, is symmetric. The Cycle graph + has n vertices and n undirected edges. The Cycle graph is + simple so the non-simple graphs with a single vertex and single loop and + with two vertices and two edges between them are excluded.

+ + If the optional first argument filt is present, then this should + specify the category or representation the digraph being created will + belong to. For example, if filt is , + then the digraph being created will be mutable, if filt is , then the digraph will be immutable. + If the optional first argument filt is not present, then is used by default.

+ + See https://mathworld.wolfram.com/CycleGraph.html for + further details. + + D := CycleGraph(7); +]]> + + +<#/GAPDoc> + +<#GAPDoc Label="PathGraph"> + + + A digraph. + + If n is a non-negative integer then this operation returns the + nth Path graph, consisting of the path on n vertices. + This is similar to the Chain digraph but with symmetric edges. The Path + graph has n vertices and n-1 edges. The graph is acyclic.

+ + If the optional first argument filt is present, then this should + specify the category or representation the digraph being created will + belong to. For example, if filt is , + then the digraph being created will be mutable, if filt is , then the digraph will be immutable. + If the optional first argument filt is not present, then is used by default.

+ + See https://mathworld.wolfram.com/PathGraph.html for + further details. + + D := PathGraph(12); +]]> + + +<#/GAPDoc> diff --git a/doc/z-chap2.xml b/doc/z-chap2.xml index 01140f706..dc6d67cc0 100644 --- a/doc/z-chap2.xml +++ b/doc/z-chap2.xml @@ -98,6 +98,29 @@ <#Include Label="StarDigraph"> <#Include Label="TadpoleDigraph"> <#Include Label="BookDigraph"> + <#Include Label="PrismGraph"> + <#Include Label="GearGraph"> + <#Include Label="WalshHadamardGraph"> + <#Include Label="MobiusLadderGraph"> + <#Include Label="HalvedCubeGraph"> + <#Include Label="WheelGraph"> + <#Include Label="HypercubeGraph"> + <#Include Label="LindgrenSousselierGraph"> + <#Include Label="KneserGraph"> + <#Include Label="MycielskiGraph"> + <#Include Label="OddGraph"> + <#Include Label="AndrasfaiGraph"> + <#Include Label="CirculantGraph"> + <#Include Label="KellerGraph"> + <#Include Label="PermutationStarGraph"> + <#Include Label="WindmillGraph"> + <#Include Label="StackedPrismGraph"> + <#Include Label="WebGraph"> + <#Include Label="HanoiGraph"> + <#Include Label="BondyGraph"> + <#Include Label="BinomialTreeGraph"> + <#Include Label="CycleGraph"> + <#Include Label="PathGraph"> diff --git a/gap/examples.gd b/gap/examples.gd index 406ac18ae..47d16b846 100644 --- a/gap/examples.gd +++ b/gap/examples.gd @@ -90,3 +90,99 @@ DeclareOperation("TadpoleDigraph", [IsFunction, IsPosInt, IsPosInt]); DeclareConstructor("BookDigraphCons", [IsDigraph, IsPosInt]); DeclareOperation("BookDigraph", [IsPosInt]); DeclareOperation("BookDigraph", [IsFunction, IsPosInt]); + +DeclareConstructor("GearGraphCons", [IsDigraph, IsPosInt]); +DeclareOperation("GearGraph", [IsPosInt]); +DeclareOperation("GearGraph", [IsFunction, IsPosInt]); + +DeclareConstructor("PrismGraphCons", [IsDigraph, IsPosInt]); +DeclareOperation("PrismGraph", [IsPosInt]); +DeclareOperation("PrismGraph", [IsFunction, IsPosInt]); + +DeclareConstructor("MobiusLadderGraphCons", [IsDigraph, IsPosInt]); +DeclareOperation("MobiusLadderGraph", [IsPosInt]); +DeclareOperation("MobiusLadderGraph", [IsFunction, IsPosInt]); + +DeclareConstructor("WalshHadamardGraphCons", [IsDigraph, IsPosInt]); +DeclareOperation("WalshHadamardGraph", [IsPosInt]); +DeclareOperation("WalshHadamardGraph", [IsFunction, IsPosInt]); + +DeclareConstructor("HalvedCubeGraphCons", [IsDigraph, IsPosInt]); +DeclareOperation("HalvedCubeGraph", [IsPosInt]); +DeclareOperation("HalvedCubeGraph", [IsFunction, IsPosInt]); + +DeclareConstructor("WheelGraphCons", [IsDigraph, IsPosInt]); +DeclareOperation("WheelGraph", [IsPosInt]); +DeclareOperation("WheelGraph", [IsFunction, IsPosInt]); + +DeclareConstructor("HelmGraphCons", [IsDigraph, IsPosInt]); +DeclareOperation("HelmGraph", [IsPosInt]); +DeclareOperation("HelmGraph", [IsFunction, IsPosInt]); + +DeclareConstructor("HypercubeGraphCons", [IsDigraph, IsInt]); +DeclareOperation("HypercubeGraph", [IsInt]); +DeclareOperation("HypercubeGraph", [IsFunction, IsInt]); + +DeclareConstructor("LindgrenSousselierGraphCons", [IsDigraph, IsPosInt]); +DeclareOperation("LindgrenSousselierGraph", [IsPosInt]); +DeclareOperation("LindgrenSousselierGraph", [IsFunction, IsPosInt]); + +DeclareConstructor("KneserGraphCons", [IsDigraph, IsPosInt, IsPosInt]); +DeclareOperation("KneserGraph", [IsPosInt, IsPosInt]); +DeclareOperation("KneserGraph", [IsFunction, IsPosInt, IsPosInt]); + +DeclareConstructor("MycielskiGraphCons", [IsDigraph, IsPosInt]); +DeclareOperation("MycielskiGraph", [IsPosInt]); +DeclareOperation("MycielskiGraph", [IsFunction, IsPosInt]); + +DeclareConstructor("OddGraphCons", [IsDigraph, IsInt]); +DeclareOperation("OddGraph", [IsInt]); +DeclareOperation("OddGraph", [IsFunction, IsInt]); + +DeclareConstructor("AndrasfaiGraphCons", [IsDigraph, IsPosInt]); +DeclareOperation("AndrasfaiGraph", [IsPosInt]); +DeclareOperation("AndrasfaiGraph", [IsFunction, IsPosInt]); + +DeclareConstructor("CirculantGraphCons", [IsDigraph, IsPosInt, IsList]); +DeclareOperation("CirculantGraph", [IsPosInt, IsList]); +DeclareOperation("CirculantGraph", [IsFunction, IsPosInt, IsList]); + +DeclareConstructor("KellerGraphCons", [IsDigraph, IsInt]); +DeclareOperation("KellerGraph", [IsInt]); +DeclareOperation("KellerGraph", [IsFunction, IsInt]); + +DeclareConstructor("PermutationStarGraphCons", [IsDigraph, IsPosInt, IsInt]); +DeclareOperation("PermutationStarGraph", [IsPosInt, IsInt]); +DeclareOperation("PermutationStarGraph", [IsFunction, IsPosInt, IsInt]); + +DeclareConstructor("WindmillGraphCons", [IsDigraph, IsPosInt, IsPosInt]); +DeclareOperation("WindmillGraph", [IsPosInt, IsPosInt]); +DeclareOperation("WindmillGraph", [IsFunction, IsPosInt, IsPosInt]); + +DeclareConstructor("StackedPrismGraphCons", [IsDigraph, IsPosInt, IsPosInt]); +DeclareOperation("StackedPrismGraph", [IsPosInt, IsPosInt]); +DeclareOperation("StackedPrismGraph", [IsFunction, IsPosInt, IsPosInt]); + +DeclareConstructor("WebGraphCons", [IsDigraph, IsPosInt]); +DeclareOperation("WebGraph", [IsPosInt]); +DeclareOperation("WebGraph", [IsFunction, IsPosInt]); + +DeclareConstructor("HanoiGraphCons", [IsDigraph, IsPosInt]); +DeclareOperation("HanoiGraph", [IsPosInt]); +DeclareOperation("HanoiGraph", [IsFunction, IsPosInt]); + +DeclareConstructor("BondyGraphCons", [IsDigraph, IsInt]); +DeclareOperation("BondyGraph", [IsInt]); +DeclareOperation("BondyGraph", [IsFunction, IsInt]); + +DeclareConstructor("BinomialTreeGraphCons", [IsDigraph, IsPosInt]); +DeclareOperation("BinomialTreeGraph", [IsPosInt]); +DeclareOperation("BinomialTreeGraph", [IsFunction, IsPosInt]); + +DeclareConstructor("CycleGraphCons", [IsDigraph, IsPosInt]); +DeclareOperation("CycleGraph", [IsPosInt]); +DeclareOperation("CycleGraph", [IsFunction, IsPosInt]); + +DeclareConstructor("PathGraphCons", [IsDigraph, IsPosInt]); +DeclareOperation("PathGraph", [IsPosInt]); +DeclareOperation("PathGraph", [IsFunction, IsPosInt]); diff --git a/gap/examples.gi b/gap/examples.gi index bd916be38..89daaa67b 100644 --- a/gap/examples.gi +++ b/gap/examples.gi @@ -425,6 +425,141 @@ function(filt, n, k) return D; end); +InstallMethod(PrismGraphCons, "for IsMutableDigraph and an integer", +[IsMutableDigraph, IsPosInt], +function(filt, n) + local D; + if n < 3 then + ErrorNoReturn("the argument must be an integer equal to 3 or more,"); + else + D := GeneralisedPetersenGraph(IsMutableDigraph, n, 1); + return D; + fi; +end); + +InstallMethod(PrismGraphCons, +"for IsImmutableDigraph, integer", +[IsImmutableDigraph, IsPosInt], +function(filt, n) + local D; + D := MakeImmutable(PrismGraphCons(IsMutableDigraph, n)); + SetIsMultiDigraph(D, false); + SetIsSymmetricDigraph(D, true); + return D; +end); + +InstallMethod(PrismGraph, "for an integer", [IsPosInt], +n -> PrismGraphCons(IsImmutableDigraph, n)); + +InstallMethod(PrismGraph, "for a function and an integer", +[IsFunction, IsPosInt], PrismGraphCons); + +InstallMethod(MobiusLadderGraphCons, "for IsMutableDigraph and an integer", +[IsMutableDigraph, IsPosInt], +function(filt, n) + local D, i; + if n < 4 then + ErrorNoReturn("the argument must be an integer equal to 4 or more,"); + fi; + D := CycleGraph(IsMutableDigraph, 2 * n); + for i in [1 .. n] do + DigraphAddEdge(D, i, i + n); + DigraphAddEdge(D, i + n, i); + od; + return DigraphSymmetricClosure(D); +end); + +InstallMethod(MobiusLadderGraphCons, +"for IsImmutableDigraph, integer", +[IsImmutableDigraph, IsPosInt], +function(filt, n) + local D; + D := MakeImmutable(MobiusLadderGraphCons(IsMutableDigraph, n)); + SetIsMultiDigraph(D, false); + SetIsSymmetricDigraph(D, true); + return D; +end); + +InstallMethod(MobiusLadderGraph, "for an integer", [IsPosInt], +n -> MobiusLadderGraphCons(IsImmutableDigraph, n)); + +InstallMethod(MobiusLadderGraph, "for a function and an integer", +[IsFunction, IsPosInt], MobiusLadderGraphCons); + +InstallMethod(WalshHadamardGraphCons, "for IsMutableDigraph and an integer", +[IsMutableDigraph, IsPosInt], +function(filt, n) + local H_2, H_n, i, D, j, sideHn; + H_2 := [[1, 1], + [1, -1]]; + H_n := [[1]]; + if n > 1 then + for i in [2 .. n] do + H_n := KroneckerProduct(H_2, H_n); + od; + fi; + sideHn := Length(H_n); + D := Digraph(IsMutableDigraph, []); + DigraphAddVertices(D, 4 * sideHn); + for i in [1 .. sideHn] do + for j in [1 .. sideHn] do + if H_n[i][j] = 1 then + DigraphAddEdge(D, i, 2 * sideHn + j); + DigraphAddEdge(D, sideHn + i, 3 * sideHn + j); + else + DigraphAddEdge(D, i, 3 * sideHn + j); + DigraphAddEdge(D, sideHn + i, 2 * sideHn + j); + fi; + od; + od; + return DigraphSymmetricClosure(D); +end); + +InstallMethod(WalshHadamardGraphCons, +"for IsImmutableDigraph, integer", +[IsImmutableDigraph, IsPosInt], +function(filt, n) + local D; + D := MakeImmutable(WalshHadamardGraphCons(IsMutableDigraph, n)); + SetIsMultiDigraph(D, false); + SetIsSymmetricDigraph(D, true); + SetIsDistanceRegularDigraph(D, true); + return D; +end); + +InstallMethod(WalshHadamardGraph, "for an integer", [IsPosInt], +n -> WalshHadamardGraphCons(IsImmutableDigraph, n)); + +InstallMethod(WalshHadamardGraph, "for a function and an integer", +[IsFunction, IsPosInt], WalshHadamardGraphCons); + +InstallMethod(HalvedCubeGraphCons, "for IsMutableDigraph and an integer", +[IsMutableDigraph, IsPosInt], +function(filt, n) + local D, tuples, vertices, i, j; + tuples := Tuples([0, 1], n); + vertices := List([1 .. (2 ^ (n - 1))], x -> []); + j := 1; + for i in [1 .. Length(tuples)] do + if Sum(tuples[i]) mod 2 = 0 then + vertices[j] := tuples[i]; + j := j + 1; + fi; + od; + D := Digraph(IsMutableDigraph, []); + DigraphAddVertices(D, [1 .. Length(vertices)]); + for i in [1 .. Length(vertices) - 1] do + for j in [i + 1 .. Length(vertices)] do + if SizeBlist(List([1 .. Length(vertices[i])], + x -> vertices[i][x] <> vertices[j][x])) = 2 then + DigraphAddEdge(D, i, j); + DigraphAddEdge(D, j, i); + fi; + od; + od; + return D; +end); + InstallMethod(KingsGraphCons, "for IsImmutableDigraph and two positive integers", [IsImmutableDigraph, IsPosInt, IsPosInt], @@ -502,6 +637,294 @@ function(filt, n, k) return D; end); +InstallMethod(HalvedCubeGraphCons, +"for IsImmutableDigraph, integer", +[IsImmutableDigraph, IsPosInt], +function(filt, n) + local D; + D := MakeImmutable(HalvedCubeGraphCons(IsMutableDigraph, n)); + SetIsMultiDigraph(D, false); + SetIsSymmetricDigraph(D, true); + SetIsEmptyDigraph(D, n = 1); + SetIsDistanceRegularDigraph(D, true); + SetIsHamiltonianDigraph(D, true); + return D; +end); + +InstallMethod(HalvedCubeGraph, "for an integer", [IsPosInt], +n -> HalvedCubeGraphCons(IsImmutableDigraph, n)); + +InstallMethod(HalvedCubeGraph, "for a function and an integer", +[IsFunction, IsPosInt], HalvedCubeGraphCons); + +InstallMethod(HypercubeGraphCons, "for IsMutableDigraph and an integer", +[IsMutableDigraph, IsInt], +function(filt, n) + local D, vertices, i, j; + if n < 0 then + ErrorNoReturn("the argument must be a non-negative integer,"); + fi; + vertices := Tuples([0, 1], n); + D := Digraph(IsMutableDigraph, []); + DigraphAddVertices(D, [1 .. Length(vertices)]); + for i in [1 .. Length(vertices) - 1] do + for j in [i + 1 .. Length(vertices)] do + if SizeBlist(List([1 .. Length(vertices[i])], + x -> vertices[i][x] <> vertices[j][x])) = 1 then + DigraphAddEdge(D, i, j); + DigraphAddEdge(D, j, i); + fi; + od; + od; + return D; +end); + +InstallMethod(HypercubeGraphCons, +"for IsImmutableDigraph, integer", +[IsImmutableDigraph, IsInt], +function(filt, n) + local D; + D := MakeImmutable(HypercubeGraphCons(IsMutableDigraph, n)); + SetIsMultiDigraph(D, false); + SetIsSymmetricDigraph(D, true); + SetIsEmptyDigraph(D, n = 0); + SetIsHamiltonianDigraph(D, true); + SetIsDistanceRegularDigraph(D, true); + SetIsBipartiteDigraph(D, true); + return D; +end); + +InstallMethod(HypercubeGraph, "for an integer", [IsInt], +n -> HypercubeGraphCons(IsImmutableDigraph, n)); + +InstallMethod(HypercubeGraph, "for a function and an integer", +[IsFunction, IsInt], HypercubeGraphCons); + +InstallMethod(CycleGraphCons, "for IsMutableDigraph and an integer", +[IsMutableDigraph, IsPosInt], +function(filt, n) + if n < 3 then + ErrorNoReturn("the argument must be an integer greater than 2,"); + fi; + return DigraphSymmetricClosure(CycleDigraph(filt, n)); +end); + +InstallMethod(CycleGraphCons, +"for IsImmutableDigraph, integer", +[IsImmutableDigraph, IsPosInt], +function(filt, n) + local D; + D := MakeImmutable(CycleGraphCons(IsMutableDigraph, n)); + SetIsMultiDigraph(D, false); + SetIsSymmetricDigraph(D, true); + return D; +end); + +InstallMethod(CycleGraph, "for an integer", [IsPosInt], +n -> CycleGraphCons(IsImmutableDigraph, n)); + +InstallMethod(CycleGraph, "for a function and an integer", +[IsFunction, IsPosInt], CycleGraphCons); + +InstallMethod(WheelGraphCons, "for IsMutableDigraph and an integer", +[IsMutableDigraph, IsPosInt], +function(filt, n) + local D; + if n < 4 then + ErrorNoReturn("the argument must be an integer greater than 3,"); + fi; + D := CycleGraph(IsMutableDigraph, n - 1); + DigraphAddVertex(D, 1); + DigraphAddEdges(D, List([1 .. n - 1], x -> [x, n])); + DigraphAddEdges(D, List([1 .. n - 1], x -> [n, x])); + return D; +end); + +InstallMethod(WheelGraphCons, +"for IsImmutableDigraph, integer", +[IsImmutableDigraph, IsPosInt], +function(filt, n) + local D; + D := MakeImmutable(WheelGraphCons(IsMutableDigraph, n)); + SetIsMultiDigraph(D, false); + SetIsSymmetricDigraph(D, true); + SetIsHamiltonianDigraph(D, true); + SetIsPlanarDigraph(D, true); + if (n mod 2) = 1 then + SetChromaticNumber(D, 3); + else + SetChromaticNumber(D, 4); + fi; + return D; +end); + +InstallMethod(WheelGraph, "for an integer", [IsPosInt], +n -> WheelGraphCons(IsImmutableDigraph, n)); + +InstallMethod(WheelGraph, "for a function and an integer", +[IsFunction, IsPosInt], WheelGraphCons); + +InstallMethod(HelmGraphCons, "for IsMutableDigraph and an integer", +[IsMutableDigraph, IsPosInt], +function(filt, n) + local D; + if n < 3 then + ErrorNoReturn("the argument must be an integer greater than 2,"); + fi; + D := WheelGraph(IsMutableDigraph, n + 1); + DigraphAddVertices(D, n); + DigraphAddEdges(D, List([1 .. n], x -> [x, x + n + 1])); + DigraphSymmetricClosure(D); + return D; +end); + +InstallMethod(HelmGraphCons, +"for IsImmutableDigraph, integer", +[IsImmutableDigraph, IsPosInt], +function(filt, n) + local D; + D := MakeImmutable(HelmGraphCons(IsMutableDigraph, n)); + SetIsMultiDigraph(D, false); + SetIsSymmetricDigraph(D, true); + return D; +end); + +InstallMethod(HelmGraph, "for an integer", [IsPosInt], +n -> HelmGraphCons(IsImmutableDigraph, n)); + +InstallMethod(HelmGraph, "for a function and an integer", +[IsFunction, IsPosInt], HelmGraphCons); + +InstallMethod(GearGraphCons, "for IsMutableDigraph and an integer", +[IsMutableDigraph, IsPosInt], +function(filt, n) + local D, i, central; + if n < 3 then + ErrorNoReturn("the argument must be an integer greater than 2,"); + fi; + central := 2 * n + 1; + D := CycleGraph(IsMutableDigraph, central - 1); + DigraphAddVertex(D, 1); + for i in [1 .. n] do + DigraphAddEdge(D, 2 * i, central); + DigraphAddEdge(D, central, 2 * i); + od; + return D; +end); + +InstallMethod(GearGraphCons, +"for IsImmutableDigraph, integer", +[IsImmutableDigraph, IsPosInt], +function(filt, n) + local D; + D := MakeImmutable(GearGraphCons(IsMutableDigraph, n)); + SetIsMultiDigraph(D, false); + SetIsSymmetricDigraph(D, true); + return D; +end); + +InstallMethod(GearGraph, "for an integer", [IsPosInt], +n -> GearGraphCons(IsImmutableDigraph, n)); + +InstallMethod(GearGraph, "for a function and an integer", +[IsFunction, IsPosInt], GearGraphCons); + +InstallMethod(LindgrenSousselierGraphCons, "for IsMutableDigraph and an integer", +[IsMutableDigraph, IsPosInt], +function(filt, n) + local D, central, i, threei; + central := 6 * n + 4; + D := CycleGraph(IsMutableDigraph, central - 1); + DigraphAddVertex(D, 1); + for i in [0 .. (2 * n)] do + threei := 3 * i; + DigraphAddEdge(D, central, threei + 1); + DigraphAddEdge(D, threei + 1, central); + if i <> 2 * n then + DigraphAddEdge(D, 2 + threei, 6 + threei); + DigraphAddEdge(D, 6 + threei, 2 + threei); + fi; + od; + DigraphAddEdge(D, central - 2, 3); + DigraphAddEdge(D, 3, central - 2); + return D; +end); + +InstallMethod(LindgrenSousselierGraphCons, +"for IsImmutableDigraph, integer", +[IsImmutableDigraph, IsPosInt], +function(filt, n) + local D; + D := MakeImmutable(LindgrenSousselierGraphCons(IsMutableDigraph, n)); + SetIsMultiDigraph(D, false); + SetIsSymmetricDigraph(D, true); + SetIsHamiltonianDigraph(D, false); + return D; +end); + +InstallMethod(LindgrenSousselierGraph, "for an integer", [IsPosInt], +n -> LindgrenSousselierGraphCons(IsImmutableDigraph, n)); + +InstallMethod(LindgrenSousselierGraph, "for a function and an integer", +[IsFunction, IsPosInt], LindgrenSousselierGraphCons); + +InstallMethod(BondyGraphCons, "for IsMutableDigraph and an integer", +[IsMutableDigraph, IsInt], +function(filt, n) + if n < 0 then + ErrorNoReturn("the argument must be a non-negative integer,"); + fi; + return GeneralisedPetersenGraph(IsMutableDigraph, 3 * (2 * n + 1) + 2, 2); +end); + +InstallMethod(BondyGraphCons, +"for IsImmutableDigraph, integer", +[IsImmutableDigraph, IsInt], +function(filt, n) + local D; + D := MakeImmutable(BondyGraphCons(IsMutableDigraph, n)); + SetIsMultiDigraph(D, false); + SetIsSymmetricDigraph(D, true); + SetIsHamiltonianDigraph(D, false); + return D; +end); + +InstallMethod(BondyGraph, "for an integer", [IsInt], +n -> BondyGraphCons(IsImmutableDigraph, n)); + +InstallMethod(BondyGraph, "for a function and an integer", +[IsFunction, IsInt], BondyGraphCons); + +InstallMethod(KneserGraphCons, "for IsMutableDigraph and two integers", +[IsMutableDigraph, IsPosInt, IsPosInt], +function(filt, n, k) + local D, tuples, vertices, i, j; + if n < k then + ErrorNoReturn("argument must be greater than or equal to argument ,"); + fi; + tuples := Tuples([0, 1], n); + vertices := List([1 .. Binomial(n, k)], x -> []); + j := 1; + for i in [1 .. Length(tuples)] do + if Sum(tuples[i]) = k then + vertices[j] := tuples[i]; + j := j + 1; + fi; + od; + D := Digraph(IsMutableDigraph, []); + DigraphAddVertices(D, [1 .. Length(vertices)]); + for i in [1 .. Length(vertices) - 1] do + for j in [i + 1 .. Length(vertices)] do + if SizeBlist(List([1 .. Length(vertices[i])], + x -> vertices[i][x] = 1 and vertices[j][x] = 1)) = 0 then + DigraphAddEdge(D, i, j); + DigraphAddEdge(D, j, i); + fi; + od; + od; + return D; +end); + InstallMethod(TriangularGridGraphCons, "for IsImmutableDigraph and two positive integers", [IsImmutableDigraph, IsPosInt, IsPosInt], @@ -658,6 +1081,307 @@ function(filt, m, n) return D; end); +InstallMethod(KneserGraphCons, +"for IsImmutableDigraph, integer, integer", +[IsImmutableDigraph, IsPosInt, IsPosInt], +function(filt, n, k) + local D; + D := MakeImmutable(KneserGraphCons(IsMutableDigraph, n, k)); + SetIsMultiDigraph(D, false); + SetIsSymmetricDigraph(D, true); + SetIsRegularDigraph(D, true); + SetIsVertexTransitive(D, true); + SetIsEdgeTransitive(D, true); + if n >= 2 * k then + SetChromaticNumber(D, n - 2 * k + 2); + else + SetChromaticNumber(D, 1); + fi; + if Float(n) >= ((3 + 5 ^ 0.5) / 2) * Float(k) + 1 then + SetIsHamiltonianDigraph(D, true); + fi; + SetCliqueNumber(D, Int(n / k)); + return D; +end); + +InstallMethod(KneserGraph, "for two integers", [IsPosInt, IsPosInt], +{n, k} -> KneserGraphCons(IsImmutableDigraph, n, k)); + +InstallMethod(KneserGraph, "for a function and two integers", +[IsFunction, IsPosInt, IsPosInt], KneserGraphCons); + +InstallMethod(MycielskiGraphCons, "for IsMutableDigraph and an integer", +[IsMutableDigraph, IsPosInt], +function(filt, n) + local D, i; + if n < 2 then + ErrorNoReturn("the argument must be an integer greater than 1,"); + fi; + D := Digraph(IsMutableDigraph, []); + DigraphAddVertices(D, 2); + DigraphAddEdges(D, [[1, 2], [2, 1]]); + for i in [3 .. n] do + D := DigraphMycielskian(D); + od; + return D; +end); + +InstallMethod(MycielskiGraphCons, +"for IsImmutableDigraph, integer", +[IsImmutableDigraph, IsPosInt], +function(filt, n) + local D; + D := MakeImmutable(MycielskiGraphCons(IsMutableDigraph, n)); + SetIsMultiDigraph(D, false); + SetIsSymmetricDigraph(D, true); + SetChromaticNumber(D, n); + SetCliqueNumber(D, 2); + SetIsHamiltonianDigraph(D, true); + return D; +end); + +InstallMethod(MycielskiGraph, "for an integer", [IsPosInt], +n -> MycielskiGraphCons(IsImmutableDigraph, n)); + +InstallMethod(MycielskiGraph, "for a function and an integer", +[IsFunction, IsPosInt], MycielskiGraphCons); + +InstallMethod(OddGraphCons, "for IsMutableDigraph and an integer", +[IsMutableDigraph, IsInt], +function(filt, n) + if n < 1 then + ErrorNoReturn("the argument must be an integer greater than 0,"); + fi; + return KneserGraph(IsMutableDigraph, 2 * n - 1, n - 1); +end); + +InstallMethod(OddGraphCons, +"for IsImmutableDigraph, integer", +[IsImmutableDigraph, IsInt], +function(filt, n) + local D; + D := MakeImmutable(OddGraphCons(IsMutableDigraph, n)); + SetIsMultiDigraph(D, false); + SetIsSymmetricDigraph(D, true); + SetIsVertexTransitive(D, true); + SetIsEdgeTransitive(D, true); + SetIsRegularDigraph(D, true); + SetIsDistanceRegularDigraph(D, true); + SetChromaticNumber(D, 3); + return D; +end); + +InstallMethod(OddGraph, "for an integer", [IsInt], +n -> OddGraphCons(IsImmutableDigraph, n)); + +InstallMethod(OddGraph, "for a function and an integer", +[IsFunction, IsInt], OddGraphCons); + +InstallMethod(KellerGraphCons, "for IsMutableDigraph and an integer", +[IsMutableDigraph, IsInt], +function(filt, n) + local D, vertices, i, j; + if (not IsInt(n)) or n < 0 then + ErrorNoReturn("the argument must be a non-negative integer,"); + fi; + vertices := Tuples([0, 1, 2, 3], n); + D := Digraph(IsMutableDigraph, []); + DigraphAddVertices(D, Length(vertices)); + for i in [1 .. Length(vertices) - 1] do + for j in [i + 1 .. Length(vertices)] do + if SizeBlist(List([1 .. Length(vertices[i])], + x -> vertices[i][x] <> vertices[j][x])) > 1 and + SizeBlist(List([1 .. Length(vertices[i])], + x -> AbsInt(vertices[i][x] - vertices[j][x]) mod 4 = 2)) > 0 then + DigraphAddEdge(D, i, j); + DigraphAddEdge(D, j, i); + fi; + od; + od; + return D; +end); + +InstallMethod(KellerGraphCons, +"for IsImmutableDigraph, integer", +[IsImmutableDigraph, IsInt], +function(filt, n) + local D; + D := MakeImmutable(KellerGraphCons(IsMutableDigraph, n)); + SetIsMultiDigraph(D, false); + SetIsSymmetricDigraph(D, true); + if n > 1 then + SetChromaticNumber(D, 2 ^ n); + SetIsHamiltonianDigraph(D, true); + else + SetIsEmptyDigraph(D, true); + fi; + return D; +end); + +InstallMethod(KellerGraph, "for an integer", [IsInt], +n -> KellerGraphCons(IsImmutableDigraph, n)); + +InstallMethod(KellerGraph, "for a function and an integer", +[IsFunction, IsInt], KellerGraphCons); + +InstallMethod(CirculantGraphCons, "for IsMutableDigraph, an integer and a list", +[IsMutableDigraph, IsPosInt, IsList], +function(filt, n, par) + local D, i, j; + if (n < 2) or (not ForAll(par, x -> IsInt(x) and x in [1 .. n])) then + ErrorNoReturn("arguments must be an integer greater ", + "than 1 and a list of integers between 1 and n,"); + fi; + D := Digraph(IsMutableDigraph, []); + DigraphAddVertices(D, n); + for i in [1 .. n] do + for j in par do + if (i - j) mod n = 0 then + DigraphAddEdge(D, i, n); + else + DigraphAddEdge(D, i, (i - j) mod n); + fi; + if (i + j) mod n = 0 then + DigraphAddEdge(D, i, n); + else + DigraphAddEdge(D, i, (i + j) mod n); + fi; + od; + od; + return DigraphRemoveAllMultipleEdges(DigraphSymmetricClosure(D)); +end); + +InstallMethod(CirculantGraphCons, +"for IsImmutableDigraph, integer, list of integers", +[IsImmutableDigraph, IsPosInt, IsList], +function(filt, n, par) + local D; + D := MakeImmutable(CirculantGraphCons(IsMutableDigraph, n, par)); + SetIsMultiDigraph(D, false); + SetIsSymmetricDigraph(D, true); + SetIsAcyclicDigraph(D, false); + SetIsRegularDigraph(D, true); + SetIsVertexTransitive(D, true); + SetIsHamiltonianDigraph(D, true); + SetIsBiconnectedDigraph(D, true); + return D; +end); + +InstallMethod(CirculantGraph, "for an integer and a list", [IsPosInt, IsList], +{n, par} -> CirculantGraphCons(IsImmutableDigraph, n, par)); + +InstallMethod(CirculantGraph, "for a function and an integer", +[IsFunction, IsPosInt, IsList], CirculantGraphCons); + +InstallMethod(AndrasfaiGraphCons, "for IsMutableDigraph and an integer", +[IsMutableDigraph, IsPosInt], +function(filt, n) + local js; + js := List([0 .. (n - 1)], x -> (3 * x) + 1); + return CirculantGraph(IsMutableDigraph, (3 * n) - 1, js); +end); + +InstallMethod(AndrasfaiGraphCons, +"for IsImmutableDigraph, integer", +[IsImmutableDigraph, IsPosInt], +function(filt, n) + local D; + D := MakeImmutable(AndrasfaiGraphCons(IsMutableDigraph, n)); + SetIsMultiDigraph(D, false); + SetIsSymmetricDigraph(D, true); + SetIsAcyclicDigraph(D, false); + SetIsRegularDigraph(D, true); + SetIsVertexTransitive(D, true); + SetIsHamiltonianDigraph(D, true); + SetIsBiconnectedDigraph(D, true); + return D; +end); + +InstallMethod(AndrasfaiGraph, "for an integer", [IsPosInt], +n -> AndrasfaiGraphCons(IsImmutableDigraph, n)); + +InstallMethod(AndrasfaiGraph, "for a function and an integer", +[IsFunction, IsPosInt], AndrasfaiGraphCons); + +InstallMethod(PermutationStarGraphCons, "for IsMutableDigraph and two integers", +[IsMutableDigraph, IsPosInt, IsInt], +function(filt, n, k) + local D, permList, vertices, bList, pos, i, j; + if k < 0 then + ErrorNoReturn("the arguments and must be integers, ", + "with n greater than 0 and k non-negative,"); + fi; + if k > n then + Error("the argument must be greater than or equal to ,"); + fi; + permList := PermutationsList([1 .. n]); + vertices := Unique(List(permList, x -> List([1 .. k], y -> x[y]))); + D := Digraph(IsMutableDigraph, []); + DigraphAddVertices(D, Length(vertices)); + for i in [1 .. Length(vertices) - 1] do + for j in [i + 1 .. Length(vertices)] do + bList := List([1 .. Length(vertices[i])], + x -> vertices[i][x] <> vertices[j][x]); + pos := Positions(bList, true); + if bList[1] then + if (SizeBlist(bList) = 2 and + vertices[j][pos[2]] = vertices[i][pos[1]] and + vertices[j][pos[1]] = vertices[i][pos[2]]) or + (SizeBlist(bList) = 1 and (not vertices[j][1] in vertices[i])) then + DigraphAddEdge(D, i, j); + DigraphAddEdge(D, j, i); + fi; + fi; + od; + od; + return D; +end); + +InstallMethod(PermutationStarGraphCons, +"for IsImmutableDigraph, integer, integer", +[IsImmutableDigraph, IsPosInt, IsInt], +function(filt, n, k) + local D; + D := MakeImmutable(PermutationStarGraphCons(IsMutableDigraph, n, k)); + SetIsMultiDigraph(D, false); + SetIsSymmetricDigraph(D, true); + SetIsRegularDigraph(D, true); + SetIsVertexTransitive(D, true); + if k <= Int(n / 2) then + SetDigraphDiameter(D, 2 * k - 1); + else + SetDigraphDiameter(D, Int((n - 1) / 2) + k); + fi; + return D; +end); + +InstallMethod(PermutationStarGraph, "for two integers", [IsPosInt, IsInt], +{n, k} -> PermutationStarGraphCons(IsImmutableDigraph, n, k)); + +InstallMethod(PermutationStarGraph, "for a function and two integers", +[IsFunction, IsPosInt, IsInt], PermutationStarGraphCons); + +InstallMethod(WindmillGraphCons, "for IsMutableDigraph and two integers", +[IsMutableDigraph, IsPosInt, IsPosInt], +function(filt, n, m) + local D, i, K, nrVert; + if m < 2 or n < 2 then + ErrorNoReturn("the arguments and must be integers greater than 1,"); + fi; + D := Digraph(IsMutableDigraph, []); + K := CompleteDigraph(n - 1); + nrVert := 1 + DigraphNrVertices(K) * m; + DigraphAddVertices(D, nrVert); + for i in [0 .. (m - 1)] do + DigraphAddEdges(D, DigraphEdges(K) + (i * DigraphNrVertices(K))); + od; + for i in [1 .. (DigraphNrVertices(D) - 1)] do + DigraphAddEdge(D, i, nrVert); + DigraphAddEdge(D, nrVert, i); + od; + return D; +end); + InstallMethod(BananaTreeCons, "for IsImmutableDigraph and two positive integers", [IsImmutableDigraph, IsPosInt, IsPosInt], @@ -711,6 +1435,110 @@ function(filt, m, n) return D; end); +InstallMethod(WindmillGraphCons, +"for IsImmutableDigraph, integer, integer", +[IsImmutableDigraph, IsPosInt, IsPosInt], +function(filt, n, m) + local D; + D := MakeImmutable(WindmillGraphCons(IsMutableDigraph, n, m)); + SetIsMultiDigraph(D, false); + SetIsSymmetricDigraph(D, true); + SetChromaticNumber(D, n); + SetDigraphDiameter(D, 2); + return D; +end); + +InstallMethod(WindmillGraph, "for two integers", [IsPosInt, IsPosInt], +{n, m} -> WindmillGraphCons(IsImmutableDigraph, n, m)); + +InstallMethod(WindmillGraph, "for a function and two integers", +[IsFunction, IsPosInt, IsPosInt], WindmillGraphCons); + +InstallMethod(PathGraphCons, "for IsMutableDigraph and an integer", +[IsMutableDigraph, IsPosInt], +function(filt, n) + local D; + D := Digraph(IsMutableDigraph, []); + DigraphAddVertices(D, n); + DigraphAddEdges(D, List([1 .. (n - 1)], x -> [x, x + 1])); + return DigraphSymmetricClosure(D); +end); + +InstallMethod(PathGraphCons, +"for IsImmutableDigraph, integer", +[IsImmutableDigraph, IsPosInt], +function(filt, n) + local D; + D := MakeImmutable(PathGraphCons(IsMutableDigraph, n)); + SetIsMultiDigraph(D, false); + SetIsSymmetricDigraph(D, true); + SetIsAcyclicDigraph(D, true); + SetIsEmptyDigraph(D, n = 1); + return D; +end); + +InstallMethod(PathGraph, "for an integer", [IsPosInt], +n -> PathGraphCons(IsImmutableDigraph, n)); + +InstallMethod(PathGraph, "for a function and an integer", +[IsFunction, IsPosInt], PathGraphCons); + +InstallMethod(StackedPrismGraphCons, "for IsMutableDigraph and two integers", +[IsMutableDigraph, IsPosInt, IsPosInt], +function(filt, n, k) + if n < 3 then + ErrorNoReturn("the arguments and must be integers, ", + "with greater than 2 and greater than 0,"); + fi; + return DigraphCartesianProduct(CycleGraph(IsMutableDigraph, n), + PathGraph(IsMutableDigraph, k)); +end); + +InstallMethod(StackedPrismGraphCons, +"for IsImmutableDigraph, integer, integer", +[IsImmutableDigraph, IsPosInt, IsPosInt], +function(filt, n, k) + local D; + D := MakeImmutable(StackedPrismGraphCons(IsMutableDigraph, n, k)); + SetIsMultiDigraph(D, false); + SetIsSymmetricDigraph(D, true); + return D; +end); + +InstallMethod(StackedPrismGraph, "for two integers", [IsPosInt, IsPosInt], +{n, k} -> StackedPrismGraphCons(IsImmutableDigraph, n, k)); + +InstallMethod(StackedPrismGraph, "for a function and two integers", +[IsFunction, IsPosInt, IsPosInt], StackedPrismGraphCons); + +InstallMethod(WebGraphCons, "for IsMutableDigraph and an integer", +[IsMutableDigraph, IsPosInt], +function(filt, n) + local D, i; + if n < 3 then + ErrorNoReturn("the argument must be an integer greater than 2,"); + fi; + D := StackedPrismGraph(IsMutableDigraph, n, 3); + for i in [1 .. (n - 1)] do + D := DigraphRemoveEdge(D, i, i + 1); + D := DigraphRemoveEdge(D, i + 1, i); + od; + D := DigraphRemoveEdge(D, n, 1); + D := DigraphRemoveEdge(D, 1, n); + return D; +end); + +InstallMethod(WebGraphCons, +"for IsImmutableDigraph, integer", +[IsImmutableDigraph, IsPosInt], +function(filt, n) + local D; + D := MakeImmutable(WebGraphCons(IsMutableDigraph, n)); + SetIsMultiDigraph(D, false); + SetIsSymmetricDigraph(D, true); + return D; +end); + InstallMethod(BookDigraphCons, "for IsMutableDigraph and one positive integer", [IsMutableDigraph, IsPosInt], @@ -738,3 +1566,95 @@ function(filt, m) SetIsBipartiteDigraph(D, true); return D; end); + +InstallMethod(WebGraph, "for an integer", [IsPosInt], +n -> WebGraphCons(IsImmutableDigraph, n)); + +InstallMethod(WebGraph, "for a function and an integer", +[IsFunction, IsPosInt], WebGraphCons); + +InstallMethod(HanoiGraphCons, "for IsMutableDigraph and an integer", +[IsMutableDigraph, IsPosInt], +function(filt, n) + local D, nrVert, prevNrVert, exp, i; + D := Digraph(IsMutableDigraph, []); + nrVert := 3 ^ n; + DigraphAddVertices(D, nrVert); + DigraphAddEdges(D, [[1, 2], [2, 3], [3, 1]]); + prevNrVert := 1; + exp := 1; + 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; + od; + + return DigraphSymmetricClosure(D); +end); + +InstallMethod(HanoiGraphCons, +"for IsImmutableDigraph, integer", +[IsImmutableDigraph, IsPosInt], +function(filt, n) + local D; + D := MakeImmutable(HanoiGraphCons(IsMutableDigraph, n)); + SetIsMultiDigraph(D, false); + SetIsSymmetricDigraph(D, true); + SetIsPlanarDigraph(D, true); + SetIsHamiltonianDigraph(D, true); + return D; +end); + +InstallMethod(HanoiGraph, "for an integer", [IsPosInt], +n -> HanoiGraphCons(IsImmutableDigraph, n)); + +InstallMethod(HanoiGraph, "for a function and an integer", +[IsFunction, IsPosInt], HanoiGraphCons); + +InstallMethod(BinomialTreeGraphCons, "for IsMutableDigraph and an integer", +[IsMutableDigraph, IsPosInt], +function(filt, n) + local bits, is2n, verts, D, rep, pos, parent, parVert, i; + bits := Log(n, 2); + is2n := IsEvenInt(n) and IsPrimePowerInt(n); + if not is2n then + bits := bits + 1; + fi; + verts := List(Tuples([0, 1], bits){[1 .. n]}, + x -> x{List([1 .. bits], y -> bits - y + 1)}); + D := Digraph(IsMutableDigraph, []); + DigraphAddVertices(D, n); + for i in [2 .. n] do # 1 is the root vertex + rep := StructuralCopy(verts[i]); + pos := Position(rep, 1); + parent := rep; + parent[pos] := 0; + parVert := Position(verts, parent); + DigraphAddEdge(D, i, parVert); + od; + + return DigraphSymmetricClosure(DigraphRemoveAllMultipleEdges(D)); +end); + +InstallMethod(BinomialTreeGraphCons, +"for IsImmutableDigraph, integer", +[IsImmutableDigraph, IsPosInt], +function(filt, n) + local D; + D := MakeImmutable(BinomialTreeGraphCons(IsMutableDigraph, n)); + SetIsMultiDigraph(D, false); + SetIsSymmetricDigraph(D, true); + SetIsEmptyDigraph(D, n = 1); + SetIsAcyclicDigraph(D, true); + return D; +end); + +InstallMethod(BinomialTreeGraph, "for an integer", [IsPosInt], +n -> BinomialTreeGraphCons(IsImmutableDigraph, n)); + +InstallMethod(BinomialTreeGraph, "for a function and an integer", +[IsFunction, IsPosInt], BinomialTreeGraphCons); diff --git a/tst/standard/examples.tst b/tst/standard/examples.tst index 8ede44549..a0749344f 100644 --- a/tst/standard/examples.tst +++ b/tst/standard/examples.tst @@ -381,6 +381,331 @@ true gap> IsBipartiteDigraph(BookDigraph(32)); true +# PrismGraph +gap> PrismGraph(3); + +gap> PrismGraph(2); +Error, the argument must be an integer equal to 3 or more, +gap> D := PrismGraph(5); + +gap> DigraphEdges(D); +[ [ 1, 2 ], [ 1, 5 ], [ 1, 6 ], [ 2, 1 ], [ 2, 3 ], [ 2, 7 ], [ 3, 2 ], + [ 3, 4 ], [ 3, 8 ], [ 4, 3 ], [ 4, 5 ], [ 4, 9 ], [ 5, 1 ], [ 5, 4 ], + [ 5, 10 ], [ 6, 1 ], [ 6, 7 ], [ 6, 10 ], [ 7, 2 ], [ 7, 6 ], [ 7, 8 ], + [ 8, 3 ], [ 8, 7 ], [ 8, 9 ], [ 9, 4 ], [ 9, 8 ], [ 9, 10 ], [ 10, 5 ], + [ 10, 6 ], [ 10, 9 ] ] + +#MobiusLadderGraph +gap> MobiusLadderGraph(2); +Error, the argument must be an integer equal to 4 or more, +gap> D := MobiusLadderGraph(4); + +gap> DigraphEdges(D); +[ [ 1, 2 ], [ 1, 8 ], [ 1, 5 ], [ 2, 1 ], [ 2, 3 ], [ 2, 6 ], [ 3, 2 ], + [ 3, 4 ], [ 3, 7 ], [ 4, 3 ], [ 4, 5 ], [ 4, 8 ], [ 5, 4 ], [ 5, 6 ], + [ 5, 1 ], [ 6, 5 ], [ 6, 7 ], [ 6, 2 ], [ 7, 6 ], [ 7, 8 ], [ 7, 3 ], + [ 8, 1 ], [ 8, 7 ], [ 8, 4 ] ] +gap> MobiusLadderGraph(10); + + +#WalshHadamardGraph +gap> WalshHadamardGraph(1); + +gap> D := WalshHadamardGraph(2); + +gap> IsIsomorphicDigraph(D, CycleGraph(8)); +true +gap> WalshHadamardGraph(0); +Error, no method found! For debugging hints type ?Recovery from NoMethodFound +Error, no 1st choice method found for `WalshHadamardGraph' on 1 arguments + +# HalvedCubeGraph +gap> HalvedCubeGraph(1); + +gap> D := HalvedCubeGraph(3); + +gap> IsIsomorphicDigraph(D, CompleteDigraph(4)); +true +gap> HalvedCubeGraph(-1); +Error, no method found! For debugging hints type ?Recovery from NoMethodFound +Error, no 1st choice method found for `HalvedCubeGraph' on 1 arguments + +# HypercubeGraph +gap> HypercubeGraph(0); + +gap> D := HypercubeGraph(2); + +gap> IsIsomorphicDigraph(D, CycleGraph(4)); +true +gap> HypercubeGraph(-1); +Error, the argument must be a non-negative integer, + +# CycleGraph +gap> IsIsomorphicDigraph(CycleGraph(5), DigraphSymmetricClosure(CycleDigraph(5))); +true +gap> CycleGraph(2); +Error, the argument must be an integer greater than 2, + +# WheelGraph +gap> D := WheelGraph(5); + +gap> DigraphEdges(D); +[ [ 1, 2 ], [ 1, 4 ], [ 1, 5 ], [ 2, 1 ], [ 2, 3 ], [ 2, 5 ], [ 3, 2 ], + [ 3, 4 ], [ 3, 5 ], [ 4, 1 ], [ 4, 3 ], [ 4, 5 ], [ 5, 1 ], [ 5, 2 ], + [ 5, 3 ], [ 5, 4 ] ] +gap> WheelGraph(2); +Error, the argument must be an integer greater than 3, +gap> ChromaticNumber(D); +3 +gap> D := WheelGraph(6); + +gap> ChromaticNumber(D); +4 + +# HelmGraph +gap> D := HelmGraph(6); + +gap> DigraphEdges(D); +[ [ 1, 2 ], [ 1, 6 ], [ 1, 7 ], [ 1, 8 ], [ 2, 1 ], [ 2, 3 ], [ 2, 7 ], + [ 2, 9 ], [ 3, 2 ], [ 3, 4 ], [ 3, 7 ], [ 3, 10 ], [ 4, 3 ], [ 4, 5 ], + [ 4, 7 ], [ 4, 11 ], [ 5, 4 ], [ 5, 6 ], [ 5, 7 ], [ 5, 12 ], [ 6, 1 ], + [ 6, 5 ], [ 6, 7 ], [ 6, 13 ], [ 7, 1 ], [ 7, 2 ], [ 7, 3 ], [ 7, 4 ], + [ 7, 5 ], [ 7, 6 ], [ 8, 1 ], [ 9, 2 ], [ 10, 3 ], [ 11, 4 ], [ 12, 5 ], + [ 13, 6 ] ] +gap> HelmGraph(1); +Error, the argument must be an integer greater than 2, + +# GearGraph +gap> D := GearGraph(4); + +gap> DigraphEdges(D); +[ [ 1, 2 ], [ 1, 8 ], [ 2, 1 ], [ 2, 3 ], [ 2, 9 ], [ 3, 2 ], [ 3, 4 ], + [ 4, 3 ], [ 4, 5 ], [ 4, 9 ], [ 5, 4 ], [ 5, 6 ], [ 6, 5 ], [ 6, 7 ], + [ 6, 9 ], [ 7, 6 ], [ 7, 8 ], [ 8, 1 ], [ 8, 7 ], [ 8, 9 ], [ 9, 2 ], + [ 9, 4 ], [ 9, 6 ], [ 9, 8 ] ] +gap> GearGraph(2); +Error, the argument must be an integer greater than 2, + +# LindgrenSousselierGraph +gap> D := LindgrenSousselierGraph(1); + +gap> AutomorphismGroup(D) = Group([(4, 8)(5, 7)(9, 10), (2, 10, 9)(3, 4, 5, 6, 7, 8), (1, 2, 3, 4, 10)(5, 7, 9, 6, 8)]); +true +gap> LindgrenSousselierGraph(0); +Error, no method found! For debugging hints type ?Recovery from NoMethodFound +Error, no 1st choice method found for `LindgrenSousselierGraph' on 1 arguments +gap> LindgrenSousselierGraph(3); + +gap> IsIsomorphicDigraph(LindgrenSousselierGraph(1), GeneralisedPetersenGraph(5, 2)); +true + +# BondyGraph +gap> D := BondyGraph(2); + +gap> IsIsomorphicDigraph(D, GeneralisedPetersenGraph(17, 2)); +true +gap> BondyGraph(-1); +Error, the argument must be a non-negative integer, + +# KneserGraph +gap> IsIsomorphicDigraph(KneserGraph(5, 1), CompleteDigraph(5)); +true +gap> KneserGraph(6, 3); + +gap> KneserGraph(3, 4); +Error, argument must be greater than or equal to argument , +gap> KneserGraph(3, -1); +Error, no method found! For debugging hints type ?Recovery from NoMethodFound +Error, no 1st choice method found for `KneserGraph' on 2 arguments +gap> KneserGraph(-1, 4); +Error, no method found! For debugging hints type ?Recovery from NoMethodFound +Error, no 1st choice method found for `KneserGraph' on 2 arguments +gap> D := KneserGraph(5, 2); + +gap> DigraphEdges(D); +[ [ 1, 6 ], [ 1, 9 ], [ 1, 10 ], [ 2, 5 ], [ 2, 8 ], [ 2, 10 ], [ 3, 4 ], + [ 3, 7 ], [ 3, 10 ], [ 4, 3 ], [ 4, 8 ], [ 4, 9 ], [ 5, 2 ], [ 5, 7 ], + [ 5, 9 ], [ 6, 1 ], [ 6, 7 ], [ 6, 8 ], [ 7, 3 ], [ 7, 5 ], [ 7, 6 ], + [ 8, 2 ], [ 8, 4 ], [ 8, 6 ], [ 9, 1 ], [ 9, 4 ], [ 9, 5 ], [ 10, 1 ], + [ 10, 2 ], [ 10, 3 ] ] + +# MycielskiGraph +gap> D := MycielskiGraph(2); + +gap> IsIsomorphicDigraph(MycielskiGraph(3), CycleGraph(5)); +true +gap> MycielskiGraph(1); +Error, the argument must be an integer greater than 1, + +# OddGraph +gap> IsIsomorphicDigraph(OddGraph(2), CycleGraph(3)); +true +gap> OddGraph(4); + +gap> OddGraph(0); +Error, the argument must be an integer greater than 0, + +# KellerGraph +gap> IsIsomorphicDigraph(EmptyDigraph(4), KellerGraph(1)); +true +gap> D := KellerGraph(2); + +gap> KellerGraph(-1); +Error, the argument must be a non-negative integer, + +# CirculantGraph +gap> D := CirculantGraph(5, [1, 2]); + +gap> IsIsomorphicDigraph(D, CompleteDigraph(5)); +true +gap> D := CirculantGraph(6, [2, 3]); + +gap> IsIsomorphicDigraph(D, PrismGraph(3)); +true +gap> D := CirculantGraph(4, [1]); + +gap> IsIsomorphicDigraph(D, CycleGraph(4)); +true +gap> CirculantGraph(4, [1, 5]); +Error, arguments must be an integer greater than 1 and a list of integers \ +between 1 and n, +gap> CirculantGraph(0, [1]); +Error, no method found! For debugging hints type ?Recovery from NoMethodFound +Error, no 1st choice method found for `CirculantGraph' on 2 arguments +gap> D := CirculantGraph(10, [1, 5]); + +gap> IsIsomorphicDigraph(D, MobiusLadderGraph(5)); +true + +# AndrasfaiGraph +gap> D := AndrasfaiGraph(1); + +gap> D := AndrasfaiGraph(3); + +gap> IsIsomorphicDigraph(D, MobiusLadderGraph(4)); +true +gap> AndrasfaiGraph(0); +Error, no method found! For debugging hints type ?Recovery from NoMethodFound +Error, no 1st choice method found for `AndrasfaiGraph' on 1 arguments + +# PermutationStarGraph +gap> D := PermutationStarGraph(3, 2); + +gap> IsIsomorphicDigraph(D, CycleGraph(6)); +true +gap> D := PermutationStarGraph(4, 3); + +gap> DigraphDiameter(D); +4 +gap> IsIsomorphicDigraph(D, GeneralisedPetersenGraph(12, 5)); +true +gap> PermutationStarGraph(2, 4); +Error, the argument must be greater than or equal to , +gap> PermutationStarGraph(5, -1); +Error, the arguments and must be integers, with n greater than 0 and k\ + non-negative, +gap> PermutationStarGraph(0, 2); +Error, no method found! For debugging hints type ?Recovery from NoMethodFound +Error, no 1st choice method found for `PermutationStarGraph' on 2 arguments + +# WindmillGraph +gap> D := WindmillGraph(3, 3); + +gap> DigraphEdges(D); +[ [ 1, 2 ], [ 1, 7 ], [ 2, 1 ], [ 2, 7 ], [ 3, 4 ], [ 3, 7 ], [ 4, 3 ], + [ 4, 7 ], [ 5, 6 ], [ 5, 7 ], [ 6, 5 ], [ 6, 7 ], [ 7, 1 ], [ 7, 2 ], + [ 7, 3 ], [ 7, 4 ], [ 7, 5 ], [ 7, 6 ] ] +gap> WindmillGraph(0, 3); +Error, no method found! For debugging hints type ?Recovery from NoMethodFound +Error, no 1st choice method found for `WindmillGraph' on 2 arguments +gap> WindmillGraph(2, 1); +Error, the arguments and must be integers greater than 1, +gap> WindmillGraph(-1, 0); +Error, no method found! For debugging hints type ?Recovery from NoMethodFound +Error, no 1st choice method found for `WindmillGraph' on 2 arguments + +# PathGraph +gap> D := PathGraph(4); + +gap> IsIsomorphicDigraph(D, DigraphSymmetricClosure(ChainDigraph(4))); +true +gap> PathGraph(1); + +gap> PathGraph(0); +Error, no method found! For debugging hints type ?Recovery from NoMethodFound +Error, no 1st choice method found for `PathGraph' on 1 arguments + +# StackedPrismGraph +gap> D := StackedPrismGraph(4, 1); + +gap> IsIsomorphicDigraph(D, CycleGraph(4)); +true +gap> D := StackedPrismGraph(5, 2); + +gap> IsIsomorphicDigraph(D, PrismGraph(5)); +true +gap> StackedPrismGraph(3, 3); + +gap> StackedPrismGraph(2, 2); +Error, the arguments and must be integers, with greater than 2 and\ + greater than 0, +gap> StackedPrismGraph(3, 0); +Error, no method found! For debugging hints type ?Recovery from NoMethodFound +Error, no 1st choice method found for `StackedPrismGraph' on 2 arguments +gap> StackedPrismGraph(0, -1); +Error, no method found! For debugging hints type ?Recovery from NoMethodFound +Error, no 1st choice method found for `StackedPrismGraph' on 2 arguments + +# WebGraph +gap> D := WebGraph(3); + +gap> DigraphEdges(D); +[ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ], [ 4, 5 ], [ 4, 6 ], [ 4, 1 ], [ 4, 7 ], + [ 5, 4 ], [ 5, 6 ], [ 5, 2 ], [ 5, 8 ], [ 6, 4 ], [ 6, 5 ], [ 6, 3 ], + [ 6, 9 ], [ 7, 8 ], [ 7, 9 ], [ 7, 4 ], [ 8, 7 ], [ 8, 9 ], [ 8, 5 ], + [ 9, 7 ], [ 9, 8 ], [ 9, 6 ] ] +gap> WebGraph(2); +Error, the argument must be an integer greater than 2, + +# HanoiGraph +gap> D := HanoiGraph(1); + +gap> IsIsomorphicDigraph(D, CycleGraph(3)); +true +gap> HanoiGraph(4); + +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 + +# BinomialTreeGraph +gap> D := BinomialTreeGraph(6); + +gap> D := BinomialTreeGraph(16); + +gap> DigraphEdges(D); +[ [ 1, 2 ], [ 1, 3 ], [ 1, 5 ], [ 1, 9 ], [ 2, 1 ], [ 3, 1 ], [ 3, 4 ], + [ 4, 3 ], [ 5, 1 ], [ 5, 6 ], [ 5, 7 ], [ 6, 5 ], [ 7, 5 ], [ 7, 8 ], + [ 8, 7 ], [ 9, 1 ], [ 9, 10 ], [ 9, 11 ], [ 9, 13 ], [ 10, 9 ], [ 11, 9 ], + [ 11, 12 ], [ 12, 11 ], [ 13, 9 ], [ 13, 14 ], [ 13, 15 ], [ 14, 13 ], + [ 15, 13 ], [ 15, 16 ], [ 16, 15 ] ] +gap> BinomialTreeGraph(1); + +gap> BinomialTreeGraph(0); +Error, no method found! For debugging hints type ?Recovery from NoMethodFound +Error, no 1st choice method found for `BinomialTreeGraph' on 1 arguments + # gap> DIGRAPHS_StopTest(); gap> STOP_TEST("Digraphs package: standard/examples.tst", 0);