Practical Graph Isomorphism
Practical Graph Isomorphism
Br endan D. McKay
Current address · Computer Science [Link]
Department 01 Comput er SCience Vanderbll t Un1 vers 1 ty
Aust rali an Nation al Univ ersity
Canberra. ACT 0200. [Link] Na shvi 11 e, Tennessee 37235
bdm@::s [Link] au
INTRODUCTION
< 1s the linear order < defined as fol l ows. If a=(%t.z~. " ·.Zk)EZ
and {J = (111, 1/:;, ···.11') e Z then a < {3 e1 t her of the follo .... 1ni are true.
(1) For some t, I <t < min{k, l}, .... e have Z; = 1I; for i < t
and %1 < Yt·
1·2 Partition..
"/I"~ e IT-(V) , we wr i te 1'1"1 ~ '1'2 i f .... 1 and It~ have the sa.e
If .... "
cells, i n sOlie order. We sa.y that 1I"t 15 finer than "111"11, deno ted 1I" t < 11"2,
i f every cell of 1I" t 1 s a subset of sOlie cell of 11"2' Under the same
c onditions , . 11 is eoa.".!!r t llan .... 1. It is \lell known that the se t n(V)
forms a lattice under the partial orde r <. This . e ans t ha t , given 11"10
11"2 e n(V), there i s a unique coarsest partition 71"1/\ 11"~ e I1(V) SUch that
11"1 > 11"1/\ 11"2 and "/1"2 > . . . 1/\ 11"2. and a unique finest parti tion 11"1 v ""~ e I1{V)
s uc h that "/1"1 < 71"1 V 11'2 and 'lf2 < . . 1 V 71"2_ Each cell of 1I't /\ .... 2 15 a non-
ellPty intersection of a cell of 1'1"1 and a cell of "11"2' Each cell of "11"1 V"ll"~
is a minimal non-empty subset of V which 1s both a Union of cells of
1'1"1 and a union of cells of 71"2'
.
wll i ch
Let 'If e U-(V) . Tben f1x('If) is the set of ele.e nts of V
are fixed by 11". The &~Pp o rl of 'II'" is Ute set s UP p('II'") =
V \ flx('II'"). The
; I V; E 'II'}.
s e t of minim um. ctll Tl!!pru t nta.ti1l e& of fI' is mcr(1f) = {minY
whe re t he lIinl l1a are under tile na tural orderI ng of V.
L" 'If.. " V~) IE il(V). For each %IE V define u(%,,..) = i ,
= (VI, V2,
are cOI'U,'d ent
wllere % IE Y;. If '11'1, 11"2 IE ll(V) then we s a y t hat 11"1 and 11"2
, 1!'2) < U(y,1!'2)'
if, f o r any %, Y IE V, U(t,'I'I'"l ) < u(y,1I"d implie s that U(:t
As a relati on, cons isten c y is s Ylillet r ic but no t trans
iti ve . If 11" 1 < 11"2
-<"'2 or
and '1f t a nd ,.., are consi stent, we indic ate tlli s by writin g 'If.
'lf2 >- ,.. •• The re l ati on -< I s trans iti ve but not s ymme tri c.
1· 4 Group s
eland t
For pe rlluta t ion group t heo ry not del1n eated he re see Wl
S,,). The 1mage
[19]. Le t '1 be a permu tation on V (1n other wo r ds 'T E
y, if W C V
of U E V under '1 1.1 11 1 be deno t ed by 11'1. More ge nerall
', V,) IE g(V).
t hen W" = {'W'J I 'llie W}. Simil arly. if 1f = (V. , V2 , "
t he n 'If'J = (vl , V~, " ' , Vn Finall y, tf G IE g{V) t hen
G" IE Q'(V) ha s
E(G") = {t'Jy'J I 'XII IE E(G)} .
then Q defin es a parti ti on 8(n) E n(V) whose
If Q C 8",
Fo r no tati onal
cell s are the o rbits of (0 ). t he group gene r a ted by Q .
) and .er(a)
conve nience we 1.1111 write B({,}) as 8b), and fix(a) , supp(Q
a nd mcr(8(Q n.
w11 1 be used a s abbre vi a tio ns t or fix(8( n»), s up p(8(Q))
1·3 .
re s pec t ively. The ne xt } " mma follow s ea s ily frOIl Lellllla
'·5 [Link] L flt n, IfJ C Sn. 'J'[Link]
.
DEVELOPMENT OF TH E ALGOR ITHM
In t his section ",e describe the theoretIcal basis f o r t he
a lgor ithm. The aore mundane as pects of i ts impl ementa tio n w11l be treated
1n Secti on 3.
2·2 Theorem L!t G I , O2 E .G'(V) ,:II" E mV) [Link] '7 E Sn. Th~ n C{G 1, 11") =
C(G2, "If'!") i.f and onl y if there -i.J a permutation 6 E S" ,uch that G 2 = G ~ [Link]
1'I" '!" =ff~ .
Proof: The exlstence of 6 as required implies t hat C(G \, 1I") = C(0 2,"II""1) by
Property C2. Suppose c onversely that C(G J ,1I") = C( G ~,1I"1") . By Pr operty C1,
O~ = G~ for s ome fJ e S". Tlle refor e C(G 2 , :11"') = C(G~, 1I"1 ) = C{G 1 ,7I""lr).),
by Property C2. Slnc e C(G J , 1I"} = C(G 2 ,1I""I), the re Is some a e Aut(G I ) such
t ha t 1I""ltr' = 11" <>" , by Proper t y C3, and so 11" ' = ff <>~. But a E Aut.(G I), and.
so O 2 = Gf = G'{~. 0
The isomor ph1 s. probl em desc ri bed i n Theo rem 2·2 can be thought
of as that of t esting ve r tex-col oured graph s f or hoao r phlsl11. Gi ve n 1,..1
col ours, ~e colour the ve r tices of G 1 whi ch 11 e tn "the i-th cell of
ff . . ith the i - th col o ur, t or 1 <i < Iffl. We then $1II11arly col our the
vertices of G 2 i n accorc!.ance .... ith ,..'. This 101111 use the S411e colour s
.... ith the salle fr eque ncy. Theorem 2·2 no~ says that e(G I ,1f) = C(G 2 , 11""1)
if a na only if "there I s II. co l our-preserving i somo r phism from (i J to (i 2.
..
2·3 Equitable Partitions
For G E g(V).
V and W C V, we define dG(v, W) to be the
t! E
.,
is a unique coarsest equi table partition E(,..-) E I1(V) which is finer than
(l) * := 'IT
m:= 1
W:=Wm
m:=m+l
k: = 1
{Suppose if = (VI , V2 , ' ", v~) at t his point.}
(3) Define (Xl, X:., ···, X.) IE lI(V... ) such that for any :I: IE Xit
Y IE X j we bave d(~, W) < d(y, W) i f and onl y i f i < j.
If (.! = 1) go t o (4)
M:= M+,-l
Update ;r by replac i ng t he cell V... wltb tbe cells X l, X :, ·· ·, X.
in that o rder (in situ.).
(4) k := k + 1
If (k < r) go to (3)
Go to (2) o
2·6 Theorem For Gny G IE g(V), 1T E LI{V), we Mtle R(G,1!', '!!') = €(1T),
(b) By defi nitio n, €(1T) < 1T, so €('/r) < if at Step (1). No w
suppose tha t e("') < if be f or e s Ollie executi on of Step ( 3). Since W is a
cel l of some partition coarser than €(11') (i e. some earlier value of 1i) ,
it 15 a uni on of cells of €(w). Since €(1T) 15 equitable, we must have
t ba t t(w) <i after the exe cution of Step (3). Therefore, by ind uct i o n,
{ ('If) < R(G, 1I',1!') < 11' .. hen the algorithm stops.
'I
is made successive ly f iner by t be 4lg o rit ~, :t and y must al'oiays be in
the same cell of i-.
(e) Since z and yare never se parated, d(:t, W) = d{y, W}. But
sinc:e W Is a union of cell s of R(G,,..-,l'T) , a nd d(z, Y2) ':1= d(Y,Y2) , there
is at lea st one o the r cell Ys of R(G,1f,If) contained 1n W f or which
d(:r;,Ys) ;;£d(y, Ys). Si nce Y'l and Ys are different cells of R(G,1r,If) t hey
must be separa t ed at some execution of Step (J). At leas t one of theil,
say Y2 will t hen be con t a i ned in s oae new ele_en t of a.
2· 7 Theorem Let G E Q(V), 11' e lI(V) and SUppOSIJ that there is some equi.
t abl ~ partitio n fr' which i, coar.!er than 7T. Cho f}u a C '1'1' luch that for any
WE fr', W ~ halJe X C W fo r at mod one X € '1'1' \ a. T hen. ~{ G,1r,a) ~ €"(7T ).
"
(d)
On the other hand, Y2 and. Y3 may be in the !lame cell of 11'.
Since they are in different cells of R(G. 1I',c.r) tbey .ust be separa t ed
a t Step (3). At leas t one of t hem, say Y!/., .... 111 then be contained in
some nel>' elellen t of a. We can now take up the proof of Theor em 2·6 at
step (e) and conclude II.S bef ore that R(G,lI',a) ..... e(7I")· 0
has lIore than one ce ll . The unit part iti on 11"0 is equi table , and so we
can choose a to be 11" l ess anyone cel l. Thts will be part!l;:ularly time -
saving if 11" = (tI, V \ tI) for sOllie tI, In which case we can use a = (tI).
Two ve r y usefu l pro pe r ties o f Algo r ttlut 2·5 are s tated in the
next lemma. Both o f them are i lllmedia te cons eq uence s of the defi ni tion
of the a l gorithm.
2·8 Lemma Let G E Q(V), "II" E n(V). a an o,.dered &[Link] of 1T' and 1 E Sn .
Then
(b) o
Let 1T' = (tll ,tl2, .. ·,w.. ) E U(V) and let tI e Vi for sOllie i. I f IVii = I
define "11",>1; = fr. If jv.j > 1 define fT ,,1.1 = (Vi,··· , Yo- I, II, Yo \ 'II, Y.:+I , ··· , Vk)'
Also define 1T' .[Link]= R(G,1T'o>"tI,(tI)).
derived from G, 11" and a sequence 1Il,tl2,' " ,tI",_1 where, for 1 <i< m~l.
Then we have VI < 1.'2 if VI < V2' If VI < /12, we say that VI is earlier
than 1.'2. and tha t /12 is later than VI'
2·11 Lemma Let G E Q(V), 7r E II(V) and /11, /12, V3 E T(G, 71"). Then
(a) Exactly one of VI < 1.'2, 1.'1 = /12 and /12 < /II is tru.e.
"
(c) If 111 < 112,
11'1 E T(G,'II", 111) and V:/. E T(G,'II", 1I2) then 11'1 < 1I~,
except pO$.tibly if 111 i.t an. [Link]&tor of 112.
Given G E -'!(V) and. 'II" E a(V) we can gene rate the e lellents of
T(G,fI') In the order given by <, with the simple backtrack [Link].
gIven bel ow.
(1 ) It; := 1
'11'1: = .R.(G,1I','If)
v: = mIn W~
Ie:= k+ 1
Go t o COl}
(4) Ie := It; - 1
If (k > 1) 110 to (3 )
Stop: All tbe nodes of T(G,'Ir) hIlve been out put in tbe
required order. o
"
2·13 Group Action. Oil T(G ,~)
(b) If II e T(G, 1I"), [Link] T( G'"', ", .. , ,,"I) = T(G, 11", "p. o
The map fr om T(G, '!f) t o T(G,"p I nducect by '1 w11 1 not tn general
preserve the o rder1na <.
We wl11 be pa rticularly intere sted in pe rmutations 'J E Sn such
that G" = G and ","I e '!f. I n other word s, '1 e Aut (G)" . If "I> II:.! e T(G,1I')
a nd II::: = "I for sOllie '1 E Aut {G) .. we write V I '"" V::: and sa y that " 1 and
II::: are equivalent. By theorem 2·14, ...... is an equi valence relati on on
T(G,1f). If v is a terai nal node of T(G,'!f) t he n v is ca ll ed a n i [Link]
nods if the r e is no earli er node of T(G,:rr) wh ich is equi valent to v.
2·15 Theorem Let G <I!! .Q(V}, 11" e LI(V) 4nd'1 E Aut(G)" . [Link]
(c) If VI, v::: E T(G , '11'), VI < 112 Gnd lit ' " v:::, t hen T(G, '11', V2 - VI)
Prool : Asser tlons Ca.) and (b) are [Link] e conseque nces of Theorell
2·14, so we conSider on ly a.s serti on (c) . If Vi ....... 112, there 1s SOlie
'1 E Aut( G) ~ = Vf ' But then
such tha t "2 V::: - V I = (YI - 112P [Link]
so T(G,'Ir,V2 - "'I )= T(G,'II", VI - " 2P by (b ) . Ho wever VI <~ and sO
"' I - v::: < 112 - Vi> by Lemma 2·11. Ther efore, e ve ry ter1llinal nm1e i n
T(G, '!f, V2 - VI) is eq ul valent t o an ear li er termInal noDe i n T(G ,:If, "' I-II:::).
whi ch proves (c:) .
"
2· 16 Indicator rund ionl
Given one indica tor function A, we can define ano the r ind icator
function ,1 by
Proof: Let v = [11"1 ,'11"2, · ··. '11"...1, where '11' ... = (VI [ \/2 1··· I V.. ), a nd take
the pe rauta tio n 6 E S .. whic h takes 11; onto i for 1 < i < n). Then
G(v) = d by def i nition. Also by definition, '11";' = (,,11111 1'" I ,, ~),
snd so G(v') = G"'- II. Thereto r e G(v) = G(v') if and onl y if G' = G"'- 'I,
which is possibl e 1r and onl y if 1 E Aut(G). o
Our next requir ement Is a linear ordering of Q(V). Any such
onler ing will do, but it will be convenie nt f or us to use an ordering
defined using the adja cency aatrices of elements ot Q(V). GIven G E Q(V)
we can define an integer n.(G) by writing down the e i eCients of the
adjacency aatrlx In a r ow- by- r ow fash ion, and interpr eting the result as
an n 2 _bit binary number. If Glf G 2 E Q(V) we can then define G l < G2
if and only i f n(G l ) < n(G2).
We can at last define C(G,'Ir). Let X(G,'Ir) be the set of all
terminal nodes of T(G,'II"). Choose an arbitrary (but fixed) indicator
function A. Let A* = max{.1{G,7r,v) I v E X(G,'II")}. Then we def i ne
C(G,w) = max{ G(II) III E X(G,7f) and AlG, 1f, v) = A*}.
Now suppose that C(G, '11"1") = C(G,'II") for some 'Y e Sn. Since C
satisfies Property C2, C(G,1l"1') =
-,
C(G"' ,1f}.Therefore there are a,
I
(j E Sn such that 1f0" = 'lr P = '11", C(G,1r1") = G1'- O and C(G,'Ir) = GP. The
assumption that C(G, "1'1"1") = C(G,1r) thus implies that G1"- O = G~ and so
I
(ja-1'Y E Aut(G). Finally, 7f~o-l1" = '11"1" since 1ffJ = '11"'" ="1'1". Therefore C
has Property CJ. 0
"
fo r which IX(G,"-)! i s very larae, even i f IAut(G)1 is small. We w11l
lIeet some of t hese grapbs in §3.
In the te rms of Theorem 2·20 our aim will be to reduce the size
of X*(G,lT) as lIuch as possible. We will reduce the nUliber of el e ment s
Of X*(G,'!I') which are not identity nodes by searening for autollorptlisms
of G and ellploying any we find te delete subt r ees of T{G,1f). We will
reduce the number of Ideotl t y nodes In X"'(G,1f) by using A.
(1) We lIay find two t erminal nodes Ill' £I~ E X(G, '11") such that
G(v,) = G(",).
The first case is tbe more important and will be treated first.
The second case can vait until Section 2·24.
"
Once we have found an explicit automorphism there are several
ways we can put it to work. These are based on Theorem 2·15. The immediate
outcome of Theorem 2·15 is that we may ignore the remainder of the subtree
T(G,1I",V~-Vl)' However, we can do better than that. Since Aut(G) is a
group, not only '"/ but all its powers are in Aut(G). Moreover, if we have
found several automorphisms of G, any permutation which 1s generated
by these is also in Aut(G). The follow1ng scheme for handling this mass
of information 1s not always the best, but has been found to work very
well in many circumstances.
2·22 Lemma Let VI < V2 E X(G, 11"). Then I~ - v21 < IVI- v~l.
Proof: If 1£11 - v21 < It - v21, then V2 E T(G, 1r, r - VI), whi ch contradicts
the assumption that III < v~. o
We next introduce an auxiliary partition fJ E n(V). We initially
set 9 equal to the discrete partition of V, and whenever we obtain an
explicit automorphism 1, we update 9:= 9 v 9(1). This means, by Lemma
1·i3, that 9 is at every stage the orbit partition of the group generated
by all the explicit automorphisms so far discovered. It also means that
9 <9(Aut(G)"-m)' where [11"1,11"2," ·,11"...1 is any common ancestor of all the
terminal nodes we have yet considered. This is because a permutation
taking one node to another fixes their common ancestors.
..
we only consider those for which 11; e mcr(6). The second Is that,
upon discovering an explicit automorphism 7 during the generation of
T(G,1I",V('!Ii)), and updating 6, we check to see if it still true that
v; e IIlcr(6). If no t , we have found proof (namely 1 ) that T(G,1I",V(lIi))
only contains terminal nodes equivalent to those of some subtree we have
al teady examined. Therefore we can return at once to v and consider
V(VH I)'
61
There is one other circumstance under which we may wish to
change W(II).If we find two equivalent terminal nodes Ill! 112 where
112 = 111 and where II is the l onge s "!: common ancestor of V l and 112. we can
2·25 Lemma L et G I: .G(V) [Link] let 'II" E U(V) be [Link] with respect to
+
G. If 11" has m non-trivial cells and either n < IlTl 4, n = 111") m or +
n = )lTl + m + 1, then IT1 = 8(Aut(G).,,) for [Link] equitable 'lT1 < 11". 0
61
p := !. Thereafter we update p:= v whenever we find a termInal node ",
>
4,{G, 1I',p} or d(G,.,V}= d(G , ., p} and G(v} > G(p}.
s uc h that iYG,. , ,,,}
Tbe definition of C(G,"') ensures that by the ti.e we have finished
searching T(G,:pr) we have G(p) = C(G,1I'), provided the set of terlllinal
nodes examined includes a ll the identity nodes. Now suppose that at sOlDe
i nstant during our search we have p = [11'1, 11'~, .. " '11" ... 1 and encolUlter a nod!!
v = [."r1,1I"'2t .. ·. 11"'/01, not necessarily terminal. Le t r = lIIin{m, k}. Then,
i t 4{G,1I",v(r)) < MG.1f,p(r) , ·th!! definition o t an indicator functi on
t ells us th4 t .[Link],1I", v) < d/..G, ff, p) f o r every [Link] node II o f T(G, rr).
Tberefor!! w!! can ute ly i gnore T(G,1I",v) wi t hou t .l sca l c ulating C(G,.).
2·27 Theorem Let 61 < 62 < ... < 5" be eiementl of a. [Link] ordered ut
£!,. Let ml, m2, "', m", bt pOlititl e int eger', and p~t I = ml + + ... +
m2 m~ .
L et :tI t :t2, "', :tl b! t lemtnh rJ/ .6, t:tactiy mj of which. au !qual to 5j for
1 < j < k . N ow permuh the :ti at random to get :ttl ), 2;(2), •.• , :r;£'), each. 0/
63
:t(il > ::c(il for i < i, out ::c(i) "'" 6" . Let M oe tht ,,"umoer ojmarkrrt eltmt""t.s.
Then
.-,
E(M) ~ " . m < ' 0'(''),
~Jm+l
1-' o
The second theorell concerns the nUllber of va lues of 4{G,1I",tli)
for those T(G,1I",v;) which a r e not ignored. I t therefo r e hIlS a bearing
on the number of ident ity nodes which are excluded by means of A.
2·28 Theorem Under th.e conditions of T heortm sun, let N bt tlu n"mbltr
of differtm tll1luet amonglt tM marktd dementi. Then
< log I,
+m" -
'Where th.e .urn il 0 if A: = 1. In particular, if mo· = m for 1 <i< k. then
E(N) = E;_:fl < log ic . 0
..
au t ollorpbi slis produced) it may be necessary t o translate it back to
the o ri gina l l abell ing, whic h is inconven i ent. "'e wH l describe an
alternative , but ..,111 onl y jus t 1fy it qualitatively. A more precise
ana lysI s woul d be impOSS i bly di f ficult to perform.
"
Identi ty node [Link] to C{G, 'If). This 15 the node p referred to
1n Sl!ction 2·25. WI! a1 so pl!rmi t thl! &1gor1 thlt to sl!arch for terllina1
nodes equivalent to r, with t he [Link] of using the automorphislls thus
d Iscovered to shorten the total amount of work:. This will s OlleU_es
degrade the perforllanee somewhat, but on the aVl!rage it works vl!ry well.
We are now able to [Link] the way in wh ich terminal nodes are
processed. Suppose that ."e have Just created a node v , not necessarily
terminal, which is not an ancestor of , (1. e. I S later than O.
The node p and the partition 8 have tbe. saae i nt e r pretation as
before. Suppose that II 1s the node [tr l ,'lr2' ·· ·,'lrk] so that 1111 = k. Also
define m = Irl and r = Ipl, and define variables as foll ows.
kh: I f.,..." satisfies the requirellents of Lelllla 2·2 5, then hh is
the silalle st value of i, 15 i < k, for which 'Ir; satisfies
these r equi re ments.
Otherw1 S6 , hh = k.
hzb: This is the lIaxhum value "Of 1, 1 <i< min{k, r}, such
that .:UG,1r,,,(i») = MG,'Ir,p{;~.
..
(2) If v is non-terminal, proceed to search T(G, 11", v).
(Al) Add (fix(,), mere,)) to 1/1" (1f there is room) and set
6:=6v6(1).
67
are equivalent, and so all those descended from V<" are equivale n t,
giving a contradiction.
2·30 We will now give a forl&&l description of the cOlllplete alg orithm.
N()tu: (1) lab and cAg are boo lean var i ables. If lah = [Link], p 15 not
used, and the algori th. only searches for terll1inal nodes equivalent to
~. We will s how I n Theo rem 2·33 that use tul into rmation a bout Aut(G) 15
still obtained.. If dig = true, the algorithm will not use Lemma 2·2 5,
and. will be vaUd f or digraphs and graphs with loops (for which Lemma
2·25 does not ho l d) .
(11) The va riable J.I r e fers everywhe r e to the node [71"1,71"2, ···, 7I"~1.
2·3 1 Algorithm GilJ ~n G E g(V) and 7r E a{V), find g~n~[Link] for Au t(G),.
and (optionally) compu.t~ C{G,7r) .
0) k := Jize := 1
h := lub := indez := I := 0
8 := discrete partitio n o f V
kh:= 2
"
I f (1fl E P and dig = false) hk:= 1
Vt := minWI
(2) k:= Ie + 1
Ai<:= A(G,1f,II)
If (h= 0) go to (5)
qzb := A.;, - zb k
Go to (6)
Vk:= min W~
Go to (2)
Go to (4)
(6) Ie' := k
69
"" := 1I1nthh-l, IIIU:{M - 1, [Link]}}
1:= 1I1n{1 + 1, L}
AJ- := IIlCr (fI'IoIl)
"'r := flx(fI'llll )
Go t o (12)
I f (k ~ [Link]) go t o (8)
Go to (10)
(9) p := II
qzb := 0
hI; := hzb:= Ie
zb" +1 := 00
Go to (6)
(to) 1: = min{l + 1, L}
(h := IIcrb)
flr: = flxb)
"
O:=OvO(-r)
Output '1
k:= II.
Go to (13)
(11) k := hb
If (k> h) go to (17)
If (k=h) go to (14)
II. := Jt
(14) If (tlk and ttlh are in the same cell of 0) indllx := indllx +1
1110 := mini tI e W" I II > tlk}
If (1110 = 00) go to (16)
hzb:= It
qzb := 0
Go to (2)
index:= 0
71
.I::=Jc - 1
Go t o (1 3)
(17) If (ek = O) set Wh:= Wknn , for each i, l<i < l, such
t hat (1I 1, V2' ··· , Vk _l } C tIJ,
If (v. ~ 00) go to (5 )
.1::= k-l
Go to (13)
(1S) h := ht := hzf := k
!:= II
k:= .1:-1
p :=v
hzb := hb := k +1
qzb := a
Go t o (13 )
o
2·32 Con sider the stage during t he execu tion of Algo rl tb.
2·31 tha t
ve pas s the poi nt marke d B (1n Step (la». At t his instan t define
K = k - l and "W. = tI. (1 <i< K ).
71
2·33 Theorem During th.e e:tecut1on of Algo";thm £·91, each. timt we pas,
point A (in Step (16)) or "o,'nt B (in Bte" (18)) th.e foj/owing are trut:
( 1.1 1) 8 = 9(r ( · - I ~
n
(1/1';. OJ) which are used to reduce any W. have WI E ~i' Therefore, e1 t her
Wi is already In the sallie cell of 8 a s Wt or we are sure to discover
so.e a utollOrphl s. "l s uc h that vI < IIi. By the Induction hy po t hesis wI
is In t he salle cell of 9 as W I> and so 1:he upds.1:e 8 := 8 v 8(,} merges
the cell s of 8 contain I ng WI and Wi, c ont [Link] to hypothesis. No te a lso
1:hat we ha ve J ust proved t ha t '1 e Y.
Claim (v) f oll ows fr ail the s impl e observation tha t t he [Link]
of ce lls of 6 s tarts at n and decr eases by at. l east one f or each new
element of Y. o
In cl osI ng we note a few s imple prope rties of the s et of
generato rs of r f ound by Al gorttb:l 2·3 1. These are essentiall y the sallie
as those given in Theo r e ms 35- 38 iu [13] and t he proofs given t here a pply
with only notati onal cMnges. Let Y be the full set Of auto tlo rp hls.s
output by Algorith. 2·31, and let r = Aut (G) .
2·34 Tbeonm (t) Y d(l t l not comain ~ny elements of the form ,.,6, wh.!re
1,6 E r, supp(,)n supp(5) = 0 an.d" -:I:- (1) rf 5.
(c) bin) = o.
75
3·3 Unord ered partit; ionl
The only unord ered partit ion used by Aljo ritlm 2.31 Is
Fore.
any v e. V let 8. denot e the cell of e
conta ining " and let p(tI) = ain8...
Clear ly e
can be uniqu ely repres ented by the array p, and most of
the
neces sary quest ions abou t S can be answe red very quick
ly by refere nce
to p. For examp le, if 11, 'W € V then 11 and 'W Ilre In the
salle cell of
8 if and only if 11(,,) = p{w), and 11 E acr(S) if and only
i f p{,,) =".
This repre senta tion of 8 suffe rs fro. the dlsadv l.\ntag
e that
updat es of the form S;= SvO(-J), for 1 € S ,,' are quite expen
sive in terms
of computat i on tille . This proble lll has been cons i de rably
a ll ev iated by
the use of a second a rray q whlch "chain s together~ the
eleme nts of each
cel1. More precis ely, if i € lIIcr(S). the n S. = {i. q(,), q(q(t),
"q(q(q('ln. · ·· },
where the s equen ce termi nates on the te rm before the first
ze ro.
3·4 Graph .
[Link] lthm 3·3 1 requi r es the input graph G and, for reason
ably
effic ient opera tion, requi res the gra ph varia ble G(p).
Froll t he great
number of possi ble ways of repre sentin i these graph s in
the compu ter, we
Ilave chosen All adjac ency l:l4trl x repre senta tion becau se
of It s great er
storag e economy. More precis ely, G is stored as a list
of n blt-
vecto rs repre senti ng N(1,G), N(2,G). ··· ,N(n, G), and so
requi res around
n 2 bits of storag e. Since Algor ithm 3·31 i s valid also
fo r digrap hs, it
1s clear ly Dot possib l e t o reduc e t his storag e requir
ement in gener al.
However "if the prog ram was only 1ntenr ied to be apPlie d
an graph s with
ve ry loW' degre e, a dlf f e r en t so r t of repre senta tion would
save space ,
and proba bly time as wel l.
Algor ithm 2·5 can easily be implem ented usi ng the data struc
ture s
above . We '01111 now consi der tbe effici ency wbich can
be a c hieved i n
such an Imple menta tion. The follow 1ng complex1 ty resul
t wa s sugge sted
by a re18te d resul t 1n Gries [ 7] . For t he neces sary defin
iti ons , r e f er
back t o Secti on 2·9.
J·6 Theorem For 4ny G E Q(V), fr IE LI(Y) [Link] dirlinct 111, 1Iz, " ' ,11... _1 IE
V, the deri1led partiti on nut l'lrl,1rZ,·· ·, 'lrml can b. computed in O(n:l l og n)
time, auuming an impl.m entation in which. .i(1I, W ) can be computed in time
proportional to IWI, for an~ v IE V, W C v.
For a ny gi ven W, the nec essllry r exeeuti ons of Step (l) can be
performed in O(nI W I) t i me. Therefore the total time for the comp utation
of l'lrI, 'II"~,·· · , 'II"",lis O(n2+nEIWI), where t he sum 15 over all sets
a s si gned to W during any execution of St ep (2) (f or any execution of
Algorithm 2·5).
The value of q., c lea r l y reDlll i lls constant or dec reases betwee n
dIffe r ent exec utions of Al s or i thm 2·5. The ool y other place where i t can
cha nge is dur i ng St ep (3) , when ha reDlll i ns fixed whl1e (II decreases, Of
77
Por our particular choice of data structures, and our part icul a r
implemen t a t ion environmen t, we have found that the fastest way to compute
d(v, W} for ",/30 <
IWI < A approxilll4tely 11$ to represent W as a bit-
vector and t o count the numbe r of one- bi t s in the bit-vector re present ing
N(v ,G) nW. Altbough this t echnique (used for IWI > n appears to r ed uce
t he t otal the in - t he aajarity· of c ases, 1t has t he unfortuna t e side-
effect of invalidating the pre mises of Theo r ea 3·6. The be st [Link]
for the bound 0(n 2 10gA) which we have been able to prove I s O(n ~).
Since the time require d for the computation of d(v, Mr) is now essenti ally
independent o f IWI, Step (3) o f Algorithm 2·5 can be simplified by us ing
t = 1. This is espe cia lly conven ient if t he seq uence a is r epresented
as a set at poin t ers to t he array a (see Sectlon 3·2) .
The ind ica tor func ti on A Is e valua ted b y the s ub r ou t ine which
1mplements Algo rlt hll 2·5. It Is f ormed by taU ng cell s i zes, relative
ve rt ex d eirees and other inf ormation .... hi ch 15 computed 1n the course
"
of Algori thm 2·5, and merging these into Ii single integer value in a
"random" fashion (see Section 2·28).
3· 10 Experimental performance
"
100
Q c
u~
io
s,, ~onds
10
/
G, /
/
/p
/
/
1 /
/
/
/
/
/
/ G,
/
/
/
/
/
/
-1 /
/
/
/
/
/
/
/
/
/
- 01 ~____~~~~.-~/~~~,-____~__~-.-.-.~~.
10 100 lODe
nWllber o f vert ices
Figure 3· 1
"
frequency. The graphs represented by the curve R~ were
made by randomly generating three permutations '71, '72 and
'7 ~ E S .. such that :r;6 ~:r; c6 E b~,'7~,'7n) and :r;1'i rf :r;'l1
(1 <i < j < 3) for each x E V. Define G by V(G) = V
and E(G) = {xx'l; 1 x E V, 1 <i< 3}. For n > 40 all those
graphs constructed had trivial automorphism groups, and
produced search trees with maximum depth 2.
81
2'/e1Jel regular (see Mathon tl 0J ) . There are good theoreti -
cal reasons aD] t o expect 2- level regula r g ra phs to be
parti cula r ly dl ftlc ult to pr ocess, and this Is bor ne out
by e xpe rie nce. The graphs Aeo and B no (60 ver ti ces; see
[10]) requi red 79 and IS O seconds r e spective ly, while the
graphs A72 - D 72 (7 2 verti ces) require d about 500 seconds
each.
3· 12 Duign ilomorphism
A lIuch more d iffi~ult problem posed by two BI SDs wt~h 126 points
and 525 blocks has be en previ ous ly disc ussed in Stanton and McKay (17].
3· 13 Hadamard equivalence
Other ~orkers (see 16] for eXBIple) have found t hat a count of
small subgraphs (e. g. cllques) can ofte n be used to provide an inl UaI
8J
pa r titioning of tbe vertices of a. d i fficult gra ph, wbi c h greatly spee4~
up a subsequent i somorpbi s m test. Siailar techniques can be usel1 bere,
but they are of no use in [Link] cases. SOlle of the hardest graphs aacmgst
the 126 ment ioned above have only two orbits (the v-type vertices and the
others) - the inltlal partitioning which we were usini anyway (because of
Theorem 3·15). However we have devised a me thod based on a generalisati on
of the profile l1et1ned 1n [51 Which can be used to refine the partition s
at the illmedlate s uccesso rs of the root node 1n T-(G,1T). With this
impr ovement, we can now process t hese graphs 1n about 20 seconds on the
average.
EXAMPLES
..
(2 3) (6 7) (10 11) (14 15) (18 19) (22 23) (26 27) (30 31)
Ir(~;)1 = 6 18(r{3»)1 = 16
(S 9) (6 10) (7 11) (8 1 2) (21 25) (22 26) (23 27) (24 28)
Ir(2)1 = 24 18(p(2»)1 = 10
(9 17) (10 18) (11 19) (12 20) (13 21) (14 22) (15 23) (16 24)
defined as follows.
"
(11 12 13 14 15)
(6 21) (7 22) (8 23) (9 24) (10 25) (11 15) (12 17) (13 18) (14 19) (15 20)
rr(2}1= 20000 IO(r(2)1 = 7
(25)(34)
[r(I )1 = 40000
(12345)
11 15 21) (2 7 12 17 22) (3 8 13 18 23) (4 9 14 19 24) (5 10 15 20 25)
_ 1000000 IW)I 1
REFERENCES
[4] J.A. Bondy and U.5.R. Murty: Graph Theory with Applications,
Macmillan (1976).
[6] D.G. Cornel1 and R.A. Mathon: Algorithmic techniques for the
generation and analysis of strongly regular graphs and other
combinatorial configurations. Annals of Discrete Math. 2 (1978)
1- 32.
86
[8) J. Hopcroft: An nlogn algorittm. for minimizing states in
a finite automaton. Theory of Machines and Computations.
Academic Press (1971) 189-196.
[17] B.D. McKay and R.G. Stanton: Isomorphism of two large designs.
Ars [Link] 6 (197B) 87-90.
"