Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions doc/oper.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2133,6 +2133,34 @@ true
</ManSection>
<#/GAPDoc>

<#GAPDoc Label="IsKParadoxical">
<ManSection>
<Oper Name="IsKParadoxical" Arg="digraph, int"/>
<Returns><K>true</K> or <K>false</K>.</Returns>
<Description>
A tournament <A>D</A> is <M>k</M>-<E>paradoxical</E> if for every set
<M>S</M> of <A>k</A> vertices there is a vertex outside <M>S</M> which
is an in-neighbour of every vertex in <M>S</M>, i.e. there is one player
who beats all the players of <M>S</M>. This is a generalisation of
<Ref Oper="IsParadoxical"/>.
<P/>
If <A>D</A> has no vertices, then the answer is <K>false</K>. If <A>D</A>
has at least one vertex and <A>k</A> is <C>0</C> then the answer is
<K>true</K>.
<P/>
If <A>k</A> is negative or <A>D</A> is not a tournament (see
<Ref Prop="IsTournament"/>), then an error is raised.
<Example><![CDATA[
gap> D := Digraph([[2, 3, 5], [3, 4, 6], [4, 5, 7], [5, 6, 1], [6, 7, 2],
> [7, 1, 3], [1, 2, 4]]);;
gap> IsKParadoxical(D, 2);
true
gap> IsKParadoxical(D, 3);
false]]></Example>
</Description>
</ManSection>
<#/GAPDoc>

<#GAPDoc Label="DigraphDijkstra">
<ManSection>
<Oper Name="DigraphDijkstra" Arg="digraph, source, target" Label="for a source and target"/>
Expand Down
28 changes: 28 additions & 0 deletions doc/prop.xml
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,34 @@ false
</ManSection>
<#/GAPDoc>

<#GAPDoc Label="IsParadoxical">
<ManSection>
<Prop Name="IsParadoxical" Arg="digraph"/>
<Returns><K>true</K> or <K>false</K>.</Returns>
<Description>
A tournament <A>D</A> is <E>paradoxical</E> if every vertex has at least
one in-neighbour, i.e. each player loses at least one game. This is the
same as being <M>1</M>-paradoxical; see <Ref Oper="IsKParadoxical"/>.
<P/>
If <A>D</A> has no vertices, then the answer is <K>false</K>.
<P/>
If <A>D</A> is not a tournament (see <Ref Prop="IsTournament"/>), then an
error is raised.
<P/>

&MUTABLE_RECOMPUTED_PROP;

<Example><![CDATA[
gap> D := Digraph([[2], [3], [1]]);;
gap> IsParadoxical(D);
true
gap> D := Digraph([[2, 3], [3], []]);;
gap> IsParadoxical(D);
false]]></Example>
</Description>
</ManSection>
<#/GAPDoc>

<#GAPDoc Label="IsChainDigraph">
<ManSection>
<Prop Name="IsChainDigraph" Arg="digraph"/>
Expand Down
1 change: 1 addition & 0 deletions doc/z-chap4.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<#Include Label="DigraphOutEdges">
<#Include Label="IsDigraphEdge">
<#Include Label="IsMatching">
<#Include Label="IsKParadoxical">
<#Include Label="DigraphMaximalMatching">
<#Include Label="DigraphMaximumMatching">
</Section>
Expand Down
1 change: 1 addition & 0 deletions doc/z-chap5.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<#Include Label="IsReflexiveDigraph">
<#Include Label="IsSymmetricDigraph">
<#Include Label="IsTournament">
<#Include Label="IsParadoxical">
<#Include Label="IsTransitiveDigraph">
</Section>

Expand Down
1 change: 1 addition & 0 deletions gap/oper.gd
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ DeclareOperation("IsPerfectMatching", [IsDigraph, IsHomogeneousList]);
DeclareOperation("IsDigraphPath",
[IsDigraph, IsHomogeneousList, IsHomogeneousList]);
DeclareOperation("IsDigraphPath", [IsDigraph, IsList]);
DeclareOperation("IsKParadoxical", [IsDigraph, IsInt]);

# 9. Connectivity . . .
DeclareOperation("DigraphIsKing", [IsDigraph, IsPosInt, IsPosInt]);
Expand Down
38 changes: 38 additions & 0 deletions gap/oper.gi
Original file line number Diff line number Diff line change
Expand Up @@ -1596,6 +1596,44 @@ function(D, edges)
return true;
end);

InstallMethod(IsKParadoxical, "for a tournament and a non-negative int",
[IsDigraph, IsInt],
function(D, k)
local n, subset, blists;
n := DigraphNrVertices(D);

if not IsTournament(D) then
ErrorNoReturn("the 1st argument <D> must be a tournament,");
fi;

if k < 0 then
ErrorNoReturn("the 2nd argument <k> must be non-negative,");
fi;

if n = 0 then
return false;
fi;

if k = 0 then
return true;
fi;

# this minimum number of vertices needed for k-paradox is given by
# Szekeres, E.; Szekeres, G. (1965), "On a problem of Schütte and Erdős"
if n < (k+2) * (2^(k-1)) - 1 then
return false;
fi;

blists := List(InNeighbours(D), inn -> BlistList([1..n], inn));
for subset in Combinations(blists, k) do
if SizeBlist(IntersectionBlist(subset)) = 0 then
return false;
fi;
od;

return true;
end);

#############################################################################
# 9. Connectivity
#############################################################################
Expand Down
1 change: 1 addition & 0 deletions gap/prop.gd
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ DeclareProperty("IsCompleteBipartiteDigraph", IsDigraph);
DeclareProperty("IsCompleteMultipartiteDigraph", IsDigraph);
DeclareProperty("IsCompleteDigraph", IsDigraph);
DeclareProperty("IsTournament", IsDigraph);
DeclareProperty("IsParadoxical", IsDigraph);
DeclareProperty("IsChainDigraph", IsDigraph);
DeclareProperty("IsCycleDigraph", IsDigraph);
DeclareProperty("IsDigraphCore", IsDigraph);
Expand Down
14 changes: 14 additions & 0 deletions gap/prop.gi
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,20 @@ function(D)
return IsAntisymmetricDigraph(D);
end);

InstallMethod(IsParadoxical, "for a tournament",
[IsDigraph],
function(D)
if not IsTournament(D) then
ErrorNoReturn("the argument <D> must be a tournament,");
fi;

if DigraphNrVertices(D) = 0 then
return false;
else
return not ForAny(InNeighbours(D), IsEmpty);
fi;
end);

InstallMethod(IsEmptyDigraph, "for a digraph with known number of edges",
[IsDigraph and HasDigraphNrEdges],
D -> DigraphNrEdges(D) = 0);
Expand Down
24 changes: 24 additions & 0 deletions tst/standard/oper.tst
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,30 @@ gap> gr := Digraph([[], [3, 4], [1, 4], [1]]);
gap> DigraphIsKing(gr, 2, 2);
Error, the 1st argument <D> must be a tournament,

# IsKParadoxical: for a tournament and a non-negative integer
gap> gr := Digraph([[2], [1]]);;
gap> IsKParadoxical(gr, 1);
Error, the 1st argument <D> must be a tournament,
gap> gr := EmptyDigraph(0);;
gap> IsKParadoxical(gr, 1);
false
gap> gr := Digraph([[]]);;
gap> IsKParadoxical(gr, 0);
true
gap> IsKParadoxical(gr, -1);
Error, the 2nd argument <k> must be non-negative,
gap> gr := Digraph([[2], [3], [1]]);;
gap> IsTournament(gr);
true
gap> IsKParadoxical(gr, 1);
true
gap> IsKParadoxical(gr, 2);
false
gap> gr := Digraph([[2, 3, 5], [3, 4, 6], [4, 5, 7], [5, 6, 1], [6, 7, 2],
> [7, 1, 3], [1, 2, 4]]);;
gap> IsKParadoxical(gr, 2);
true

# DigraphRemoveLoops
gap> gr := DigraphFromDigraph6String("&EhxPC?@");
<immutable digraph with 6 vertices, 11 edges>
Expand Down
18 changes: 18 additions & 0 deletions tst/standard/prop.tst
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,24 @@ gap> gr := Digraph([[2], [1], [1]]);
gap> IsTournament(gr);
false

# IsParadoxical
gap> gr := Digraph([[2], [1]]);;
gap> IsParadoxical(gr);
Error, the argument <D> must be a tournament,
gap> gr := EmptyDigraph(0);;
gap> IsParadoxical(gr);
false
gap> gr := Digraph([[2, 3], [3], []]);;
gap> IsTournament(gr);
true
gap> IsParadoxical(gr);
false
gap> gr := Digraph([[2], [3], [1]]);;
gap> IsTournament(gr);
true
gap> IsParadoxical(gr);
true

# IsStronglyConnectedDigraph
gap> gr := Digraph([]);
<immutable empty digraph with 0 vertices>
Expand Down
Loading