Skip to content

Commit e4a13f6

Browse files
Fix IsDigraphHomomorphism
1 parent a6f30ed commit e4a13f6

File tree

5 files changed

+33
-24
lines changed

5 files changed

+33
-24
lines changed

doc/grahom.xml

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -648,14 +648,27 @@ gap> EmbeddingsDigraphs(D1, D2);
648648
A permutation or transformation <A>x</A> is a <E>homomorphism</E> from a
649649
digraph <A>src</A> to a digraph <A>ran</A> if the following hold:
650650
<List>
651-
<Item>
652-
<C>[u ^ <A>x</A>, v ^ <A>x</A>]</C> is an edge of
653-
<A>ran</A> whenever <C>[u, v]</C> is an
654-
edge of <A>src</A>; and </Item>
655-
<Item>
656-
<A>x</A> fixes every <C>i</C> which is not a vertex of <A>src</A>.
657-
</Item>
651+
<Item>
652+
<C>[u ^ <A>x</A>, v ^
653+
<A>x</A>]</C> is an edge of <A>ran</A> whenever <C>[u, v]</C> is an edge of
654+
<A>src</A>; and
655+
</Item>
656+
<Item>
657+
<A>x</A> maps the vertices of <A>src</A> to a subset of the vertices of
658+
<A>ran</A>, i.e. <C>IsSubset(DigraphVertices(<A>ran</A>),
659+
OnSets(DigraphVertices(<A>src</A>), <A>x</A>))</C> is <K>true</K>.
660+
</Item>
658661
</List>
662+
663+
Note that if <C>i</C> is any integer greater than
664+
<C>DigraphNrVertice(<A>src</A>)</C>, then the action of <A>x</A> on
665+
<C>i</C> is ignored by this function. One consequence of this is that
666+
distinct transformations or permutations might represent the same
667+
homomorphism. For example, if <A>src</A> and <A>ran</A> are
668+
<C>CycleDigraph(2)</C>, then both the permutations <C>(1, 2)</C> and <C>(1,
669+
2)(3, 4)</C> represent the same automorphism of <A>src</A>.
670+
<P/>
671+
659672
See also <Ref Func="GeneratorsOfEndomorphismMonoid"/>.<P/>
660673

661674

doc/isomorph.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -814,7 +814,7 @@ true
814814
gap> IsDigraphAutomorphism(src, (2, 3), [2, 2, 1]);
815815
false
816816
gap> IsDigraphAutomorphism(src, (2, 3)(4, 5));
817-
false
817+
true
818818
gap> IsDigraphAutomorphism(src, (1, 4));
819819
false
820820
gap> IsDigraphAutomorphism(src, ());

gap/grahom.gi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ function(src, ran, x)
576576
if IsMultiDigraph(src) or IsMultiDigraph(ran) then
577577
ErrorNoReturn("the 1st and 2nd arguments <src> and <ran> must be digraphs",
578578
" with no multiple edges,");
579-
elif LargestMovedPoint(x) > DigraphNrVertices(src) then
579+
elif not IsSubset(DigraphVertices(ran), OnSets(DigraphVertices(src), x)) then
580580
return false;
581581
fi;
582582
for i in DigraphVertices(src) do

src/homos.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1748,6 +1748,7 @@ static bool init_data_from_args(Obj digraph1_obj,
17481748
set_bit_array_from_gap_list(IMAGE_RESTRICT, image_obj);
17491749
if (INT_INTOBJ(injective_obj) > 0
17501750
&& size_bit_array(IMAGE_RESTRICT, nr1) < nr1) {
1751+
// TODO shouldn't the first nr1 be nr2?
17511752
// homomorphisms should be injective (by injective_obj) but are not since
17521753
// the image is too restricted.
17531754
return false;

src/perms.c

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,34 +25,29 @@ Perm new_perm(uint16_t const degree) {
2525
}
2626

2727
Perm new_perm_from_gap(Obj gap_perm_obj, uint16_t const degree) {
28-
UInt lmp = LargestMovedPointPerm(gap_perm_obj);
29-
DIGRAPHS_ASSERT(lmp <= MAXVERTS);
30-
if (lmp > MAXVERTS) {
31-
ErrorQuit("expected permutations of degree at most %d, but got a "
32-
"permutation of degree %d",
33-
MAXVERTS,
34-
lmp);
35-
}
36-
37-
DIGRAPHS_ASSERT(lmp <= degree);
38-
3928
Perm p = new_perm(degree > 0 ? degree : 1);
4029

30+
size_t copy_up_to = degree;
31+
size_t lmp = LargestMovedPointPerm(gap_perm_obj);
32+
if (degree > lmp) {
33+
copy_up_to = lmp;
34+
}
35+
4136
if (IS_PERM2(gap_perm_obj)) {
4237
UInt2* gap_perm_ptr = ADDR_PERM2(gap_perm_obj);
43-
for (UInt i = 0; i < lmp; ++i) {
38+
for (UInt i = 0; i < copy_up_to; ++i) {
4439
p[i] = gap_perm_ptr[i];
4540
}
46-
for (UInt i = lmp; i < degree; ++i) {
41+
for (UInt i = copy_up_to; i < degree; ++i) {
4742
p[i] = i;
4843
}
4944
} else {
5045
DIGRAPHS_ASSERT(IS_PERM4(gap_perm_obj));
5146
UInt4* gap_perm_ptr = ADDR_PERM4(gap_perm_obj);
52-
for (UInt i = 0; i < lmp; ++i) {
47+
for (UInt i = 0; i < copy_up_to; ++i) {
5348
p[i] = gap_perm_ptr[i];
5449
}
55-
for (UInt i = lmp; i < degree; ++i) {
50+
for (UInt i = copy_up_to; i < degree; ++i) {
5651
p[i] = i;
5752
}
5853
}

0 commit comments

Comments
 (0)