Skip to content

Commit 27be18a

Browse files
committed
Added Golomb graph
1 parent 4843f46 commit 27be18a

File tree

2 files changed

+46
-3
lines changed

2 files changed

+46
-3
lines changed

Project.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "SimpleGraphs"
22
uuid = "55797a34-41de-5266-9ec1-32ac4eb504d3"
3-
version = "0.7.13"
3+
version = "0.7.14"
44

55
[deps]
66
AbstractLattices = "398f06c4-4d28-53ec-89ca-5b2656b7603d"

src/simple_constructors.jl

+45-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
export Complete, Path, Cycle, RandomGraph, RandomRegular, RandomSBM
44
export RandomTree, code_to_tree
55
export Grid, Wheel, Cube, BuckyBall, Johnson, Doyle
6-
export Petersen, Kneser, Paley, Knight, Frucht, Hoffman, HoffmanSingleton, Spindle
6+
export Petersen, Kneser, Paley, Knight, Frucht, Hoffman, HoffmanSingleton, Spindle, Golomb
77

88
"""
99
`Complete(n)` returns a complete graph with `n` vertices `1:n`.
@@ -825,6 +825,49 @@ function Spindle()
825825
d[k] = p2[:, k-3]
826826
end
827827
embed(G, d)
828-
SimpleGraphs.name(G, "Spindle")
828+
SimpleGraphs.name(G, "Moser Spindle")
829+
return G
830+
end
831+
832+
833+
834+
"""
835+
Golomb()
836+
Create the Golomb graph. This is a unit-distance graph with chromatic number 4.
837+
It has 10 vertices and 18 edges.
838+
"""
839+
function Golomb()::SimpleGraph{Int}
840+
G = Cycle(6)
841+
for v = 1:6
842+
add!(G, 0, v)
843+
end
844+
845+
add!(G, 1, 7)
846+
add!(G, 3, 8)
847+
add!(G, 5, 9)
848+
add!(G, 7, 8)
849+
add!(G, 7, 9)
850+
add!(G, 8, 9)
851+
852+
xy = Dict{Int,Vector{Float64}}()
853+
854+
xy[0] = [0, 0]
855+
for k = 1:6
856+
x, y = reim(exp((k - 1) * im * 2 * π / 6))
857+
xy[k] = [x, y]
858+
end
859+
860+
r = sqrt(3) / 3
861+
θ = acos(r / 2)
862+
863+
864+
for k = 0:2
865+
x, y = reim(r * exp((θ + 2 * k * π / 3) * im))
866+
xy[k+7] = [x, y]
867+
end
868+
869+
embed(G, xy)
870+
name(G, "Golomb")
871+
829872
return G
830873
end

0 commit comments

Comments
 (0)