Constructing Cayley Graphs

I am having confusions in constructing a Cayley Graph in Sage Math. Say, I want to construct the Cayley graph on the Symmetric Group $S_4$ with respect to the generating set consisting of all transpositions, what code do I use.

I tried the following minimal code:

G = SymmetricGroup(4)
CG = G.cayley_graph(generators=[PermutationGroupElement([1, 2]),
PermutationGroupElement([1, 3]),
PermutationGroupElement([1, 4]),
PermutationGroupElement([2, 3]),
PermutationGroupElement([2, 4]),
PermutationGroupElement([3, 4])])
CGU = CG.to_undirected()
CGU.show()


But, I get the error

    501         # a valid permutation (else segfaults, infinite loops may occur).
502         if not is_valid_permutation(self.perm, self.n):
--> 503             raise ValueError("invalid data to initialize a permutation")
504
505         # This is more expensive

ValueError: invalid data to initialize a permutation


How do I rectify the code so as to produce my desired Cayley Graph. Any suggestions?

edit retag close merge delete

Sort by ยป oldest newest most voted

If you enter PermutationGroupElement? at a SageMath prompt you will see the required format of the input, and that your input doesn't satisfy any of the requirements.

Moreover, from the documentation of the cayley_graph method (accessed e.g. by entering G.cayley_graph?), you can see that you don't have to be so verbose when specifying generators which are cycles.

sage: G = SymmetricGroup(4)
sage: G.cayley_graph(generators=[(1,2),(1,3),(1,4),(2,3),(2,4),(3,4)])
Digraph on 24 vertices

more