Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 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
90 changes: 90 additions & 0 deletions src/Combinatorics/Graphs/functions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2164,3 +2164,93 @@ end

_is_tree(g::Graph{Directed}) = is_weakly_connected(g) && isone(n_vertices(g) - n_edges(g))


@doc raw"""
petersen_graph()
Comment thread
Sequenzer marked this conversation as resolved.

Construct and return the Petersen graph as a simple undirected graph.

Comment thread
Sequenzer marked this conversation as resolved.
"""
function petersen_graph()
e = Vector{Int}[[1,3],[1,4],[2,4],[2,5],[3,5],[1,6],[6,7],[2,7],[7,8],[3,8],[8,9],[4,9],[9,10],[5,10],[10,6]]
return graph_from_edges(e)
end

@doc raw"""
clebsch_graph()

Construct and return the 5-regular Clebsch graph.

The Clebsch graph is a strongly regular graph with 16 vertices and 40 edges. It is triangle-free, has degree 5.
Comment thread
Sequenzer marked this conversation as resolved.
Outdated
"""
function clebsch_graph()
e = Vector{Int}[[1, 2], [1, 3], [1, 5], [1, 9], [1, 16], [2, 4], [2, 6], [2, 10], [2, 15], [3, 4], [3, 7], [3, 11], [3, 14], [4, 8], [4, 12], [4, 13], [5, 6], [5, 7], [5, 13], [5, 12], [6, 8], [6, 14], [6, 11], [7, 8], [7, 15], [7, 10], [8, 16], [8, 9], [9, 10], [9, 11], [9, 13], [10, 12], [10, 14], [11, 12], [11, 15], [12, 16], [13, 14], [13, 15], [14, 16], [15, 16]]
Comment thread
Sequenzer marked this conversation as resolved.
Outdated
return graph_from_edges(e)
end

@doc raw"""
disjoint_automorphisms(G::Graph)

Find and return a pair of automorphisms of the graph `G` which are disjoint and
neither is the identity (thus neither fixes all vertices; and hence, since they
are disjoint, neither moves all vertices). Returns a tuple `(g1, g2)` of such
automorphisms if found, otherwise throws an error.
Comment thread
Sequenzer marked this conversation as resolved.

Two autormorphisms $\sigma$ and $\tau$ are said to be disjoint if
$\sigma(i) = i$ if and only if $\tau(i) \neq i$ for all vertices $i$ of the graph.
Comment thread
Sequenzer marked this conversation as resolved.
Outdated

# Examples
```jldoctest
julia> C = clebsch_graph();

julia> disjoint_automorphisms(C)
((2,3)(6,7)(10,11)(14,15), (1,4)(5,8)(9,12)(13,16))
```
"""
function disjoint_automorphisms(G::Graph)
A = automorphism_group(G)
n = nv(G)

Comment thread
Sequenzer marked this conversation as resolved.
Outdated
ret, a, b = _compute_disjoint_automorphism(G::Graph)
@req ret "The graph has no disjoint automorphisms"
return a, b
end

@doc raw"""
has_disjoint_automorphisms(G::Graph)

Return `true` if the graph `G` has a pair of non-trivial, disjoint automorphisms,
and `false` otherwise.
Comment thread
Sequenzer marked this conversation as resolved.

# Examples
```jldoctest
julia> C = petersen_graph();

julia> has_disjoint_automorphisms(C)
false
```
"""
function has_disjoint_automorphisms(G::Graph)
A = automorphism_group(G)
n = nv(G)
Comment thread
Sequenzer marked this conversation as resolved.
Outdated
ret, a, b = _compute_disjoint_automorphism(G::Graph)
Comment thread
Sequenzer marked this conversation as resolved.
Outdated
return ret
end

@attr Tuple{Bool, PermGroupElem, PermGroupElem} function _compute_disjoint_automorphism(G::Graph)
A = automorphism_group(G)
n = nv(G)
Comment thread
fingolfin marked this conversation as resolved.
Outdated

for cc in conjugacy_classes(A)
rcc = first(cc)
Comment thread
Sequenzer marked this conversation as resolved.
Outdated
rcc == one(A) && continue
Comment thread
Sequenzer marked this conversation as resolved.
Outdated
stab = stabilizer(A, moved_points(rcc))[1]
Comment thread
Sequenzer marked this conversation as resolved.
Outdated
order(stab) > 1 || continue
for g2 in stab
g2 == one(A) && continue
return (true, rcc, g2)
end
Comment thread
Sequenzer marked this conversation as resolved.
Outdated
end
return (false, one(A), one(A))
end

3 changes: 3 additions & 0 deletions src/exports.jl
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@ export class_positions_of_pcore
export class_positions_of_solvable_residuum
export closed_subvariety_of_toric_variety
export closure
export clebsch_graph
export cm_regularity
export coatoms
export cobases
Expand Down Expand Up @@ -559,6 +560,7 @@ export direct_sum
export direct_sum_components
export directed_component
export discriminant_representation
export disjoint_automorphisms, has_disjoint_automorphisms
export disjoint_union
export div_left
export div_left!
Expand Down Expand Up @@ -1433,6 +1435,7 @@ export permutation_group
export permutation_matrix
export permutation_of_terms
export permuted
export petersen_graph
export phylogenetic_tree
export picard_class
export picard_group
Expand Down
29 changes: 29 additions & 0 deletions test/Combinatorics/Graph.jl
Original file line number Diff line number Diff line change
Expand Up @@ -292,4 +292,33 @@
@test sg4.vertexlabels[1] == "second"
@test sg4.vertexlabels[2] == "fourth"
end

@testset "petersen_graph" begin
P = petersen_graph()
@test n_vertices(P) == 10
@test n_edges(P) == 15
@test degree(P) == fill(3,10)
end

@testset "clebsch_graph" begin
C = clebsch_graph()
@test n_vertices(C) == 16
@test n_edges(C) == 40
@test degree(C) == fill(5,16)
end

@testset "disjoint automorphism" begin
P = petersen_graph()
@test !has_disjoint_automorphisms(P)
@test_throws ArgumentError disjoint_automorphisms(P)

C = clebsch_graph()
@test has_disjoint_automorphisms(C)
a,b = disjoint_automorphisms(C)
G = automorphism_group(C)
@test a != one(G)
@test b != one(G)
Comment thread
fingolfin marked this conversation as resolved.
Outdated
@test fixed_points(a) == moved_points(b)
@test fixed_points(b) == moved_points(a)
end
end
Loading