a fast backtracking algorithm to test directed graphs for isomorphism using distance matrices de...

Upload: calina-sechel

Post on 11-Feb-2018

216 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/23/2019 A fast backtracking algorithm to test directed graphs for isomorphism using distance matrices de Douglas C. Schm

    1/13

    A F a s t B a c k t r a c k i n g A l g o r i t h m t o T e s t D i r e c t e d G r a p h sf o r I s o m o r p h i s m U s i n g D i s t a n c e M a t r i c e s

    DOUGLAS C. SCHMIDTVanderbdt Unwers~ty, Nashwlle, TennesseeANDLARRY E. DRUFFELUnited States A w Force Academy, Colorado

    A B S T R A C T A backtracking algomthm for testing a pair of digraphs for isomorphism is presented Themformatlon contained m the distance matrix representation of a graph is used to estabhsh an lmtlalpartltmn of the graph's vertices This distance matrix reformation is then apphed m a backtrackingprocedure to reduce the search tree ofposmble mappings While the algorithm is not guaranteed to run mpolynomml time, it performs efficmntly for a large class of graphsKEY WORDSAND PHRASES backtrack programming, digraph, distance matrix, momorphlsm, partltmnmgC R C A T E G O R I E S 5 3 2

    A new backtr acking algomth m for testi ng a pair of directed graphs for isomorphi sm ispresent ed in this paper. The algori thm is effic ient for a large class of graphs andterminates e ither providing the isomorphism, or Indicating that there is no isomor-phism for the given pair of graphs.Giv en two graphs , G 1 and G 2, the prob lem of det erm in in g an isomorp hism, ff itexmts, is important. I t has appli catmn m a varmt y of f ields including chemistry ,netwo rk theory, and reformat ion retr ieval. The problem can be solved by exam ini ngall N! perm uta tio ns of N vertices. However, this approach is practical only for graphswith very smal l N.

    Although there have been a t tempts to f ind a mathematica l func t ion which wil lidentify isomorphic graphs [1, 2], no such function has been found which can becomputed in polynomial t ime. The problem is known to be in the set ofN P (nondeter-ministm polynomml) problems but i t is not kno wn if i t is NP-complete (see Kar p [3])

    Since heuris tics ha ve been employed successfully on a varie t y of problems whichhave exhau stiv e search solut mns of factorial or exponent ia l order, t hey were appliedto the graph isomorphism problem by Unger [4], who reported processing t imes forsome 24 node graphs at 2 min on an IBM 7090. For some 12 node graphs, however, thetim e was up to 7 min. Ot her h euri stm a lgo rit hms ha ve been proposed [5-7].

    Copyright 1976, Association for Computing Machinery, Inc General permission to repubhsh, but notfor profit, all or part of this maternal is granted provided that ACM's copymght notice is given and thatreference is made to the pubhcatlon, to Its date of issue, and to the fact that reprinting pmvfleges weregranted by permission of the Assoclatmn for Computing MachineryThis work was done at the Systems and Information Science Department of the Vanderbdt EngineeringSchool, Vanderbllt Unlvermty, Nashville, Tennessee, and was supported m part by a VanderblltUmversity Research Council GrantAuthors' addresses D C Schmldt, Systems and Information Scmnce Department, Vanderbllt Umver-slty, Box 6146, Station B, Nashville, TN 37235, L E Druffel, Department of Astronautics and ComputerSoence, Umted States Air Force Academy, CO 80840Journal of the Association or ComputingMachinery, Vol 23 No 3 July 1976 pp 433-445

  • 7/23/2019 A fast backtracking algorithm to test directed graphs for isomorphism using distance matrices de Douglas C. Schm

    2/13

    4 3 4 D . C S C H M I D T A N D L. E D R U F F E LS h a h , D a v i d a , a n d M c C a r t h y [8] h a v e p r o p o se d a b a c k t r a c k i n g a l g o r i t h m f o ru n i q u e l y c o d in g g r a p h s . I f t h e u n i q u e c o de s f o r a p a i r o f g r a p h s a r e t h e s a m e , t h e n t h e

    c o d in g d e f in e s a n i s o m o r p h i s m . A n o t h e r t y p e o f g r a p h c o d in g h a s r e c e n t l y b e e na p p l i e d b y B e r z tl s s [9 ], u s i n g a b a c k t r a c k p r o c e d u r e t o d e t e r m i n e a l l i s o m o r p h i s m s .T h e p r o c e s s i n g t i m e s r a n g e f r o m 3 6 t o 2 41 se c fo r 1 2 v e r t e x g r a p h s o n a n I B M 3 60 /5 0.

    C o r n e i l a n d G o t h e b [1 0, 1 1] p r o p o s e d a v e r y p o w e r f u l a l g o r i t h m f o r g e n e r a t i n g t h ea u t o m o r p h m m p a r t i t i o n w h i c h l e a d s t o a p o l y n o m i a l t i m e i s o m o r p h i s m a l g o r i t h m .T h e m e t h o d w a s b a s ed o n a co n j ec t ur e w h i c h R M a t h o n h a s s i n c e s h o w n i s n o t t ru e[12]. T h e r e f o r e t h e i r a l g o r i t h m b e c o m e s a v e r y u s e f u l b a c k t r a c k i n g m e t h o d . T h e yr e p o r t t i m e s a s lo w a s . 03 3 m i n f o r a 6 0 - v e r t e x g r a p h , a n d u p t o 38 .7 m i n f o r a 6 0-v e r t e x p o l y g o n , u s i n g a n I B M 7 0 9 4 .

    H o p c r o f t a n d T a r j a n [1 3], H o p c r o f t a n d W o n g [1 4], a n d W e m b e r g [ 1 5] h a v e a l ld e v e lo p e d p o l y n o m m l ti m e m e t h o d s f o r t e s t i n g p l a n a r g r a p h s f o r i s o m o r p h i s mU n f o r t u n a t e l y , e a c h o f t h e s e a l g o r i t h m s r e h e s o n p r o p e r t ie s o f p l a n a r g r a p h s w h i c hd o n o t e x t e n d t o t h e g e n e r a l c a s e .Fundamental Deftnttmns and RelatmnshlpsB e f o re d e s cm b i n g t h e a l g o m t h m , t h e i s o m o r p h i s m p r o b l e m w i ll b e f o r m a l l y d ef in e d .M a n y o f t h e t e r m s a n d c o n c e p ts u s e d h e r e a r e w e l l k n o w n m g r a p h t h e o r y T h et e r m i n o l o g y u s e d i n th i s p a p e r i s a d a p t e d f r o m B e h z a d a n d C h a r t r a n d [16].

    G i v e n a p a i r o f g r a p h s , ~G ~ a n d G 2, a n i s o m o r p h i s m i s a o n e - to - o n e m a p p i n g 4 ' f ro mt h e v e r t i c e s o f G j o n t o t h e v e r t i c e s o f G ~ s u c h t h a t ~b p r e s e r v e s a d j a c e n c y a n dn o n a d j a c e n c y o f t h e v e r ti c es . I n t e r m s o f t h e a d j a c e n c y m a t r i x , t w o g r a p h s G ' a n d G ~a r e i s o m o r p h ic i f a p e r m u t a t i o n o f t h e r o w s a n d c o r r e s p o n d in g c o l u m n s o f a d j ac e n c ym a t r i x A ~ w i l l p r o d u c e t h e a d j ac e n c y m a t r i x A LI n t h i s p a p e r t h e c o n c e p t o f p a r t i t i o n i n g b y t h e c o m p o s i t io n o f v e c t o r s w i ll b e u s e d .F o r i l l u s t r a t i v e p u r p o s e s , t h e composttion o f a p a i r o f v e c t o r s w i l l b e d e f i n e d t o b e t h et e r m w i s e j u x t a p o s i t io n o f t h e i r e l e m e n t s . I n p r a c t m e t h i s p r o c e s s c an b e p e r f o r m e d i nh n e a r t i m e u s i n g a l is t te c h m q u e d e v e lo p e d b y H o p c r o f t a n d W o n g [14].A d e g r e e s e q u e n c e o f g r a p h is m e r e l y a l is t in g o f t h e d e g r e e s . I n d e g r e e a n do u t d e g r e e s e q u e n c e s c a n s i m i l a r l y b e d e fi ne d . I n t e r m s o f t h e a d j a c en c y m a t r i x , t h ed e g r e e se q u e n c e c a n b e g e n e r a t e d b y s u m m i n g t h e r o w s a n d c o l u m n s c o r r es p o n d i n gt o e a c h v e r t e x . T h e o u t d e g r e e s e q u e n c e , t h e m d e g r e e s e q u e n c e, a n d t h e d e g r e es e q u e n c e f o r G r a p h 1 ( F i g u r e 1 ) a r e [ 3 ,2 , 2 ,2 , 2 ,2 ] , [ 2 ,2 , 2 ,3 , 2 ,2 ] , a n d [ 5 ,4 , 4 ,5 , 4 ,4 ] ,r e s p e c t i v e l y .

    F o r a n y g r a p h G ~ t o b e i s o m o r p h i c t o G ~, G ~ m u s t e x h i b i t t h e s a m e d e g r e es e q u e n c e s a s G j. T h i s i s a n e c e s s a r y b u t n o t s u f f i c i e n t c o n d i ti o n f o r i s o m o r p h i s m .M o s t e x i s t i n g a l g o r i t h m s u s e t h i s n e c e s s a r y c o n d i t i o n t o p a r t l t m n v e r t i c e s a c c o r d i n gt o t h e i r d e g r e e s . T h u s e x i s t i n g h e u r i s t i c a l g o r i t h m s c o n s i s t o f t w o p h a s e s : ( 1) g e n e r a t ea n i m t i a l p a r t i t i o n i n g o f v e r t i c e s b a s e d o n th e d e g r e e s o f t h e v e r t i c e s , a n d (2 ) e m p l o yh e u r i s ti c s w h m h a t t e m p t t o c o n s i d er t h e n e i g h b o r h o o d o f e a c h r e s p e c t iv e v e r te x .T h e s e h e u r i s t ic s r e p r e s e n t a t t e m p t s t o c h a r a c t e r i z e a v e r t e x b y it s re l a t m n s h l p w i t he v e r i n c r e a s in g n u m b e r s o f v e r t ic e s w h i ch a r e m o r e d i s ta n t l y c o n n e c te d . W h a t s e e m st o b e n e e d e d i s a w a y o f e v a l u a t i n g t h e r e l a t i o n s h i p o f a v e r t e x w i t h a l l o t h e r v e r t ic e s ,o r id e a ll y , s o m e w a y t o e v a l u a t e i ts r e l a t m n s h i p w i t h t h e r e s t o f t h e g r a p hThe Dtstance MatrtxT h e d i s t a n c e m a t r i x is a c h a r a c t e r i z a t i o n o f a g r a p h w h i c h o f f e rs i n f o r m a t i o n o n t h er e l a t i o n s h i p b e t w e e n a l l v e r t i c e s i n t h e g ~ v en g r a p h . T h e distance matrtx D i s a nNN m a t r i x i n w h i c h t h e e l e m e n t d,, r e p r e s e n t s t h e l e n g t h o f t h e s h o r t e s t p a t h

    A s u p e r s c m p t w i l l b e a p p e n d e d t o a l l v a r i a b l e s d e s c m b m g p r o p e r t m s o f a g r a p h w h e n a s p e cf f ic g r a p h i sb e i n g d i s c u s s e d T h u s , v,~ i s t h e ~ t h v e r t e x o f G ~, e t c

  • 7/23/2019 A fast backtracking algorithm to test directed graphs for isomorphism using distance matrices de Douglas C. Schm

    3/13

    A F a s t B a c k t r a c k i n g A l g o r i t h m

    Fm 1 Graph 1

    435

    between the vertices v , and v~ For every pai r of vertices v, and v~, there is a umqueminimum distance. If i = j, then d,~ = 0. If no pat h exists between the two vertices,the length is defined to be infimte.

    Theorem 1 is a rest ateme nt of a theorem introduced by Hakl mi and Yau [17].THEOREM 1. I f G ~s a n N - v e r t e x r e a h z a t m n o f D , t h e n G i s u n i q u eGiven a graph, generation of the distance ma trix is a matt er o f finding the shortestdistance between every pair of vertices. A nu mber of algorit hms have been developedto construct the distance matrix, man y of which are summamzed by Dreyfus [18].Floyd's algori thm [19], while of order O (N3), is simple and convement to implement.Given the adjacency matr ix of Graph 1 (Table I), any of these algori thms will yieldthe distance matmx shown m Table II.A n I m p r o v e d I n i t z a l P a r t ~ t t o n in gSince the distance matmx is a unique represent ation of a graph and since it containsinformation concerning the relationship between vertices in the graph, it offers ameans of finding an initial par tition which may be finer than tha t obtained by usingthe degrees of the vertices.Define a r o w c h a r a c t e r i s t i c m a t r i x X R to be an N (N-l) matr ix such that theelement xr,,~ is the number of vertices which are a distance m away from v~. Simi larlydefine a c o l u m n c h a r a c te r t st ic m a t r i x X C such tha t each element xc,,,~ is the numberof vertices from which v, is a distance m. A c h a r a c t e r i s t i c m a t r i x X Is formed bycomposing the corresponding rows o f X R and X C . To illustrate the formation of thesematrmes, consider Graph 1, which is defined by the adjacency matri x in Table I andthe distance matri x shown in Table II. The charactemstic matrices X R , X C , and X forGraph 1 are shown in Tables III-V The characteristic matrix will be represented bythe termwise juxtaposition of the appropriate elements in the array .Information from the character istic matr ix may be used to form an initial partition .v: will map to v~ in an isomorphism only if xl , , = x~ . .. Vm. Vertices which exhibitidentical rows of the characteristic matrix will be assigned the same c l a s s . In order todescribe the partitioning process, a c l a s s v e c t o r C will be defined such that theelement c, is the class of vertex v,. All vertices with the same class are thenpartitioned into the same cell The partition so obtained from the characteris ticmatrix is often superior to that obtained from the degree sequence. Algorithm 1(Appendix A) is a formal definition of the initial par titi oning process.

  • 7/23/2019 A fast backtracking algorithm to test directed graphs for isomorphism using distance matrices de Douglas C. Schm

    4/13

    4 3 6 D. C. SCHMIDT AND L. E. DRUFFELF o r e x a m p l e , l e t G ' b e G r a p h I a n d G 2 b e G r a p h 2 ( F ig u r e 2 ). T h e d i s t a n c e m a t r i x

    f o r G r a p h 2 is g i v e n i n T a b l e V I a n d t h e c h a r a c t e r is t ic m a t r i x X i n T a b l e V I I . T h ein i t i a l pa r t i t i o n , de f ine d by C ' = [1 ,2 ,3 ,4 ,3 ,2 ] a nd C 2 = [2 ,3 ,4 ,3 ,2 ,1 ] , i s [ (1 ) (2 ,6 ) (3 ,5 ) (4 )]a n d [(6 )(1 ,5 )(2 ,4 )(3 )]. T h e i n i t i a l p a r t i t i o n i n g u s i n g t h e v e r t e x d e g r e e s i s[ ( 1 ) ( 2 , 3 , 5 , 6 ) ( 4 ) ] a n d [ ( 6 ) ( 1 , 2 , 4 , 5 ) ( 3 ) ] . T h e i n i t i a l p a r t i t i o n b a s e d o n t h e d i s t a n c e m a t r i xm a y b e m o r e r e fi n e d t h a n t h a t b a s e d o n t h e a d j a c e n c y m a t r i x a n d c a n n e v e r b e l es sSO.

    T A B L E I A D J A C E N C Y M A T R I X F O R G R A P H I T A B L E II D I S T A NC E M A T R I X F O R G R A P H 11 2 3 4 5 6 1 2 3 4 5 6

    1 0 1 0 0 1 1 1 0 1 2 2 1 12 0 0 0 1 1 0 2 2 0 2 1 1 23 0 1 0 1 0 0 3 2 1 0 1 2 34 1 0 1 0 0 0 4 1 2 1 0 2 25 0 0 0 I 0 1 5 2 3 2 1 0 16 l 0 1 0 0 0 6 1 2 1 2 2 0

    TA BL E II I. Row CHARACTERISTIC MATRIX FOR TABL E IV COLUMN CHARACTERISTIC MATRIXGRAPH ] FOR GRAPH 1

    1 2 3 4 5 1 2 3 4 51 3 2 0 0 0 1 2 3 0 0 02 2 3 0 0 0 2 2 2 1 0 03 2 2 1 0 0 3 2 3 0 0 04 '2 3 0 0 0 4 3 2 0 0 05 2 2 1 0 0 5 2 3 0 0 06 2 3 0 0 0 6 2 2 1 0 0

    T A B L E V C HA RA CT ER IS TI C M A T R I X F O R T A B L E V IG R A P H 1 1

    t 2 3 4 5 1 01 32 23 00 00 00 2 12 22 32 01 00 00 3 23 22 23 10 00 00 4 34 23 32 00 00 00 5 25 22 23 10 00 00 6 16 22 32 01 00 00

    DISTANCE MATRIX FOR GRAPH 22 3 4 5 62 2 1 2 10 1 2 3 22 0 1 2 12 1 0 1 21 1 2 0 21 2 2 1 0

    FIG 2 Gra ph 2

  • 7/23/2019 A fast backtracking algorithm to test directed graphs for isomorphism using distance matrices de Douglas C. Schm

    5/13

    A F a s t B a c k t r a c k i n g A l g o r i t h m 4 3 7TABLE VII C H A R AC T E R I ST I C M A T R I X F O R G R A P H 21 2 3 4 5 6

    1 22 32 01 oo oo2 22 23 10 oo oo3 23 32 oo oo oo4 22 23 10 oo oo5 22 32 Ol oo oo6 32 23 oo oo oo

    T HE O R E M 2 . I f t w o v e r ti c e s v , a n d v~ a r e p a r t i t i o n e d ~ nto s e p a r a t e c l a s s e s b y t h ed e g r e e s e q u e n c e , t h e y w i l l a ls o b e p a r t i t i o n e d ~ nto s e p a r a t e c l a s s e s b y t h e c h a r a c t e r is -t i c vec t or .

    PR OO F. T h e e l e m e n t s o f t h e ro w c h a r a c t e r i s t m m a t r i x xr,~ a r e t h e e l e m e n t s o f t h eo u t d e g r e e s e q u e n c e. A s i m i l a r r e s u l t fo l lo w s f o r t h e c o l u m n c h a r a c t e r i s t i c m a t r i xe l e m e n t s xc,~.

    S i n c e th e i m t m l p a r t i t m n c a n b e u s e d to l i m i t t h e s iz e o f t h e s e a r c h t r e e , i t m a yr e d u ce t h e a m o u n t o f c o m p u t a t i o n t h a t t h e b a c k t r a c k i n g a l g o r i t h m m u s t d o . I n s o m ec a se s i t w i l l p r o w d e a m e a n s o f i m m e d m t e l y d e t e r m i n i n g t h a t n o is o m o r p h i s m e x i s t sf o r a g i v e n p a i r o f v e r t m e s .

    D e f i n e a c l a s s c o u n t v e c t o r K s u c h t h a t t h e e l e m e n t k , i s t h e n u m b e r o f v e r t i c e s i nc l a s s ~. I t f o ll o w s t h a t l f G ~ s i s o m o r p h i c t o G 2, t h e n k : = k~, V i. P m r s o f g r a p h s w h i c hd o n o t h a v e i d e n t i c a l c l a ss c o u n t v e c to r s m a y b e i m m e d i a t e l y r e je c t e d w h e n t h e i n i t i a lp a r t i t i o n i s c o m p u t e d .

    T h e B a c k t r a c k z n g A l g o r z t h mW h i l e t h e i n i t i a l p a r t i t io n g e n e r a t e d b y A l g o r i t h m 1 u s u a l l y r e d u c e s t h e s i ze o f t h es e a r c h t r e e , i n g e n e r a l i t d o e s n o t u m q u e l y c h a r a c t e r i z e t h e v e r t i c e s o f a g r a p h . F o ri n s t a n c e , t h e i n i t i a l p a r t i t i o n i n g o f v e r t i c es , w h e r e G 1 i s G r a p h 1 a n d G 2 i s G r a p h 2 ,r e q u i r e s t h a t i f G 1 a n d G 2 a r e i s o m o r p h i c , t h e n v~ w i l l b e m a p p e d t o v~ a n d v~ w i l l b em a p p e d t o v~. B u t t h i s l e a v e s s o m e u n c e r t a i n t y a b o u t t h e m a p p i n g s f o r v e r t i c e s v~, v ]a n d v ] , v ]. E v e n t h o u g h t h e i n i t i a l p a r t i t i o n u s i n g t h e d i s t a n c e m a t r i x m a y b e a ni m p r o v e m e n t o v e r t h a i o f t h e d e g r e e s e q u e n c e , i t d o e s n o t u n i q u e l y c h a r a c t e r i z e t h ev e r t i c e s .

    A s e c o n d a l g o m t h m w h i c h s e le c ts p os s ib l e v e r t e x m a p p i n g s b e t w e e n t h e t w o g r a p h sa n d c h e c k s th e s e m a p p i n g s f or c o n s i s t e n c y i s u s e d t o r e so l v e a m b i g u i t i e s i n t h em a p p i n g s . T h e m a p p i n g o f v~ t o v~ i s c o n s i s t e n t i f: (1 ) e v e r y e l e m e n t di s = d~8 a n d dJ , =ds2~ V j , s s u c h t h a t v~ h a s b e e n m a p p e d t o v~; a n d ( 2) e v e r y e l e m e n t d~k (v~ n o tp r e v i o u s l y m a p p e d ) h a s a c o r r e s p o n d i n g d~p (v~ n o t p r e v i o u s l y m a p p e d ) s u c h t h a t c~= c~. T h u s a c o n m s t e n t m a p p i n g i m p l i e s t h a t r o w 1 a n d c o l u m n ~ o f D 1 h a v ec o r r e s p o n d i n g e l e m e n t s i n r o w r a n d c o l u m n r o f D 2, a t l e a s t fo r a l l p r e v i o u s l y m a p p e dv e r t ic e s , a n d t h a t t h e r e m a i n i n g e l e m e n t s o f t h o s e r o w s a n d c o l u m n s d o n o t p r e c l u d ef u r t h e r c o n s i s te n t v e r t e x m a p p i n g s i f a n y m a p p i n g s r e m a i n . T h e a l g o r i t h m w i l lc h o o s e p a i r s o f v e r t i c e s v~ a n d v~ w h i c h a r e m t h e s a m e c l a s s a n d w i l l i n v e s t i g a t e t h ec o n s m t e n c y o f m a p p i n g v : t o v~. S u c h a m a p p i n g i s a s s e r t e d b y c o m p o s i n g t h e c l a s sv e c t o r f or t h e a p p r o p r i a t e g r a p h w i t h t h e r e s p e c t i v e r o w s a n d c o l u m n s o f t h e d i s t a n c em a t m c e s . T h e c o m p o s i t io n g e n e r a t e s a n e w c l a s s v e c to r , w h i c h d e f i n e s a re f i n e dp a r t i t i o n . I f t h e m a p p i n g i s c o n s i s t en t , a n o t h e r p a i r o f v e r t m e s c a n b e c h o s e n fo rm a p p i n g . I f a p a r t i t i o n i s r e a c h e d s u c h t h a t t h e r e a r e n o c o n s i s t e n t m a p p i n g s , t h e n am a p p i n g b e t w e e n t w o v e r t i c e s f or w h i c h t h e m a p p i n g i s n o t a n i s o m o r p h i s m h a s b e e na t t e m p t e d a n d ~t i s n e c e s s a r y t o b a c k t r a c k t o t r y a n o t h e r m a p p i n g .

    A r e c u r s i v e a l g o r i t h m w h i c h d e s c r i b e s t h i s p ro c e s s i s g i v e n i n A l g o r i t h m 2 (A p p e n -d i x B) . S i n c e a n e w c l a s s v e c t o r a n d a n e w c l a s s c o u n t v e c t o r w i l l b e g e n e r a t e d a t e a c hl e v e l o f t h e r e c u r s l v e p r o c e s s , a n i n d e x w i l l b e a d d e d t o t h e s e v e c t o r s . T h u s C ~ w i l lr e f e r to t h e c l a s s v e c to r f or G r a p h 1 g e n e r a t e d a t l e v e l t . A n e l e m e n t o f t h e v e c t o r c~t

  • 7/23/2019 A fast backtracking algorithm to test directed graphs for isomorphism using distance matrices de Douglas C. Schm

    6/13

    4 3 8 D . C . S C H M I D T A N D L . E . D R U F F E L

    refers to the class of vertex v~ in Graph 1 generate d at level t. Similarly , an index willbe added to the vector notation for the class count vector K.Taking G ~as Graph 1 and G 2 as Graph 2, the example begun in the last section willbe continued to illustrate the selection and re finement process by applying Algorith m2 (the corresponding step number is indicated in parentheses).

    ( 1) t = O . P = O .( 2 ) C ~ = [ 1 , 2 , 3 , 4 , 3 , 2 ] , C a = [ 2 , 3 , 4 , 3 , 2 , 1 ]

    K ~ = [ 1 , 2 , 2 , 1 , 0 , 0 ] , K ~ = [ 1 , 2 , 2 , 1 , 0 , 0 ](3 ) t < N(4 ) t = Po = 0(5) t = O.(6) Choose t = 1, pb = 1(7) Chooser = 6(8) r exists, go to 10(10) ComposeC~ with row I and column 1 of D1 and C~ with row 6 and column 6 ofD z ymldmg C] =[1,2,3,4,5,6], C~ = [6,5,4,3,2,1]

    (11) K] = [1,1,1,1,1,1], K~ = [1,1,1,1,1,1](12) K~ = K~(13) t = 1(14) Go to 3Note that, although the algorithm must continue vemfying the consistency of themappings, each of the vertmes has a unique class assignment so tha t the ma pping ateach level is determined. Since there was no arbitrary choice made at any level,

    either the mapp ing ~b = [1-6, 2-5, 3-4, 4-3, 5-2, 6-1] is an isomorphism or noisomorphism exists for the two graphs. In this case, it is easy to see tha t the mapp ingis an isomorphism. However, the algorithm must continue through all six levels toverify consmtency.Complex t ty o f the A lgor t t hmSince O ( N 3) time is reqmred to generate the distance matrix, at least for densegraphs, the order of the combined algorithms cannot be less than N 3

    Algorithm 1 is reasonably easy to analyze. Formatio n of the row and columncharacteri stic matrices requires O( N 2) time for each matrix. Composition of the rowand column characteristic matrices for the two graphs requires O ( N 2) time. Thussteps 1 throug h 3 require O (N 2) time. The iterat ion steps 5 throu gh 9 are bounded byO ( N ) time. Thus, the initial partition may be realized in O ( N ~) time, given thedistance matrix.Algorithm 2 is not as easily analyzed. Clearly the algori thm mu st reach level N ofthe tree to find an isomorphism. However, because it may backtrack, the number ofbranches is not easily determined. For each branc h, a pair of vectors must becomposed, which requires O ( N ) time and consistency must be verified requir ing O ( N )time. T hus each branch reqmres O ( N ) time. Since there must be at le as tN branches,the lower bound of Algorithm 2 is O ( N 2) time. The upper bound is O ( N . N !) .Althou gh the dmtance matrix is powerful in obtaining an initial partitioning, thereare some classes of graphs for which the information in the distance ma tri x is nobetter th an th at of the adjacency matrix. If, for every pair of nonadj acent vertices [v~,v~], there exists at least one vertex vk such th at the edges [v,, vk] and [vk, v~] exist, th enthe maximum distance will be two. For example, the mformation in the distancematmx may be suppressed by adding a single vertex which is adjacent to every vertexin the original graph. The distance matmx for Graph 3 (Figure 3), excluding vertexvn, shown in Table VIII, presents a character ization of its vertices in which differ-ences are more obvious than that of the distance matri x of Table IX. Table IX reflectsthe addltmn of vertex v~. However, the isomorphism of a pair of graphs is unchangedby the add ition of an equal numbe r of vertices adjacent to all other vertmes, just as itis unchanged by addition of an equal num ber of vertices with degree zero. Note tha t

  • 7/23/2019 A fast backtracking algorithm to test directed graphs for isomorphism using distance matrices de Douglas C. Schm

    7/13

    A F a s t B a c k tr a c k in g A l g o r i t h m 4 3 9

    Fm 3 Graph 3

    TA BLE VI II DISTANCE MATRIX FOR GRAPH 3 WITHOUT Vll1 2 3 4 5 6 7 8 9 101 0 2 3 2 2 1 3 2 1 32 2 0 2 3 1 2 2 3 1 33 3 2 0 2 1 2 2 2 3 14 2 3 2 0 2 1 2 2 3 15 2 1 1 2 0 1 1 2 2 26 1 2 2 1 1 0 2 1 2 27 3 2 2 2 1 2 0 1 3 18 2 3 2 2 2 1 1 0 1 19 1 1 3 3 2 2 3 1 0 2

    10 3 3 1 1 2 2 1 1 2 0

    TABLE IX DISTANCEMATRIX FOR GRAPH 3 INCLUDING V,,1 2 3 4 5 6 7 8 9 I0 II

    l 0 2 2 2 2 l 2 2 1 2 12 2 0 2 2 i 2 2 2 I 2 13 2 2 0 2 1 2 2 2 2 1 14 2 2 2 0 2 1 2 2 2 1 15 2 1 1 2 0 1 1 2 2 2 16 1 2 2 1 1 0 2 1 2 2 17 2 2 2 2 1 2 0 1 2 1 18 2 2 2 2 2 1 1 0 1 1 19 1 1 2 2 2 2 2 1 0 2 110 2 2 1 1 2 2 1 1 2 0 1

    11 1 1 1 1 1 1 1 1 1 1 0

    t h i s i s n o t k n o w n t o b e t r u e i n t h e g e n e r a l c a s e ( s e e U l a m ' s c o n j e c t u r e [ 20 ]) , b u t i t i sc e r t a i n l y t r u e f o r v e r t i c e s o f d e g r e e z e r o o r d e g r e e N - 1 I t i s t m v i a l t o d e t e c t t h ep r e s e n c e o f s u c h v e r t i c e s b e c a u s e t h e r o w a n d c o l u m n w i l l b e a l l o n e s e x c e p t f o r t h ed i a g o n a l e l e m e n t . T h e s e v e r t i c e s m a y b e r e m o v e d f r o m t h e g r a p h s . I n t h i s c a s e , t h e

  • 7/23/2019 A fast backtracking algorithm to test directed graphs for isomorphism using distance matrices de Douglas C. Schm

    8/13

    4 4 0 D . C . S C H M I D T A N D L . E . D R U F F E Li n f o r m a t i o n m a y b e r e t r i e v e d a s e a si l y a s i t w a s s u p p r e s se d , a n d t h e o r i g i n a l g r a p h sm a y b e c o m p a r e d f o r i s o m o r p h i s m .

    H o w e v e r , t h e r e a r e g r a p h s f or w h i c h t h e m a x i m u m d i s t a n ce i s t w o a n d f o r w h i c ht h e r e i s n o s i m p l e w a y t o d i s t i n g u i s h o n e v e r t e x f r o m a n o t h e r . G r a p h 4 (F i g u r e 4 ) i ss u c h a g r a p h . T h e d i s t a n c e m a t r i x f o r G r a p h 4 i s s h o w n i n T a b l e X . C l e a r l y t h ed i s t a n c e m a t r i x y i e l d s t h e s a m e i n i t i a l p a r t i t i o n a s t h e a d j a c e n c y m a t r i x f o r t h i s c l a sso f g r a p h .A Dynarn~c BoundS i n c e th e u p p e r b o u n d o f A l g o r i t h m 2 m a y r e a c h o r d e r f a ct o ri a l, i t s e e m s p r u d e n t t oi n v e s t i g a t e t h e f e a s i b il i ty o f p r e d i c t i n g t h e d i f f ic u l t y o f t e s t i n g t h e i s o m o r p h i s m o f ag i v e n p a i r o f g r a p h s . I f t h e r e a r e L , v e r t i c e s i n t h e ~ th ce l l o f t h e i n i t i a l p a r t i t i o n , t h e na n u p p e r b o u n d t o t h e n u m b e r o f p o ss ib le m a p p i n g s w h i c h w o u l d h a v e t o be i n v e st i-g at ed is l[I~=,( L , !), w h e r e k i s t h e n u m b e r o f c e ll s m t h e i n i t i a l p a r t i t i o n . T y p i c a l l y t h i si s a p e s s i m i s t i c b o u n d .

    T h e a m o u n t o f w o r k r e q u i r e d o f t h e a l g o m t h m d e p e n d s o n th e n u m b e r o f b r a n c h e se x p l o r ed . P r e d i c t i n g t h e p e r f o r m a n c e o f t h e a l g o r i t h m f o r a g i v e n p a i r o f g r a p h st h e r e f o r e r e q m r e s e s t i m a t i n g t h e n u m b e r o f b r a n c h e s t h a t m u s t b e i n v e s t ig a t e d .I f a n y v e r t ic e s a r e u m q u e l y d e f i n e d a f t e r t h e i m t l a l p a r t i t i o n i s o b t a in e d u s i n g

    F I G 4 G r a p h 4

    T A B L E X D I ST A NC E M A T R I X F O R G R A P H 41 2 3 4 5 6 7

    1 02 13 24 15 26 17 2

    1 2 1 2 1 20 1 2 2 2 21 0 1 1 2 12 1 0 2 1 12 1 2 0 1 22 2 1 1 0 12 1 1 2 1 0

  • 7/23/2019 A fast backtracking algorithm to test directed graphs for isomorphism using distance matrices de Douglas C. Schm

    9/13

    A F a s t B a c k tr a c k in g A l g o r i t h m 4 4 1A l g o r i t h m 1 , t h e n t h e m a p p i n g f o r t h e s e v e r t ic e s p r e s e n t s n o c h o ic e . I f a m a p p i n g o f v~t o v~ r e fi n e s t h e p a r t ~ tm n s o th a t a n o t h e r v e r t e x m a p p i n g is u n i q u e l y d e t e r m i n e d ,t h e n t h a t m a p p i n g i s a ls o m a d e . A l l u n i q u e l y d e f i n ed v e r t ic e s a r e t h e r e b y m a p p e d .F o r m a n y g r a p h s , t h e s e s u c c e s s i v e a s s e r t i o n s w i l l, i n f a c t, l e a d t o a t e r m i n a t i o n o f t h ea l g o r i t h m . F o r o t h e r s , a l e v e l w i l l b e e n c o u n t e r e d a t w h i c h a c h o i ce m u s t b e m a d e ;d e s i g n a t e t h i s l e v e l b y p .

    T o e s t i m a t e t h e w o r s t p o ss ib l e c a se , a s s u m e t h a t G I h a s n o a u t o m o r p h i s m o t h e rt h a n t h e t r iv i a l a u t o m o r p h i s m a n d t h a t G 2 i s i so m o r p h i c t o G 1 w i t h t h e v e r t ic e sa r r a n g e d i n s uc h a w a y t h a t t h e a l g o r i t h m w i ll b e r e q m r e d t o i n v e s t i g a t e e v e r y ch o ic ea t e a c h l e v e l. A t t h i s p o i n t , o n l y t h e v e r t m e s o f G 1 w i l l b e c o n s i d e r e d . S i n c e a l lv e r t i c e s w h i c h h a v e i d e n t ic a l a d j a c e n c ie s a r e i n t e r c h a n g e a b l e , c l e a r l y a n y d e o s i o nc o n c e r n i n g o n e i s e q m v a l e n t t o a l ik e d e c is io n c o n c e r n i n g t h e o t h e r . A p a i r o f v e r t i c e sv,, v~ a re ident ical i f d ,k = d~A an d dk, = d ~ , k ~ , j , an d d,~ -~ d~ ,. Id en t i c a l ve r t i c es a r et e m p o r a r i l y p u t i n to s e p a r a t e c l a ss e s A v e r t e x is t h e n m a r k e d a n d t h e c o m p o s i ti o np e r f o r m e d s o t h a t t h e n e x t l e v e l is r e a c h e d T h i s p r o ce s s i s r e p e a t e d a t e a c h l e v e l u n t ilt h e c o m p o s i ti o n w i t h t h e r o w o f t h e c h a r a c t e r i s t m m a t r i x c o r r e s p o n d i n g t o s o m ev e r t e x g e n e r a t e s a p a r t i t i o n i n g s u c h t h a t e a c h r e m a i n i n g v e r t e x i s i n a c la s s b y i ts e lf .D e s i g n a t e t h i s le v e l q . T h e a l g o r i t h m r e t u r n s t o l e v e l p , b u t t h e v e r t i c e s c h o s e n a te a c h l e v e l a r e s ti ll m a r k e d a n d w i l l a l w a y s b e c h o s e n a t t h a t l e v e l b y s t e p 6 o fA l g o r i t h m 2 .

    T h e b o u n d t h e n is a c o u n t o f t h e n u m b e r o f b r a n c h e s t h a t m i g h t p o s s i b ly b er e q u i re d t o c o m p l e t e t h e a l g o r i t h m L e t st b e t h e s iz e o f t h e c l a ss f r o m w h i c h t h ev e r t e x w a s m a r k e d a t l e v e l t . T h u s t h e r e a r e a t m o s t s t b r a n c h e s f r o m l ev e l t. T h em a x i m u m n u m b e r o f b r a n c h in g s r e q u i r e d ~ s

    H s ~ + N s j ( n - q ) .l = p J = p ~ = p

    N o t e t h a t t h is i s a b o u n d o n th e n u m b e r o f b r a n c h e s w h i c h w o u l d b e r e q u i r e d t o m a pG ' o n to a n y o t h e r g r a p h .

    W h e n a l l c e ll s o f a p a r t i ti o n c o n t a i n m o r e t h a n o n e v e r t e x , s o m e a r b i t r a r y c h o ic em u s t b e m a d e a n d t h e d y n a m i c b o u n d i n g i s u s e d . T h e v e r t i c e s s e l e ct e d a t e a c h l e v e l o ft h e b o u n d i n g a l g o r i t h m w i ll a l w a y s b e s e le c t e d a t t h e r e s p e c t i v e le v e l b y s t e p 6 o fA l g o r i t h m 2. R a t h e r t h a n m a k e a r b i t r a r y c h oic e s, s e v e r a l s t r a te g i e s w e r e d e v e l o p e dw h i c h ~ ' sh a pe " t h e b a c k t r a c k t r e e b y m a k i n g h e u r i s t ic a l l y d e t e r m i n e d c h o ic e s.

    S t r a t e g y i c h o o s e s a v e r t e x i n t h e s m a l l e s t c e ll , i .e . c h o o s e s s o m e c e l l j s u c h t h a t L ~i s s m a l l e s t , t h e n c h o o s e s s o m e v e r t e x v~ f r o m c e l l j . W i t h t h i s s t r a t e g y , r e f i n e m e n tr e a l iz e d b y a s s e r t i n g a p a i r o f v e r t i c e s in t h e s m a l l e s t c l a ss m a y r e d u c e t h e s iz e o f al a r g e r ce ll a n d h e n c e r e d u c e t h e s e a r c h i n g r e q u i r e d a t t h e n e x t l e v e l. T h i s s t r a t e g yh a s t h e e f fe c t o f r e d u c i n g t h e b r e a d t h o f s e a r c h , b u t p o s s i b l y p e r m i t s a g r e a t e r d e p t h .I t i s e a s i ly a n d e f fi c ie n t ly i m p l e m e n t e d .S t r a t e g y 2 r e d u c e s t h e d e p t h o f s e a r c h i n g b y g e t t i n g t h e m o s t r e f in e d p a r tl ti .o n a tt h e n e x t l ev e l . T h i s r e q m r e s t h e c o m p o s i t m n o f t h e r e s p e c t i v e r o w o f t h e c h a r a c t e r i s -t ic m a t r i x f or e v e r y v e r t e x w i th t h e c u r r e n t p a r t i t m n t o d e t e r m i n e w h i c h v e r t e xw o u l d y i e ld t h e m o s t c e ll s o f t h e n e x t p a r t i t i o n . S u c h a s t r a t e g y m a y d e c r e a s e t h ed e p t h o f s e a r c h b u t c a n a l so i n c r e a s e i t s b r e a d t h .

    T h e c o n s e q u e n c e o f c h o o s i n g a v e r t e x f r o m c e ll j i s t h a t , a t m o s t , (L ~) H ~= ~ (L ',!)m a p p i n g s n e e d b e ch e c k e d w h e r e t h e p r i m e d c o m p o n e n t s a r e f r o m t h e p a r t i t i o n a t t h en e x t l ev e l. I n s t r a t e g y 3 th e p r o d u c t i s c o m p u t e d f or e a c h v e r t e x a n d t h a t v e r t e xw h i c h p r o d u c e s t h e m i n i m u m p r o d u c t i s c h o s e n . S u c h a s t r a t e g y a t t e m p t s t o m i n i -m i z e t h e b r e a d t h a n d d e p t h o f t h e s e a r c h a t t h e s a m e t im e . I t a ls o r e q u i r e s i n t e r s e c -t i o n o f e a c h v e r t e x to d e t e r m i n e t h e n e x t p a r t it i o n , a n d c a l c u l a t m n o f t h e t e r m f o re a c h v e r t e x .A s a n e x a m p l e o f t h e b o u n d i n g , l e t G r a p h 4 b e G ~. T h e d i s ta n c e m a t m x f o r G r a p h 4

  • 7/23/2019 A fast backtracking algorithm to test directed graphs for isomorphism using distance matrices de Douglas C. Schm

    10/13

    44 2 D . C . S C H M I D T A N D L . E . D R U F F E Li s g i v e n i n T a b l e X . T h e i n i t i a l p a r t i t i o n i n g i s d e f i n e d b y C~ = [ 1 ,2 ,3 ,3 ,2 ,3 ,1 ] . A na r b i t r a r y c h o ic e m u s t b e m a d e s i n c e n o v e r t e x i s in a c l a s s b y i ts e lf . T h e r e f o r e p = 0a n d S o = 2 . U s i n g s t r a t e g y 1 , c h o o s e a v e r t e x f r o m t h e s m a l l e s t c e ll , w h i c h l e a v e s a na r b i t r a r y c h o i c e b e t w e e n v ~, v ~, v ~, v . A r b i t r a r i l y c h o o s e v] a n d c o m p o s e C ~ w i t h r o w1 a n d c o l u m n 1 o l D ~, w h i c h y i e l d s C ~ = [ 1 ,2 , 3 ,4 , 5 ,4 , 6 ]. V e r t i c e s v ~ , v ] , v~ , v ~, a n d v ~a r e t h e n i n c e l ls o f s i z e 1, s o t h a t s~ = 1 . A r b i t r a r i l y c h o o s e v~ a n d c o m p o s e C ~ w i t h r o w2 a n d c o l u m n 2 o f D ~ y i e l d i n g C~ = [ 1,2 ,3 ,4 ,5 ,4 ,6 ]. N o i m p r o v e m e n t h a s b e e n r e a l iz e d ,s o s2 = 1. A r b i t r a r i l y c h o o s e v~ a n d c o m p o s e C ~ w i t h r o w 3 a n d c o l u m n 3 o f D ~ y i e l d i n gC ~ = [ 1 ,2 , 3 ,4 , 5 ,6 , 7 ]. S i n c e t h i s c o m p o s i t i o n d r i v e s a l l v e r t i c e s i n t o s i n g l e c e l l s, q = 2 .T h u s t h e m a x i m u m n u m b e r o f b r a n c h e s w h i ch c ou ld p o ss ib l y b e i n v e s t ig a t e d i nt r y i n g t o m a t c h s o m e G r a p h G 2 t o G r a p h 4 b y m a k i n g a f ix e d s e t o f c h o ic e s f ro m t h es a m e c e l ls i n t h e c o r r e s p o n d i n g p a r t i t i o n o f G 2 f r o m w h i c h v ~, v~, a n d v~ w e r e c h o s e n i s(2 + ( 2 . 1 ) + ( 2 . 1 . 1 ) . ( 7 - 2 )) = 1 4.Implemen ta tmnA l g o r i th m s 1 a n d 2 w e re I m p l e m e n t e d u s in g F o r t ra n I V o n a X e ro x D a t a S y s t e m sS i g m a - 7 w i t h 4 6 K , 3 2 - b it w o r d s o f a v a i l a b l e c o r e s t o r a g e . W i t h o u t p r o v i d i n g f o rs w a p p i n g d a t a , t h e p r a c t i c a l l im i t f o r t h i s i m p l e m e n t a t i o n i s N = 1 00 . S i n c e p r e v i -o u s l y r e p o r t e d i m p l e m e n t a t i o n s e x c e p t t h a t o f C o r n e l l a p p e a r e d t o b e t im e b o u n dr a t h e r t h a n c o re b o u n d f o r g r a p h s g r e a t e r t h a n 25 v e r ti c es , t h is s e e m e d t o b e ar e a s o n a b l e l im i t . A s i t t u r n e d o u t, t h e i m p l e m e n t a t i o n i s c o re b o u n d r a t h e r t h a n t i m eb o u n d f o r m o s t g r a p h s . U s i n g s w a p p i n g t e c h n i q u e s , w i t h o n l y o n e r o w o f e a c h m a t r i xi n co r e a t a t im e , s t o r a g e r e q u i r e m e n t s c a n b e r e d u c ed t o O ( N ) H o w e v e r , s e v e r ep e n a l t i e s a r e p a i d i n e x e c u t m n t i m e f o r t h is .Performance o f the Algor t thmI n e v a l u a t i n g p e r f o r m a n c e , i t is I m p o r t a n t to d i s t in g u i s h b e t w e e n t h e p e r f o r m a n c e o ft h e i m p l e m e n t a t i o n a n d t h e p e r f o r m a n c e o f t h e a l g o r i t h m . P e r f o r m a n c e o f t h ei m p l e m e n t a t i o n i s m e a s u r e d b y th e t o t a l t i m e r e q u i r e d f o r t h e p r o g r a m t o p r o c e ss ap a i r o f g r a p h s . T h e p e r f o r m a n c e o f t h e b a c k t r a c k i n g a l g o r i t h m w i ll b e m e a s u r e d b yt h e n u m b e r o f b r a n c h e s r e q u i r e d t o p r o c es s a p a i r o f g r a p h s .T o t e s t p e r f o r m a n c e , a ra n d o m g r a p h g e n e r a t i n g p r o g r a m w a s us e d . A ll r a n d o m l yg e n e r a t e d n o n i s o m o r p h i c p a i r s o f g r a p h s w e r e r e je c t e d a t t h e i n i t ia l p a r t i t i o n . As e co n d p r o g r a m w a s i m p l e m e n t e d t o p e r m u t e t h e a d j a c e n cy m a t r i x o f a g r a p h t oc r e a t e a s e co n d g r a p h i s o m o r p h i c t o th e f ir s t. N o s u c h p a i r o f l s o m o r p h m g r a p h sr e q u i r e d A l g o r i t h m 2 t o b a c k t r a c k . P e r f o r m a n c e o f A l g o r i t h m 2 i n t h e s e c a s e s w a s Nt i m e s t h e w o r k r e q u i r e d f o r e a c h b r a n c h , w h i c h i s s i m p l y th e c o m p o s i n g o f N e l e m e n tv e c t o r s. T h i s s u g g e s t s a n O ( N 2) p e r f o r m a n c e i n t h e s e c a s e s T h e p e r f o r m a n c e o f t h ep r o g r a m i s s h o w n i n T a b l e X I . A d i f f e r e n c e a n a l y s i s o n t h i s d a t a i n d i c a t e s O ( N 2)p e r f o r m a n c e f o r r a n d o m g r a p h s . H o w e v e r , r a n d o m g r a p h s d o n o t g e n e r a l l y c o n ta i ni n t e r e s t in g p r o p e r t m s . R a n d o m l y g e n e r a t e d r e g u l a r g r a p h s w e r e t e s te d a n d e i t h e rw e r e r e j e ct e d a s n o n is o m o r p h i c a t t h e i n i ti a l p a r t i t i o n o r r e q u i r e d n o b a c k t r a c k i n g t op r o v e t h e g r a p h s w e r e i s om o r p h ic .

    T A B L E X I R U N T I M E S I N M I L LI M I N UT E S F OR R A N D O M G R A P H SN D i s t a n c e m a t r i x A l g o r i t h m3 0 2 9 4 14 0 8 8 5 45 0 1 8 7 6 76 0 3 3 6 8 07 0 5 3 3 1 1 48 0 7 9 8 1 4 89 0 1 1 2 2 1 9 1

    1 0 0 1 5 5 1 2 2 4

  • 7/23/2019 A fast backtracking algorithm to test directed graphs for isomorphism using distance matrices de Douglas C. Schm

    11/13

    A F a s t B a c k t r a c k i n g A l g o r i t h m 4 4 3S i n c e t h e r a n d o m l y g e n e r a t e d g r a p h s d i d n o t r e q m r e b a c k t r a c k i n g , t e s t s w e r e

    m a d e o n s i m p l e p o ly g o n s. P e r f o r m a n c e f o r t h e s e g r a p h s d i d n o t d i ff e r f r o m t h a t o fr a n d o m l y g e n e r a t e d g r a p h s . T h i s is p r e d i c t a b l e s in c e a l l s i m p l e p o l y g o n s w i t h t h es a m e n u m b e r o f v e r t i c e s a r e i s o m o r p h i c , a n d e v e r y c h o ic e a t a n y l e v e l i s c o n s i s t e n t.S t a r r e d p o l y g o n s o f v a r y i n g s y m b o l s ( T u r n e r [2 1]) w e r e t e s te d w i t h n o b a c k t r a c k i n g .S i m i l a r l y , c o m p l e t e k - p a r t i t e g r a p h s w i t h k < 5 d i d n o t r e q u i r e b a c k t r a c k i n g . G r a p h sw i t h s p e c ia l p r o p e r ti e s, s u c h a s P e t e r s e n ' s G r a p h , w h e n c o m p a r e d w i t h a r a n d o mp e r m u t a t i o n o f t h e i r v e r t ic e s , d id n o t r e q m r e b a c k t r a c k i n g .

    H o f f m a n [2 2] s u g g e s t e d a p p l y i n g t h e a l g o r i t h m t o a s e t o f s t ro n g l y r e g u l a r g r a p h s( se e B o s e [ 2 3] ) p r o d u c e d b y P a u l u s [2 4] a n d , i n d e p e n d e n t l y , b y C o r n e i l a n d M a t h o n[2 5]. T h e r e a r e f i f t e e n n o n i s o m o r p h i c g r a p h s o f o r d e r 2 5 w i t h d(v , ) = 12 , V i , an d P l l =5 . S i n c e th e s e g r a p h s r e q u i r e d t h e a l g o r i t h m t o b a c k t r a c k , t h e t h r e e s t r a t e g i e s fo rm a k i n g c h o ic e s a t s t e p 6 o f A l g o r i t h m 2 w e r e s t u d ie d . T a b l e X I I s h o w s t h e p r e d i c t e dn u m b e r o f b r a n c h e s a n d t h e a c t u a l n u m b e r t a k e n u s i n g e a c h o f t h e t h r e e s t r a te g i e so n v a r i o u s c o m b i n a t i o n s o f g r a p h s .

    F r o m t h is s a m p l i n g , i t a p p e a r s t h a t s t r a t e g y 1 p r o v id e s a s o m e w h a t m o r e p e s s im i s -t ic d y n a m i c b o u n d t h a n d o s t r a te g i e s 2 a n d 3 . H o w e v e r , t h e p e r f o r m a n c e s e e m s to b ec o m p a r a b l e . S i n c e s t r a t e g y 1 i s t h e s i m p l e s t a n d m o s t e f fi c ie n t ly c o m p u t e d , i t i s a na t t r a c t i v e s t r a t e g y . A l t h o u g h s t r a t e g i e s 2 a n d 3 p r o v i d e s li g h t l y m o r e r e a l i s ti ce s t i m a t e s , t h e y a r e l e s s e f fi c ie n t a n d d o n o t n e c e s s a r i l y p e r f o r m b e t t e r .

    T a b l e X I I i l l u s t r a t e s t h a t t h e b o u n d i s b a s e d o n t h e d i f f ic u l ty o f G I. F o r i n s t a n c e , S 1a p p e a r s t o b e l e s s d if fi c u lt t h a n S 2, w h i c h s u g g e s t s t h a t i t m i g h t b e u s e f u l t o g e t ad y n a m i c b o u n d o n b o t h G 1 a n d G 2 a n d r e v e r s e r o le s i f G 2 o f fe r s a l o w e r b o u n d . N o t e ,h o w e v e r , t h a t t h e l o w e r b o u n d d o e s n o t g u a r a n t e e b e t t e r p e r f o rm a n c e . W h i le S 'a p p e a r s t o b e a l e s s d if fi c u lt g r a p h t h a n S 2, t h e a l g o r i t h m p e r f o r m e d m u c h b e t t e r i nm a p p i n g S 2 o n to S 1 h a n m m a p p i n g S ~o n t o S 2. T h e w o r s t c a s e o b s e r v e d w a s m a p p i n gS 1 o n t o S 5. T h e a v e r a g e t i m e f o r t h e s e g r a p h s u s i n g s t r a t e g y 1 w a s l es s t h a n 1 m i n . As i m i l a r c o l le c ti on o f st r o n g l y r e g u l a r g r a p h s o f o r d e r 36 w a s d e v e lo p e d b y B u s s e m a k e ra n d S e i d e l [ 26 ], a n d o n e o f o r d e r 2 6 b y C o r n e i l a n d M a t h o n [2 5].C o n c l u s i o nT h e b a c k t r a c k i n g a l g o r i t h m d e s cr ib e d i n t h i s p a p e r a p p e a r s t o b e v e r y p o w e r f u l fo r al a r g e c l as s o f g r a p h s . A n u p p e r b o u n d i s p r e s e n t e d i f t h e p a i r o f g r a p h s m a y c a u s eb a c k t r a c k i n g . I t is c a p a b l e o f h a n d l i n g p r o b l e m s o f r e a l i s ti c s iz e . F o r g r a p h s e n c o u n -t e r e d i n p r a c ti c e , t h e a l g o r i t h m a p p e a r s e x t r e m e l y e ff ic i en t .TABLE XI I DYNAMIC BOUND AND ACTUAL NUMBER OF BRANCHES FOR STRONGLY REGULAR GRAPHS

    OF ORDER 25G ' - G "

    St ra t egy 1 S t ra t egy 2 S t ra t egy 3Bound Run Bound Run Bound Run

    S ' - S 2 37825 4129 39825 5773 25825 5023S ' - S ~ 37825 4129 19825 5893 25825 5083S ' - S ~ 37825 9385 19825 8017 25825 7081S ' - S s 37825 4063 19825 5585 25825 4861S ' - S ~ 4 37825 4059 19825 5565 25825 4849S ~ S ~ 97825 1825 15325 1825 61825 1825S ~ S ' 97825 1825 15325 1825 97825 1825S ~ S ~ ' 7825 1825 76825 1825 54325 1825S i S 7 97825 1825 19825 4561 13825 3985S i S 4 115825 1825 15325 3847 61825 1825S I S ~ 97825 1825 15325 4781 97825 1825S s - S ~ 97825 2003 15325 5153 97825 1959S I S ~ 7825 1825 54325 1825 39325 1825S ~ S ' ~ 97825 2329 15325 5221 97825 2239S ' ~ S ' 97825 1825 15325 1825 79825 1825S ' ~ S ' 97825 1825 15325 1825 61825 1825

  • 7/23/2019 A fast backtracking algorithm to test directed graphs for isomorphism using distance matrices de Douglas C. Schm

    12/13

    4 4 4 D . C . S C H M I D T A N D L . E . D R U F F E LA p p e n d i x A . A l g o r t t h m 1 : I n i t i a l P a r t i t i o n i n g A l g o r i t h m1 S e t c ~ = 0 ( 1 - < ~ < - N ) .2 . C o m p u t e t h e r o w a n d c o l u m n c h a r a c te r i s ti c m a t r i c e s ,X R ~ a n d X C t f or G ~, a n d X R 2 a n d X C ~ f or G ~:

    X R ' = { x r l m ] ( 1 - < t - < N ) A ( I - < r e - < N - 1 ) / k x r l~ = ] { d ~ ] ( 1 - < j - < N ) A ( d l , = m ) } ] } ,X R : = { x r ~ l ( 1 - < s -< N ) A ( 1 - < m - < N - 1 ) / k x r ~ = ] {a r~ t] (1 -< t - < N ) A ( d ~ t = m ) } [ } ,X C ' = {xc ~ ] (1 -

  • 7/23/2019 A fast backtracking algorithm to test directed graphs for isomorphism using distance matrices de Douglas C. Schm

    13/13

    A Fast Backtracking Algorithm121314

    445CORNEIL, D G . T h e a n a l y s m o f g r a p h th e o r et ic a l g o m t h m s T e c h R e p # 6 5 , D e p o f C o m p u t S ol ,U o f T o r o n t o , T o r o n t o , O n t a r i o , C a n a d a , 1 9 74HOP CR OFT, J E , AND T AR JAN, R E . I s o m o rp h i s m o f p l a n a r g r a p h s I n Complexity of ComputerComputatmns, R E M i l l e r a n d J W T h a t c h e r , E d s , P l e n u m P r e s s , N e w Y o r k , 1 97 2, p p 1 4 3 -1 5 0HOPCROFT, J E , A N D W O N G , J K L i n e a r t i m e a l g o r i t h m f or i s o m o r p h i s m o f p l a n a r g r a p h s P r oco f t h e 6 t h A n n u a l A C M S y m p o n th e T h e o r y o f C o m p u t i n g , S e a t t l e , W a s h , A p m 1 3 0 , 19 74, p p. 1 7 2 -18 415 W E IN BE RG , L A s i m p l e a n d e f f i c m n t a l g o r i t h m f or d e t e r m i n i n g m o m o r p h l s m o f p l a n a r t r i p lyc o n n e c te d g r a p h s IEEE Trans on C~rcu~t Theory CT-13 (1966), 142-148

    1 6 B E HZ AD,M , AND CHARTRAND, G Introductmn to the Theory o f Graphs A l l y n a n d B a c o n , B o s t on ,1971

    1 7 H A K IM I , S L , A ND Y A U , S S D i s t a n c e m a t r i x o f a g r a p h a n d i t s r e h a b l h t y Quart o f Appl MathXXll, 4 (1965), 305-3171 8 D R EY FU S , S E A n a p p r a i s a l of s o m e s h o r t e s t d i s t a n c e a l g o r i t h m s Oper Res 17 (1969), 395-4121 9. F L OY D , R W A l g o r i t h m 9 7, S h o r t e s t p a t h Comm ACM 5 , 6 ( June 1962) , 3452 0 U L A M , S M A Collectmn of Mathemat~calProblems W i l e y , N e w Y o r k , 1 9 6 0 .21 T UR N ER , J P o m t - s y m m e t m c g r a p h s w i t h a p r i m e n u m b e r o f p o i n t s J Comb. Theor 3 (1967), 136-

    14 522 H O F F M A N , A J P r i v a t e c o m m u n i c a t i o n2 3 B O S E ,R C S t r o n g l y r e g u l a r g r a p h s , p a r t m l g e o m e t r i e s a n d p a r t i a l l y b a l a n c e d d e s i g n s Pacific JMath. 13 (1963), 389-420.2 4 P A UL U S, A . J L . C o n f e r e P c e m a t r i c e s a n d g r a p h s o f o r d e r 2 6. T e c h R e p 7 3 - W S K - 0 6 , T e c h n o l o g i c a l

    U E i n d h o v e n , N e t h e r m n d s , 19 732 5 C O R N E IL , D G P r i v a t e c o m m u m c a t m n26 BUSSEMAKER, F .C , A N D S E I D E L , J J S y m m e t r i c H a d a m a r d m a t r i c e s o f o r d e r 3 6 T e c h . R e p . 7 0-

    W S K - 0 2 , T e c h n o l o g i c a l U E i n d h o v e n , N e t h e r l a n d s , 1 970R E C E I V E D F E B R U A R Y 197 4, R E V I S E D D E C E M B E R 1 9 75

    Journal of the Association or Com putingMachinery,Vol 23, No 3, July 1976