Skip to content

Commit

Permalink
Implemented checking for vertex/edge transitivity (#165)
Browse files Browse the repository at this point in the history
  • Loading branch information
GrahamCampbell authored and wilfwilson committed Feb 15, 2019
1 parent 422154c commit 080f25b
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 0 deletions.
44 changes: 44 additions & 0 deletions doc/attr.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1412,3 +1412,47 @@ gap> OutNeighbours(D);
</Description>
</ManSection>
<#/GAPDoc>

<#GAPDoc Label="IsVertexTransitive">
<ManSection>
<Attr Name="IsVertexTransitive" Arg="digraph"/>
<Returns><K>true</K> or <K>false</K>.</Returns>
<Description>
If <A>digraph</A> is a digraph, then <C>IsVertexTransitive</C> returns
<K>true</K> if <A>digraph</A> is vertex transitive, and <K>false</K>
otherwise. A digraph is <E>vertex transitive</E> if its automorphism group
acts transitively on its vertices.

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

<#GAPDoc Label="IsEdgeTransitive">
<ManSection>
<Attr Name="IsEdgeTransitive" Arg="digraph"/>
<Returns><K>true</K> or <K>false</K>.</Returns>
<Description>
If <A>digraph</A> is a digraph without multiple edges, then
<C>IsEdgeTransitive</C> returns <K>true</K> if <A>digraph</A>
is edge transitive, and <K>false</K> otherwise. A digraph is
<E>edge transitive</E> if its automorphism group acts
transitively on its edges (via the action <Ref Prop="OnPairs"/>).

<Example><![CDATA[
gap> IsEdgeTransitive(Digraph([[1], [2]]));
true
gap> IsEdgeTransitive(Digraph([[2], [3], []]));
false
gap> IsEdgeTransitive(Digraph([[2], [3, 3, 3], []]));
Error, Digraphs: IsEdgeTransitive: usage,
the argument <graph> must not have multiple edges,
]]></Example>
</Description>
</ManSection>
<#/GAPDoc>
3 changes: 3 additions & 0 deletions gap/attr.gd
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,6 @@ DeclareAttribute("HamiltonianPath", IsDigraph);
DeclareAttribute("AsGraph", IsDigraph, "mutable");
DeclareAttribute("AsTransformation", IsDigraph);
DeclareAttribute("DIGRAPHS_ConnectivityData", IsDigraph, "mutable");

DeclareAttribute("IsVertexTransitive", IsDigraph);
DeclareAttribute("IsEdgeTransitive", IsDigraph);
16 changes: 16 additions & 0 deletions gap/attr.gi
Original file line number Diff line number Diff line change
Expand Up @@ -1537,3 +1537,19 @@ InstallMethod(CharacteristicPolynomial,
function(gr)
return CharacteristicPolynomial(AdjacencyMatrix(gr));
end);

InstallMethod(IsVertexTransitive, "for a digraph",
[IsDigraph],
gr -> IsTransitive(AutomorphismGroup(gr), DigraphVertices(gr)));

InstallMethod(IsEdgeTransitive, "for a digraph",
[IsDigraph],
function(digraph)
if IsMultiDigraph(digraph) then
ErrorNoReturn("Digraphs: IsEdgeTransitive: usage,\n",
"the argument <digraph> must not have multiple edges,");
fi;
return IsTransitive(AutomorphismGroup(digraph),
DigraphEdges(digraph),
OnPairs);
end);
23 changes: 23 additions & 0 deletions tst/standard/attr.tst
Original file line number Diff line number Diff line change
Expand Up @@ -1721,6 +1721,29 @@ gap> gr := CompleteDigraph(5);
gap> CharacteristicPolynomial(gr);
x_1^5-10*x_1^3-20*x_1^2-15*x_1-4

# IsVertexTransitive
gap> IsVertexTransitive(Digraph([]));
true
gap> IsVertexTransitive(Digraph([[1], [2]]));
true
gap> IsVertexTransitive(Digraph([[2], [3], []]));
false
gap> IsVertexTransitive(CompleteDigraph(20));
true

# IsEdgeTransitive
gap> IsEdgeTransitive(Digraph([]));
true
gap> IsEdgeTransitive(Digraph([[1], [2]]));
true
gap> IsEdgeTransitive(Digraph([[2], [3], []]));
false
gap> IsEdgeTransitive(CompleteDigraph(20));
true
gap> IsEdgeTransitive(Digraph([[2], [3, 3, 3], []]));
Error, Digraphs: IsEdgeTransitive: usage,
the argument <digraph> must not have multiple edges,

# DIGRAPHS_UnbindVariables
gap> Unbind(adj);
gap> Unbind(adj1);
Expand Down

0 comments on commit 080f25b

Please sign in to comment.