Skip to content

Commit 6030e58

Browse files
author
Release Manager
committed
gh-37398: fix `relabel` for permutation groups Fixes #37379. ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> <!-- If your change requires a documentation PR, please link it appropriately --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> <!-- Feel free to remove irrelevant items. --> - [x] The title is concise, informative, and self-explanatory. - [x] The description explains in detail what this PR is about. - [x] I have linked a relevant issue or discussion. - [x] I have created tests covering the changes. - [x] I have updated the documentation accordingly. ### ⌛ Dependencies <!-- List all open PRs that this PR logically depends on - #12345: short description why this is a dependency - #34567: ... --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> URL: #37398 Reported by: David Coudert Reviewer(s): David Coudert, Travis Scrimshaw
2 parents 5bda2e2 + b3b634c commit 6030e58

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

src/sage/graphs/generic_graph.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23001,10 +23001,7 @@ def relabel(self, perm=None, inplace=True, return_map=False, check_input=True, c
2300123001
is relabeled to ``l[0]``, the second to ``l[1]``, ...
2300223002

2300323003
If ``perm`` is a permutation, then each vertex ``v`` is
23004-
relabeled to ``perm(v)``. Caveat: this assumes that the
23005-
vertices are labelled `\{0,1,...,n-1\}`; since permutations
23006-
act by default on the set `\{1,2,...,n\}`, this is achieved by
23007-
identifying `n` and `0`.
23004+
relabeled to ``perm(v)``.
2300823005

2300923006
If ``perm`` is ``None``, the graph is relabeled to be on the
2301023007
vertices `\{0,1,...,n-1\}`. This is *not* any kind of canonical
@@ -23070,6 +23067,15 @@ def relabel(self, perm=None, inplace=True, return_map=False, check_input=True, c
2307023067
[0 0 1]
2307123068
[1 1 0]
2307223069

23070+
sage: # needs sage.groups
23071+
sage: C5 = graphs.CycleGraph(5)
23072+
sage: C5.relabel({u: str(u) for u in C5}, inplace=True)
23073+
sage: ar = C5.automorphism_group().random_element()
23074+
sage: R = C5.relabel(ar, inplace=False)
23075+
sage: perm = C5.is_isomorphic(R, certificate=True)[1]
23076+
sage: perm == {u: ar(u) for u in C5}
23077+
True
23078+
2307323079
A way to get a random relabeling::
2307423080

2307523081
sage: set_random_seed(0) # Results are reproducible
@@ -23227,13 +23233,8 @@ def relabel(self, perm=None, inplace=True, return_map=False, check_input=True, c
2322723233
perm = dict(perm)
2322823234

2322923235
elif isinstance(perm, PermutationGroupElement):
23230-
n = self.order()
23231-
ddict = {}
23232-
for i in range(1, n):
23233-
ddict[i] = perm(i) % n
23234-
if n > 0:
23235-
ddict[0] = perm(n) % n
23236-
perm = ddict
23236+
# Each vertex is relabeled according to the permutation group
23237+
perm = {u: perm(u) for u in self}
2323723238

2323823239
else:
2323923240
# Check for generic iterable/callable

0 commit comments

Comments
 (0)