X
5649

Constructing Steiner Triple Systems with IDL

This Help Article will provide code to construct Steiner Triple Systems using IDL.

Discussion
A Steiner triple system is an ordered pair (S,T), where S is a finite set of points or symbols, and T is a set of 3-element subsets of S called triples, such that each pair of distinct elements of S occurs together in exactly one triple of T. It can be shown that a Steiner triple system of order v exists if and only if v mod 6 = 1 or 3.

Here is an example of a Steiner triple system (constructed using the sts routine found on this page):

IDL> print, sts(9)
1 2 3
4 5 6
7 8 9
1 4 8
2 5 9
3 6 7
1 7 5
2 8 6
3 9 4
4 7 2
5 8 3
6 9 1

NOTE: This routine calls a routine named LATIN_SQUARE. For more information about this routine click here.

function sts, sz
case (sz mod 6) of
1:begin ; Skolem construction.
n = sz/6
chils = latin_square(2*n, idempotent = 2)
s = lindgen(3,2*n)+1
t = lonarr(3,sz*(sz-1)/6)
inf = 0

; Type 1 triples
for i = 0, n-1 do t[*,i] = s[*,i]
; Type 2 triples
count = n
for i = 0, n-1 do begin
t[0,count:count+2] = inf
t[1,count:count+2] = s[0:2,n+i]
t[2,count] = s[1,i]
t[2,count+1] = s[2,i]
t[2,count+2] = s[0,i]
count = count+3
end
; Type 3 triples
for j = 0, 2*n-1 do begin
for i = 0, j-1 do begin
t[0,count:count+2] = s[0:2,i]
t[1,count:count+2] = s[0:2,j]
t[2,count] = s[1,chils[i,j]-1]
t[2,count+1] = s[2,chils[i,j]-1]
t[2,count+2] = s[0,chils[i,j]-1]
count = count+3
endfor
endfor ; j
return, t
end

3:begin ; Bose construction.
n = sz/6
cils = latin_square(2*n+1, idempotent = 1)
s = lindgen(3,2*n+1)+1
t = lonarr(3,sz*(sz-1)/6)

; Type 1 triples
for i = 0, 2*n do t[*,i] = s[*,i]
; Type 2 triples
count = 2*n+1
for j = 0, 2*n do begin
for i = 0, j-1 do begin
t[0,count:count+2] = s[0:2,i]
t[1,count:count+2] = s[0:2,j]
t[2,count] = s[1,cils[i,j]-1]
t[2,count+1] = s[2,cils[i,j]-1]
t[2,count+2] = s[0,cils[i,j]-1]
count = count+3
endfor
endfor
return, t
end
else: begin
void = dialog_message('A Stiener Triple System of order V '+ $
'exists if and only if (V mod 6) = 1 or 3. Returning 0', /info)
return, 0
endelse
endcase
end