Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve ViewStrings/TrueMethods for tournaments/cycle digraphs #447

Merged
Merged
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
3 changes: 2 additions & 1 deletion gap/digraph.gi
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,8 @@ function(D)
Append(str, "multi");
fi;

if HasIsTournament(D) and IsTournament(D) and n > 1 then
if not (HasIsCycleDigraph(D) and IsCycleDigraph(D))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the overlap between being a tournament and being a cycle, some corner case?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, a corner case. The only overlap is that a cycle digraph with three vertices is a tournament (although not all tournaments with three vertices are cycle digraphs).

This bit of code stops <(im)mutable cycle tournament with 3 vertices> from showing, in favour of the simpler <(im)mutable cycle digraph with 3 vertices>, in this case.

and HasIsTournament(D) and IsTournament(D) and n > 1 then
Append(str, "tournament ");
display_nredges := false;
else
Expand Down
16 changes: 7 additions & 9 deletions gap/examples.gi
Original file line number Diff line number Diff line change
Expand Up @@ -243,21 +243,19 @@ InstallMethod(CycleDigraphCons,
function(filt, n)
local D;
D := MakeImmutable(CycleDigraphCons(IsMutableDigraph, n));
if n = 1 then
SetIsTransitiveDigraph(D, true);
SetDigraphHasLoops(D, true);
else
SetIsTransitiveDigraph(D, false);
SetDigraphHasLoops(D, false);
fi;
SetIsAcyclicDigraph(D, false);
SetIsCycleDigraph(D, true);
SetIsEmptyDigraph(D, false);
SetIsMultiDigraph(D, false);
SetDigraphNrEdges(D, n);
SetIsFunctionalDigraph(D, true);
SetIsStronglyConnectedDigraph(D, true);
SetIsTournament(D, n = 3);
SetIsTransitiveDigraph(D, n = 1);
SetAutomorphismGroup(D, CyclicGroup(IsPermGroup, n));
SetDigraphHasLoops(D, n = 1);
SetIsBipartiteDigraph(D, n mod 2 = 0);
if n > 1 then
SetChromaticNumber(D, 2 + (n mod 2));
fi;
return D;
end);

Expand Down
4 changes: 4 additions & 0 deletions gap/prop.gd
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,17 @@ InstallTrueMethod(IsBipartiteDigraph, IsUndirectedForest);
InstallTrueMethod(IsCompleteMultipartiteDigraph, IsCompleteBipartiteDigraph);
InstallTrueMethod(IsConnectedDigraph, IsBiconnectedDigraph);
InstallTrueMethod(IsConnectedDigraph, IsStronglyConnectedDigraph);
InstallTrueMethod(IsFunctionalDigraph, IsCycleDigraph);
InstallTrueMethod(IsHamiltonianDigraph,
IsTournament and IsStronglyConnectedDigraph);
InstallTrueMethod(IsInRegularDigraph, IsRegularDigraph);
InstallTrueMethod(IsOutRegularDigraph, IsRegularDigraph);
InstallTrueMethod(IsPreorderDigraph, IsPartialOrderDigraph);
InstallTrueMethod(IsRegularDigraph, IsInRegularDigraph and IsOutRegularDigraph);
InstallTrueMethod(IsRegularDigraph, IsVertexTransitive);
InstallTrueMethod(IsStronglyConnectedDigraph,
IsConnectedDigraph and IsSymmetricDigraph);
InstallTrueMethod(IsStronglyConnectedDigraph, IsCycleDigraph);
InstallTrueMethod(IsStronglyConnectedDigraph, IsEulerianDigraph);
InstallTrueMethod(IsStronglyConnectedDigraph, IsHamiltonianDigraph);
InstallTrueMethod(IsStronglyConnectedDigraph, IsUndirectedTree);
Expand Down
4 changes: 2 additions & 2 deletions gap/prop.gi
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ D -> IsDirectedTree(D) and IsSubset([0, 1], OutDegreeSet(D)));
InstallMethod(IsCycleDigraph, "for a digraph", [IsDigraph],
function(D)
return DigraphNrVertices(D) > 0
and IsStronglyConnectedDigraph(D)
and DigraphNrEdges(D) = DigraphNrVertices(D);
and DigraphNrEdges(D) = DigraphNrVertices(D)
and IsStronglyConnectedDigraph(D);
end);

InstallMethod(IsBiconnectedDigraph, "for a digraph", [IsDigraph],
Expand Down