Skip to content

Commit

Permalink
Added Golomb graph
Browse files Browse the repository at this point in the history
  • Loading branch information
scheinerman committed Dec 27, 2021
1 parent 4843f46 commit 27be18a
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "SimpleGraphs"
uuid = "55797a34-41de-5266-9ec1-32ac4eb504d3"
version = "0.7.13"
version = "0.7.14"

[deps]
AbstractLattices = "398f06c4-4d28-53ec-89ca-5b2656b7603d"
Expand Down
47 changes: 45 additions & 2 deletions src/simple_constructors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
export Complete, Path, Cycle, RandomGraph, RandomRegular, RandomSBM
export RandomTree, code_to_tree
export Grid, Wheel, Cube, BuckyBall, Johnson, Doyle
export Petersen, Kneser, Paley, Knight, Frucht, Hoffman, HoffmanSingleton, Spindle
export Petersen, Kneser, Paley, Knight, Frucht, Hoffman, HoffmanSingleton, Spindle, Golomb

"""
`Complete(n)` returns a complete graph with `n` vertices `1:n`.
Expand Down Expand Up @@ -825,6 +825,49 @@ function Spindle()
d[k] = p2[:, k-3]
end
embed(G, d)
SimpleGraphs.name(G, "Spindle")
SimpleGraphs.name(G, "Moser Spindle")
return G
end



"""
Golomb()
Create the Golomb graph. This is a unit-distance graph with chromatic number 4.
It has 10 vertices and 18 edges.
"""
function Golomb()::SimpleGraph{Int}
G = Cycle(6)
for v = 1:6
add!(G, 0, v)
end

add!(G, 1, 7)
add!(G, 3, 8)
add!(G, 5, 9)
add!(G, 7, 8)
add!(G, 7, 9)
add!(G, 8, 9)

xy = Dict{Int,Vector{Float64}}()

xy[0] = [0, 0]
for k = 1:6
x, y = reim(exp((k - 1) * im * 2 * π / 6))
xy[k] = [x, y]
end

r = sqrt(3) / 3
θ = acos(r / 2)


for k = 0:2
x, y = reim(r * exp((θ + 2 * k * π / 3) * im))
xy[k+7] = [x, y]
end

embed(G, xy)
name(G, "Golomb")

return G
end

0 comments on commit 27be18a

Please sign in to comment.