An Algorithm for Road Coloring
A coloring of edges of a finite directed graph turns the graph into finite-state automaton. The synchronizing word of a deterministic automaton is a word in the alphabet of colors (considered as letters) of its edges that maps the automaton to a sing…
Authors: A.N. Trahtman
An Algorithm for Road Coloring A.N. T rahtman ⋆ Bar-Ilan Univ ersit y , Dep. of Math., 52900, Ramat Gan, Israel Abstract. A coloring of edges of a finite directed graph turns the graph into a finite-state automaton. The synchronizi ng w ord of a deterministic automaton is a word in the alphab et of colors (considered as letters) of its edges that maps the aut omato n to a single state. A coloring of edges of a directed graph of uniform outdegree (constan t outdegree of any vertex) is synchronizing if th e coloring turns the graph into a deterministic finite automaton p ossessing a synchronizing word. The road coloring problem is the problem of synchronizing coloring of a d irected finite strongly connected graph of uniform outdegree if t he greatest common divisor of the lengths of all its cycles is one. The prob- lem p osed in 1970 has evoked noticeable interes t among the sp ecialists in the theory of graphs, automata, cod es, sym bolic dy namics as well as among the wide mathematical communit y . A p olynomial time algorithm of O ( n 3 ) complexity in the w orst case and quadratic in the ma jorit y of studied cases for the road coloring of the considered graph is presented b elow . The wo rk is based on the recent p ositi ve solution of th e road coloring problem. The algorithm w as imple- mented in t he freew are p ac k age TEST AS . Keywor ds: algorithm, road coloring, graph, deterministic finite automaton, syn- chronization In t roduct ion The road coloring pr oblem w as stated almost 40 y ea rs ago [2], [1] for a str o ngly connected directed finite deterministic g raph o f uniform outdegree where the greatest common divisor (gcd) of the lengths of all its cycles is one. The edges of the gra ph b eing unlab elled, the ta sk is to find a lab elling of the edges that turns the graph into a deterministic finite automaton poss essing a synchronizing word. The outdegr ee o f the vertex can b e considered a ls o a s the size o f a n a lphabet where the letters denote co lors. The condition on gcd is necessa ry [1], [9]. It can be repla ced by the equiv alent prop ert y tha t there do es not exist a partition of the set o f vertices o n subsets V 1 , V 2 , ..., V k = V 1 ( k > 2) such that every edge which b egins in V i has its end in V i +1 [9], [19]. T ogether wit h the ˇ Cerny conjecture [7], [8], [13], [14], [1 8], [2 2] the ro ad coloring problem used to belo ng to the most fascina ting pr oblems in the theor y ⋆ Email: trakht@macs.biu.ac.il of finite automata. The p opular In terne t Encyclop edia ”Wikip edia” mentions it on the list of the mo st interesting unsolved problems in mathematics. F or some results in this area , see [5], [6 ], [10], [1 1], [1 2], [16], [17], [19], [20]. A detailed history of in vestigations can b e found in [6]. The final p ositive so lutio n of the proble m is stated in [27]. An algorithm for r oad c o loring or ien ted on DNA computing [15] is ba s ed on the massive parallel computing of seq uences of length O ( n 3 ). The implementa- tion of the a lgorithm as well as the implement ation of effective DNA computing is still an op en problem. Another new alg orithm for road coloring (ArXiv [4]) as well as our algo- rithm b elo w is based on the pro of of [27]. This pro of is constructive and leads to a n algo rithm that finds a synchronized lab elling with cubic worst-case time complexity . Both of the ab o ve ment ioned algorithms use c oncepts and ideas of the cons idered proo f together with the conc e pts from [9], [17], but use differ e nt metho ds to reduce the time co mplexit y . A skillful study of the graph was added in [4]. Their algorithm w as declared as quadratic, but some uncertainties in the pro ofs m us t be r e moved b efore publication and implementation. Our alg orithm for the road coloring (ArXiv [24]) reduces the time complexity with the help o f the study of tw o cy c le s with c ommon vertex (Lemma 10). It gives us the p o ssibilit y to reduce quite often the time complexity . The theorems and lemmas from [27] and [26] are pr esen ted b elo w without pro of. The pro ofs ar e given only for new (or mo dified) r esults. The time com- plexity of the algo rithm for a graph with n v ertices and d o utgoing edges of a n y vertex is O ( n 3 d ) in the worst case and quadratic in the ma jority of the studied cases. The space complexit y is quadr atic. At pr esen t, only this algo r ithm for road coloring is implemented. The description of the a lgorithm is presented b elow tog ether with some pseudo codes o f the implemented subr outines. The algo rithm is implemen ted in the freew are pack age TE ST AS (http://www.cs.biu.ac.il/ ∼ tra k h t/sy n.h tml) [28]. The easy access to the pack age ensures the p ossibilit y to everybo dy to verify the considered algo rithm. The role of the road coloring and the algor ithm is substantial also in educa- tion. ” The Road Colo ring Conjectur e makes a nice supplement to any discrete mathematics course” [21]. The rea liz ation of the alg orithm is demonstrated on the basis of a linear visualization prog r am [ ? ] and can analyze any kind of input graph. Preliminaries As usual, we regard a directed graph with letter s assigned to its edges as a finite automaton, whose input alpha b et Σ consists of these letters . The graph is ca lled a tr ansition gr aph of the automaton. The letters from Σ can b e consider ed as colors and the assig ning of co lors to e dges will be called c oloring . 2 A finite directed strongly connected g r aph with constant outdegree o f all its vertices where the gcd of leng ths of all its cycles is one will b e called an AGW gr aph (as introduced by Adler, Go o dwyn and W eiss). W e denote by | P | the size of the subset P of states of an automaton (of vertices of a g raph). If there exists a pa th in an automaton from the state p to the s ta te q and the edges of the path are consecutively labe lled b y σ 1 , ..., σ k , then for s = σ 1 ...σ k ∈ Σ + we shall write q = p s . Let P s b e the set of states p s for p ∈ P , s ∈ Σ + . F or the transition g r aph Γ of an automaton, let Γ s denote the map o f the se t of states of the automaton. A word s ∈ Σ + is called a synchr onizing word of the automaton with tran- sition gra ph Γ if | Γ s | = 1. A coloring of a directed finite graph is synchr onizing if the color ing turns the graph in to a deterministic finite automaton p ossessing a synchronizing w o r d. Bold letters will denote the vertices of a g raph and the states of an automa ton. A pair of distinct sta tes p , q of a n automa ton (of vertices of the transition graph) will b e ca lled s yn chr onizing if p s = q s for s ome s ∈ Σ + . In the oppo site case, if p s 6 = q s for any s , we call the pair a de ad lo ck . A synchronizing pair of states p , q of an automaton is ca lled stable if for any word u the pair p u, q u is also synchronizing [9], [17]. W e call the set of all outgoing edges of a v e r tex a bunch if all these edges are incoming edges of only o ne vertex. The subset of states (of vertices o f the transition gr aph Γ ) of max imal size such that every pair o f states from the set is a deadlo ck will b e c a lled an F -clique . 1 Some prop erties of F -cliques and stable pairs The road coloring problem was for m ulated for AGW gr aphs [1] a nd only such graphs are consider ed in Sections 1 and 2. Let us r ecall that a binary relatio n ρ on the set of the sta tes of an automaton is called c ongruen c e if ρ is equiv alence and for an y word u from p ρ q follo ws p u ρ q u . Let us for m ulate an imp ortant re sult fro m [9], [17] in the following for m: Theorem 1 [17] L et us c onsider a c oloring of an AGW gr aph Γ . L et ρ b e the tr ans itive and r eflexive closur e of t he stability r elation on the obtaine d au- tomaton. Then ρ is a c ongruen c e r elation, Γ /ρ is also an AGW gr aph and a synchr onizing c oloring of Γ /ρ implies a synchr onizing r e c oloring of Γ . Lemma 1 [27], [9] L et F b e an F -clique of some c oloring of an AGW gr aph Γ . F or any wor d s the set F s is also an F - cliq ue and any state p b elongs t o some F -clique. Lemma 2 L et A and B (with | A | > 1 ) b e distinct F -cliques of some c oloring of an AGW gr aph Γ such that | A | − | A ∩ B | = 1 . Then for al l p ∈ A \ A ∩ B and q ∈ B \ A ∩ B , the p air ( p , q ) is stable. 3 Pro of. By the definition of a n F -clique, | A | = | B | and | B | − | A ∩ B | = 1 , to o. If the pair of states p ∈ A \ B a nd q ∈ B \ A is not stable, then for some word s the pair ( p s, q s ) is a dea dlock. An y pair of states from the F -clique A and from the F -clique B , as well as fro m the F -cliques As a nd B s , is a deadlo c k. So any pair of states from the set ( A ∪ B ) s is a deadlo ck. One ha s | ( A ∪ B ) s | = | As | + 1 = | A | + 1 > | A | . So the size o f the s et ( A ∪ B ) s o f deadlo cks is grea ter than the maxima l s iz e o f F -clique. Contradiction. Lemma 3 If some vertex of an AGW gr aph Γ has two inc oming bunches, then the origins of the bunches form a st abl e p air by any c oloring. Pro of. If a v ertex p ha s tw o incoming bunc hes fro m q and r , then the couple q , r is stable for any coloring b ecause q σ = r σ = p for a n y σ ∈ Σ . 2 The spanning subgraph of an AGW graph Definition 4 L et us c al l a sub gr aph S of an AGW gr aph Γ , a s p anning sub- gr aph of Γ , if S c ontains al l vertic es of Γ and if e ach vertex has exactly one outgoing e dge. (In usu al gr aph-the or etic terms it is a 1-outr e gular sp anning sub- gr aph). A max imal su btr e e of a sp anning s ub gr aph S with its r o ot on a cycle fr om S and having no c ommon e dges with the cycles of S is c al le d a t r e e of S . The length of a p ath fr om a vertex p thr ough t he e dges of the tr e e of the sp anning set S t o the ro ot of the t r e e is c al le d a l evel of p in S . A t r e e with a vertex of maximal level is c al le d a m aximal tr e e. Remark 5 Any sp anning sub gr aph S c onsists of disjoint cycles and tr e es with r o ots on the cycle s. Any tr e e and cycle of S is define d id entic al ly. The level of the vertic es b elonging to some cycle is zer o. The vertic es of the t re es exc ept the r o ots have p ositive level. The vertic es of maximal p ositive level have no inc oming e dge in S . The e dges lab el le d by a given c olor define d by any c oloring form a sp anning sub gr aph. Conversely, for e ach sp anning su b gr aph, ther e exists a c oloring and a c olor su ch t ha t the set of e dges lab el le d with this c olor c orr esp onds t o this sp anning sub gr aph. ❄ ❝ ✠ ❝ ✲ ❝ ❅ ❅ ❘ ❝ ❅ ❅ ❘ ❝ ✒ ❝ ❅ ❅ ■ ❝ ✠ ❝ max level 3 level 0 Cycle level 2 level 1 level 0 T ree P P q ❝ Lemma 6 [27] [26] L et N b e a set of vertic es of maximal level in some tr e e of the sp anning su b gr aph S of an AGW gr aph Γ . Then, via a c oloring of Γ such that al l e dges of S have the same c olor α , for any F -clique F holds | F ∩ N | ≤ 1 . 4 Lemma 7 [27] L et Γ b e an AGW gr aph with a sp anning su b gr aph R which is a union of cycles (without t r e es). Then t he non- t rivia l gr aph Γ has another sp anning sub gr aph with exactly one maximal tr e e. Lemma 8 Le t R b e a sp anning sub gr aph of an AGW gr aph Γ . L et T b e a maximal t r e e of R with a vertex p of maximal p ositive level L and with a r o ot r on a cycle H of R . L et u s change the sp anning sub gr aph by me ans of the fol lowing flips: 1)an e dge ¯ a = a → p r eplac es the e dge ¯ d = a → d of R for appr opriate vertic es a and d 6 = p , 2) r eplacing e dge ¯ b = b → r of T by an e dge b → x for appr opriate vert ic es b and x 6 = r , 3) r eplacing e dge ¯ c = c → r of H by an e dge c → x for appr opriate vertic es c and x 6 = r . Supp ose that one or two c onse cutive flips do n ot incr e ase the numb er of e dges in cycles (Condition ∗ ) and no vertex of Γ has t wo inc oming bunches (Condition ∗∗ ). Then ther e exists a sp anning sub gr aph with a single maximal non-trivial tr e e. Pro of. In view o f Lemma 7, supp ose that R has no n-trivial tree s. F urther con- sideration is necessa ry o nly if the maximal tree T is not single. ❝ ❝ ❝ ❄ ❝ ❝ ❝ ✛ ✛ ❆ ❆ ❑ ✁ ✁ ☛ ❝ p r a d c b ✲ ✲ · · · · · · · · · · · · · · · · · · ✛ ¯ a ¯ w ¯ c ¯ b H T ✒ Our aim is to increase the maximal level L using the three afor esaid flips. If one of the flips do es not succeed, let us go to the next, assuming the situation in which the previous fails, and excluding the successfully studied cases. W e c heck at most tw o flips together . Le t us b egin from the e dg e ¯ a ) Suppo se firs t a 6∈ H . If a belo ngs to the path in T from p to r then a new cy cle with pa rt of the path and the e dg e a → p is added to R extending the nu mber of vertices in its cy cles in spite of C o ndition ∗ of lemma. In the opp osite case the level of a is L + 1 in a single max imal tr ee. So let us a ssume a ∈ H . In this ca se the v ertices p , r and a b elong to a cyc le H 1 of a new spanning subgraph R 1 obtained by removing ¯ d and adding ¯ a . So we hav e the cyc le H 1 ∈ R 1 instead of H ∈ R . If the leng th of the path fr om r to a in H is r 1 , then H 1 has length L + r 1 + 1. A path fro m r to d of the cycle H r emains in R 1 . Supp ose that its le ng th is r 2 . So the length of the cycle H is r 1 + r 2 + 1. The length o f the cycle H 1 is no t gre a ter tha n the le ngth of H in view of Condition ∗ . So r 1 + r 2 + 1 ≥ L + r 1 + 1, whence r 2 ≥ L . If r 2 > L , then the length r 2 of the pa th from d to r in a tree of R 1 (as well as the level of d ) is grea ter than L . The tr e e co n taining d is the desired single maxima l tre e . So w e can assume for further consideration that L = r 2 and a ∈ H . An analogo us statement can be stated for any maximal tree. 5 the edge ¯ b ) Supp ose tha t the set of o utgoing edge s of the vertex b is not a bunc h. So one can r eplace in R the edge ¯ b by an edge ¯ v = b → v ( v 6 = r ). The vertex v could not b elong to T because in this case a new cycle is added to R in spite of Condition ∗ . If the vertex v b e longs to another tree of R but not to the cyc le H , then T is a part o f a new tree T 1 with a new ro ot of a new spanning subg raph R 1 and the pa th from p to the new ro ot has a length greater than L . Therefore the tree T 1 is the unique ma ximal tree in R 1 . If v b elongs to some cycle H 2 6 = H in R , then to gether with replacing ¯ b by ¯ v , we also replace the edg e ¯ d by ¯ a . So we extend the path from p to the new ro ot v of H 2 at lea st by the edge ¯ a = a → p and there is a unique maximal tree of level L 1 > L whic h contains the vertex d . Now it remains o nly the case when v b elongs to the cycle H . The vertex p also has level L in a new tree T 1 with ro ot v . The only difference betw een T and T 1 (just a s b et ween R and R 1 ) is the r oot a nd the incoming edge of this r oot. The new spanning subgra ph R 1 has the same num b er of vertices in their cycles just as do es R . Let r ′ 2 be the length o f the path from d to v ∈ H . F or the spanning s ubgraph R 1 , one can obtain L = r ′ 2 just a s it was done earlier in the case o f the edge ¯ a ) for R . F ro m v 6 = r follows r ′ 2 6 = r 2 , though L = r ′ 2 and L = r 2 . So for further consider ation supp ose tha t the set of o utgoing edges o f the vertex b is a bunch to r . The edge ¯ c ) The set of outgoing edges of the vertex c is not a bunc h in virtue of Condition ∗∗ ( r has ano ther bunch from b .) Let us repla ce in R the edge ¯ c by an edg e ¯ u = c → u such that u 6 = r . The vertex u co uld not belong to the tree T b ecause one has in this case a cycle with all v ertices from H and some vertices of T whence its length is gre a ter than | H | and so the num b er o f vertices in the cycles of a new spa nning subg r aph g ro ws in spite of Condition ∗ . If the v ertex u do es not belong to T , then the tree T is a pa rt of a new tree with a new roo t. The path from p to the new ro ot is extended a t le a st by a part of H starting at the former roo t r . The new lev el of p therefor e is maximal and greater than the level of an y vertex in a nother tree. Thu s in any case we obtain a spanning subgraph with a single no n- trivial maximal tree. Lemma 9 F or some c oloring of any AGW gr aph Γ , ther e exists a stable p air of states. Pro of. W e exclude the case of two incoming bunc hes of a vertex in virtue of Lemma 3. Ther e exists a co loring such that for some color α , the corresp onding spanning subgra ph R ha s maxim um edges in cycles. By Lemma 8, we must consider now a spanning subgr aph R with a single maximal tree T . Let the ro ot r of T b elong to the c y cle C . By Lemma 1, in a strongly connected transitio n gra ph for every w ord s and F -clique F of size | F | > 1 , the set F s a ls o is an F -clique of the sa me size and for any s tate p there exists a n F -clique F such that p ∈ F . 6 In particular, some F -clique F has a non-empty intersection with the set N of v ertices of maximal lev el L . The set N b e longs to o ne tree, whence by Le mma 6 | N ∩ F | = 1. Let p ∈ N ∩ F . The word α L − 1 maps F on an F -clique F 1 of size | F | . One has | F 1 \ C | = 1 bec ause any sequence of length L − 1 of edges of color α in any tr e e of R leads to a cyc le. F or the set N of vertices of maxima l level, N α L − 1 6⊆ C holds. So | N α L − 1 ∩ F 1 | = | F 1 \ C | = 1, p α L − 1 ∈ F 1 \ C and | C ∩ F 1 | = | F 1 | − 1. Let the integer m b e a commo n multiple of the lengths of all considered cycles colore d by α . So for any r in C as well as in F 1 ∩ C holds r α m = r . Let F 2 be F 1 α m . W e hav e F 2 ⊆ C and C ∩ F 1 = F 1 ∩ F 2 . Thu s the tw o F -cliques F 1 and F 2 of size | F 1 | > 1 have | F 1 | − 1 common vertices. So | F 1 \ ( F 1 ∩ F 2 ) | = 1 , whence b y Lemma 2, the pa ir of states p α L − 1 from F 1 \ ( F 1 ∩ F 2 ) and q from F 2 \ ( F 1 ∩ F 2 ) is stable. It is o b vio us that q = p α L + m − 1 . Theorem 2 [27] Every AGW gr aph has a synchr onizing c oloring. Theorem 3 [25] L et every vertex of a str ongly c onn e cte d dir e cte d gr aph Γ have the same numb er of out goi ng e dges. Then Γ has synchr onizing c oloring if and only if the gr e atest c ommon divisor of lengths of al l its cycles is one. The goa l of the following lemma is to reduce the co mplex it y of the algo rithm. Lemma 10 L et Γ b e an AGW gr aph having two cycles C u and C v . Supp ose that either C u ∩ C v = { p 1 } or C u ∩ C v = { p k ,..., p 1 } , wher e al l inc oming e dges of p i develop a bunch fr om p i +1 ( i < k ) . L et u ∈ C u and v ∈ C v b e t he distinct e dges of the cycles C u and C v le aving p 1 . L et R u b e a sp anning sub gr aph with al l e dges fr om C u and C v exc ept u . The sp anning sub gr aph R v is obtaine d fr om R u by remo ving v and adding u . Then at le ast one of two sp anning sub gr aphs R u , R v has a unique m ax imal tr e e whose r o ot is p 1 . Pro of. Let us add to R u the e dg e u and consider a set of trees with ro ots o n the cycles C u and C v . The trees have no common vertices and hav e no vertices except a ro ot on the cycles C u and C v . The same s e t of trees ca n b e obtained by adding the edg e v to R v . Let us define the levels o f v e r tices of a tree as in the case of a spanning subgraph and cons ider the set of maximal trees (the trees with a max imal vertex level). If all maxima l tre es hav e a co mmon r oot, then R u (and also R v ) is a spanning subgraph with a unique ma ximal tree. If maximal trees hav e different ro ots, then let as ta ke a maximal tree T with ro ot r s uc h that the leng th o f the pa th P from r to p 1 on the cycle C u (or C v ) is maximal. If P b elongs to C u , then the tree T is extended by the path P , whence R u has a unique maximal tree. In the opp osite cas e, R v has a unique maximal tree. 7 3 The algorithm for sync hronizing coloring Let us star t with transition g raph of an ar bitrary deterministic c o mplete finite automaton. 3.1 Preliminary steps The study is bas ed on Theo rem 3. A sy nc hro nizing g raph has a s ink strongly connected c o mponent ( S C C ). Our aim is to r educe the study to sink S C C (if it exists) in or der to remov e non- sync hr onizing graphs without sink S C C and then chec k the co ndition o n g cd . The function Chec kSinkSCC verifies the existence of sink S C C . W e use the linear algo rithm for finding s trongly connected comp onen ts S C C [3], [23]. Then we remove a ll S C C as ha ving outg oing edges to other S C C . If only one S C C rema ins then let us contin ue. In the opp osite case a synchronizing coloring do es not exist. W e study a stro ngly connected graph (with one S C C ). The function Find- GCDofCycles finds the great common divisor ( g cd ) of lengths of cycles of the automaton and verifies the necessary conditions of synchronizability ( g cd = 1). Let p be a n a r bitrary fixed vertex. Suppose d ( p ) = 1. Then w e use a depth- first search from p . F or an edg e r → q wher e d ( r ) is a lready defined and d ( q ) is not, supp ose d ( q ) = d ( r ) + 1. If d ( q ) is defined, let us a dd the non-zero differenc e abs ( d ( q ) − 1 − d ( r )) to the set D . The integer from D is a difference of lengths of t wo paths from p to q . In a strong ly connected gr aph, the g cd of a ll element s of D is also a g cd of lengths of all cycles [2], [25]. If g cd = 1 for a ll in teg ers from D , then the graph has sync hronizing color ing. In o pposite cas e the answer is negative. So w e reduce the inv estigation to an AGW gr aph. Let us pro ceed with a n arbitrary coloring of such a gr aph Γ with n vertices and constant outdegree d . The considered d co lors define d spanning subgraphs of the gr a ph. W e keep the pre images of vertices a nd colored edges by any transfor mation and homomorphism. If there exists a lo op in Γ aro und a state r , then let us color the edges of a tree whos e ro ot is r with the same colo r a s the color of the lo op. The other edges may be colored ar bitr arily . The coloring is sy nc hro nizing [1 ]. The function FindLo opColoring finds the co loring. 3.2 Help subrouti nes In the case of tw o incoming bunc hes of some vertex, the origins of these bunches develop a stable pair by a n y coloring (Lemma 3). W e merge both vertices in the homo mo rphic image of the graph (Theor e m 1) and o bta in according to the theorem a new AGW graph of a smaller siz e . The pseudo code of corr esponding pro cedure returns tw o such origins of bunc hes (a stable pair ). 8 The linear s earch of t wo incoming bunches and o f the lo op ca n b e made at any sta ge of the algor ithm. The function Homonor phicI mage of linear complexit y reduces the size of the considered auto ma ton and its tra nsition gr aph. The congr uence clas ses of the homomorphism are defined by a stable pair (Theore m 1). A new AGW gra ph of a smaller size will be the output. The main part of the alg orithm nee ds the parameter s o f the s panning s ub- graph: levels of all vertices, the n umber o f v e r tices (edges) in cycles, trees, next and former v er tices. W e k eep the tree and the cycle of any vertex, the ro ot of the tree. W e form the set of vertices of maximal level a nd the set of maximal trees. The function FindP arameters (spanning subgraph S , parameters) is linea r and used by a n y rec o loring step. The subro utine MaximalT reeT oStableP a ir of linea r co mplexit y finds a stable pair in a given spanning subgra ph with unique max imal tr ee. The stable pair consists o f tw o b eginnings of inco ming edges of the ro ot of the unique maximal tree (Lemma 9). 3.3 A p ossibil i t y to reduce the complexity Our algor ithm as well as the alg orithm of [4 ] is based on [2 7]. Only this section essentially differs in both thes e pap ers. If there ar e tw o c y cles with one c ommon vertex (path) then we use Lemma 10 and find a spanning subg raph with sing le maximal tr e e . Then after color ing edges of spanning subgr aph by a color α , we find a stable pair (beg innings of t wo inco ming edges to the ro ot of the tree). The function Tw oCyclesWithIn tersection as a rule r eturns a pa ir o f cycles with common vertex (path). The v a st ma jority of digraphs contains such a pa ir of cycles. The g oal of the s ubroutine is to o mit the cubic complexit y o f the algorithm. The sea rc h of a stable pa ir is linear in this cas e and th us the whole algorithm is quadra tic. Tw oCyclesWithIn tersection (graph G ) 1 levels o f all vertices first are nega tiv e 2 level( r ) = 1 and add r to stack 3 for every vertex q from stack 4 do 5 for every letter β 6 do 7 add q β to stack 8 if level( q β ) ≥ 0 9 level( q β ) = lev e l( q ) + 1 10 keep the cycle C of v e rtices q β , q and break from both cycles 11 remo ve q from stac k 12 for every vertex r 13 do 14 if r 6∈ C level(( r ) = − 1 (for a search o f second cycle) 9 15 for every vertex q from cycle C 16 do 17 r = q α 18 for every letter β 19 do 20 if r 6 = q β break 21 if r 6 = q β break 22 add q to stack 1 (possible int ersection of tw o cy c le s) 23 for every vertex r from stack 1 24 do 25 for every letter β 26 do 27 if level( r β ) < 0 28 lev el( r β ) =level( r ) + 1 29 add r β to stack 1 30 if r β = q (found second cycle) 31 develop tr ees with ro o ts o n b oth cycles, find ma ximal trees 32 color the edge v fro m q on cycle of maximal tre e by co lor 2 33 color the edg e s of tre e s a nd b oth cycles except v by color 1 34 FindP ara meters (spanning subgr aph of co lor 1 ) 35 MaximalT re eT oStableP air (subgraph, p , s ) 36 return p , s (stable pair ) 37 remov e r from stack 1 38 return F alse 3.4 The recoloring of the edges A repainting of the edges of the transitio n graph fo r to o bta in a spanning sub- graph with single maximal tree is a most complicated part of the algorithm. Let us fix the spanning subgraph R of edges of a given color α . W e consider the flips from Lemmas 7 and 8. The flips change R . Acco rding to the Lemmas, a fter a t most 3 d steps either the n umber of edges in the c y cles is g ro wing or there exists a single maximal tree. The subroutine of pseudo co de Flips (spanning subg raph F ) re tur ns e ither a stable pair or enla rges the n umber of edges in cycles of the spanning sub- graph. The subroutine uses linear s ubroutines FindP arameters , Maximal- T reeT oStableP air and also has linear time complexity O ( nd ). W e rep eat the pro cedure with pseudo co de Flips fo r a new gra ph if the nu mber of edge s in cycles after the flips gr ows. In the opp osite ca s e, we find a stable pair and then a homomorphic image o f a sma ller size. F or a graph of given size, the complexity of this step is quadra tic. 3.5 Main pro cedure and compl e xit y The Pro cedure Main uses all above-men tio ne d linear pro cedures a nd retur ns a synchronizing coloring (if exists) of the graph. 10 Main () 1 arbitrar y coloring of G 2 if F alse( Chec kSinkSCC (graph G )) 3 return F a lse 4 if FindLo opColoring (F=SCC of G ) 5 return 6 if F alse( FindGCDofCycles ( S C C F )) 7 return F a lse 8 while | G | > 1 9 if FindLo opColoring (F) 10 c hange the colo r ing of gener ic g raph G 11 return 12 for every letter β 13 do 14 if FindTw oIncomingBunch es (spanning s ubg raph,stable pair) 15 HomonorphicImage (automaton A ,stable pa ir,new A) 16 FindP arameters ( A = new A ) 17 break 18 while Flips (spanning subg r aph F of color β ) = GRO WS 19 F = new F 20 if FindTw oIncomingBunc hes ( F ,stable pair) 21 HomonorphicImage (automaton A ,stable pair,new A) 22 FindP ara meters ( A = new A ) 23 break 24 MaximalT reeT oStableP air (subgraph, stable pair) 25 HomonorphicImage (automaton A ,stable pa ir,new A) 26 FindP arameters ( A = new A ) 27 c hange the colo r ing of G on the ba se of the last homomorphic image Some of ab o ve-mentioned linea r subroutines are included in c ycles on n and d , sometimes t wice on n . So the upper b ound of the time complexity is O ( n 3 d ). Nevertheless, the ov era ll c omplexit y of the algorithm in a ma jority o f cas e s is O ( n 2 d ). The upp er bo und O ( n 3 d ) of the time complexity is reached only if the nu mber of edges in the cycles grows slowly , the size of the automaton decreases also slowly , lo ops do not app ear and the case of tw o ingoing bunc hes emer ges rarely (the worst case). The space complexity is quadratic. References 1. R.L. Adler, L.W. Goo dwyn, B. W eiss. Equiv alence of t op ological Marko v shifts, Isr ael J. of Math. , 27, 49-63, 1977. 2. R.L. Adler, B. W eiss. S imila rity of automorphisms of th e torus, Memoirs of the Amer . Math. So c. , 98, Pro vidence, RI, 1970. 3. A. Aho, J. Hop crof t, J. Ulman. The Design and Analisys of Computer Algorithms, Addison-W esley , 1974. 11 4. M.P . B´ eal, D . P errin. A quadratic algorithm for road coloring. arXiv:0803.0726 v2 [cs.DM] . 5. G. Budzban, A. Mukherjea. A semigroup app roac h to the R oad Coloring Problem. Pr ob ability on Alg. Structur es. Contemp or ary Mathematics , 261, 195-207, 2000. 6. A. Carbone. Cycles of relatively prime length and the road coloring p roblem. Isr ael J. of Math. , 123, 303-316, 2001. 7. J. ˇ Cern y. Po znamk a k homogenym eksp erimen tom s ko nechn ymi automatami, Math.-Fyz. ˇ Cas. , 14(1964), 208-215. 8. J. ˇ Cern y , A. Pirick a, B. Rosenauerov a, On d irectable automata, Kyb ernetik a 7(1971), 289-298. 9. K. Culik I I, J. Karhumaki, J. Kari. A note on synchronized automata and Road Coloring Problem. Developmen ts in Language Theory (5th Int. Conf., Vienn a, 2001), J. of F ound. Comput. Sci. 13(2002 ), 459-471. 10. J. F riedman. On th e road coloring problem. Pr o c. of the Amer. Math. So c. , 110, 1133-1135 , 1990. 11. E. Gock a, W. K irc hherr, E. Schmeic hel, A note on the road-coloring conjecture. Ar s Combin. 49, 265-270, 199 8. 12. R . H egde, K. Jain, Min-Max theorem ab out the Road Coloring Conjecture. Eur o- Comb 2005, DMTCS pr o c. , AE, 279 - 284, 2005. 13. B. Imreh, M. Steinb y , Some remarks on directable automata, Acta Cybernetica 1, 12 (1995) 23-35. 14. M. Ito, J. Duske, On cofinal and defin ite automata, Acta Cyb ernetica 6(1983), 181-189. 15. N . Jonosk a, S. A. Karl, A molecular computation of the road coloring problem. DNA Base d Computers II , DI M A CS Series in DMTCS , 44, 87-96, 1998 . 16. N . Jonosk a, S . Suen. Mono cyclic decomp osition of graphs and the road coloring problem. Congr essum numer antium , 110, 20 1-209, 1995. 17. J. Kari. Syn c hronizing fi nite au t omata on Eulerian digraphs. L e ct. Notes in Comp. Sci. , Sp ringer, 2136, 432-438, 2001. 18. A . Mateescu, A. Salomaa, Many-V alued T ruth F unctions, ˇ Cern y’s Conjecture and Road Coloring. Bul l. of Eur op e an Ass. f or TCS , 68, 134 -148,1999. 19. G.L. O’Brien. The road col oring problem. Isr ael J. of Math. , 39, 145-154, 1981 . 20. D . Perri n, M.P . S c h ˇ utzenberger. Synchronizing prefix co d es and automata, an d the road coloring problem. In Symb oli c Dynamics and Appl. , Contemp. Math. , 135, 295-318, 1992. 21. J. V. Rauff, W ay bac k from anywhere: exploring the road coloring conjecture. Math. and Comput. Edu cation. 01, 200 9. 22. I . C. Rystsov, Quasioptimal b ound for the length of reset words for regular au- tomata, Acta Cyb ernetica, 12(1995), 145-152 23. R .E. T arjan, Depth first searc h and linear graph algorithms. SIAM J. Comput. , 1(1972), 146-160. 24. A .N. T rah tman, A sub quadratic algorithm for road coloring. arXiv:0801.2838 v1 [cs.DM] . 25. A .N. T rahtman. Sync hronizing Road Coloring. 5-th IFIP WCC-TCS , Springer, 273(2008 ), 43-53. 26. A .N. T rahtman. The R oad Coloring and Cerny Conjecture. Pr o c. of Pr ague Stringolo gy Confer enc e . 200 8, 1-12. 27. A .N. T rahtman The road coloring problem. Israel Jo urnal of Math., 172(1), 2009, 51-60. 28. A .N. T rahtman, Bauer T., Cohen N. Linear visualization of a Road Colo ring. 9th Tw ente w orkshop on graphs and Co mb. Optim., Colo gne 2010, 13 -16. 12
Original Paper
Loading high-quality paper...
Comments & Academic Discussion
Loading comments...
Leave a Comment