Upwr Plnr Drwins of ris-prlll Dirps wit Mximum Dr Tr (Extn Astrt) M. Aul Hssn m n M. iur Rmn Dprtmnt of Computr in n Eninrin, Bnls Univrsity of Eninrin n Tnoloy (BUET). {sm,siurrmn}@s.ut.. Astrt. An upwr plnr rwin of irp G is plnr rwin of G wr vry is rwn s simpl urv monoton in t vrtil irtion. A irp is upwr plnr if it s n min tt mits n upwr plnr rwin. T prolm of tstin wtr irp is upwr plnr is NP-omplt. In tis ppr w iv linr-tim loritm to tst t upwr plnrity of sris-prlll irp G wit mximum r tr n otin n upwr plnr rwin of G if G mits on. Ky wors: Grp Drwin, Upwr Plnr Drwin, Dirt Ayli Grp, ris-prlll Grp, Aloritm, PQ-tr. 1 Introution In n upwr plnr rwin of irp, vry vrtx is mpp to point in t Eulin pln n vry is rwn s simpl urv monoton in t vrtil irtion witout prouin ny rossin wit otr s, s illustrt in Fi. 1(). Upwr plnr rwins of irps fin importnt pplitions in visuliztion of t irril ntwork struturs wi frquntly ris in softwr ninrin, projt mnmnt n visul lnus [BDMT98]. Unfortuntly, not ll irps v upwr plnr rwin. On n sily unrstn tt if irp ontins yl, tn on of t s on t yl nnot rwn monotonilly in t upwr irtion (s t yl inu y vrtis,, n of irp G in Fi. 1()). A irp is upwr plnr if it s n min wi mits n upwr plnr rwin. Ayliity is nssry onition for irp to upwr plnr. Trouout tis ppr, wrvr w rfr to irp, w mn n yli irp. Howvr, yliity is not suffiint onition for upwr plnrity. For xmpl, t yli irp G in Fi. 1() is not upwr plnr; tr r four possil upwr plnr M. Kyko n M. iur Rmn (Es.): WALCOM 2007, pp. 28 45, 2007.
Upwr Plnr Drwins 29 f f f G G () () () G Fi.1. () An upwr plnr irp G, () irp G wi ontins yl n trfor is not upwr plnr n () n yli irp G wi is not upwr plnr. () () () () Fi.2. T four possil mins of f F 1 of irp G. mins of t unirt yl inu y t vrtis,, n (s Fi. 2), n strtin wit ny of ts four mins, t rminin s nnot in ny wy to otin n upwr plnr rwin of G. T prolm of tstin upwr plnrity of irp is on of t most llnin prolms in t r of rp rwin n s n stui wit xtnsiv ffort. Linr-tim loritms r known for tstin wtr irp mits plnr rwin [HT74,BL76]. Tstin wtr irp mits n upwr rwin n lso solv in linr-tim usin t wll-known topoloil sortin tniqu [CLR01]. Nvrtlss, ominin ts two proprtis mks t prolm NP-r [GT94]. T prolm n stui ot in t fix min sttin n in t vril min sttin. In t fix min sttin, t loritm nnot ltr t ivn min, n if tt prtiulr min is not upwr plnr, t output must ntiv ltou som otr min of t sm rp oul upwr plnr. Fi. 3() sows n upwr plnr min of irp G wos min in Fi. 3() is not upwr plnr. Fi. 3() is notr upwr plnr min of G. Brtolzzi t l. [BDLM94] v ivn n loritm to tst upwr plnrity in tim O(n 2 ) in t fix min sttin. In t vril min sttin, t loritm n iv ntiv output only if tr is no upwr plnr min of t input rp. Gr n Tmssi [GT01] prov tt it is n NP-omplt prolm to trmin wtr irp s n upwr plnr rwin in t vril min sttin. Nvrtlss, t prolm s n stui in t vril min sttin for som rstrit lsss of irps [Pp95,HL96,BDMT98]. Gr n Tmssi
30 M. A. H. m n M. iur Rmn i f j () i j () f j () i f Fi. 3. () An upwr plnr irp G n n upwr plnr min of G, () non-upwr plnr min of G, n () notr upwr plnr min of G. [GT95] prov tt sris-prlll irp wit sinl sour n sinl sink is lwys upwr plnr. Unfortuntly, sris-prlll irp G wit multipl sours n sinks my not upwr plnr, n tstin upwr plnrity for irps wit multipl sours n sinks is mor iffiult. Rntly, Diimo t l. [DGL06] provi n loritm tt tsts upwr plnrity of sris-prlll irps in tim O(n 4 ) in t vril min sttin. In tis ppr, w stuy upwr plnr rwins of sris-prlll irps of 3 wit multipl sours n sinks in t vril min sttin. For su irp G, w iv linr-tim loritm to onstrut n upwr plnr rwin of G if G mits on. T ppro of our loritm is iffrnt from t on prsnt in [DGL06] n t loritm in [DGL06] rquirs tim O(n 4 ) vn for sris-prlll irp wit t mximum r tr. T min i of our loritm is s follows. Our loritm works in two pss, nmly tstin ps n onstrution ps. W in wit omposition tr ll PQ-tr T of G. In t tstin ps, w trvrs T ottom-up n tst t fsiility of otinin n upwr plnr rwin of G. If tis ps fils, w lr tt G is not n upwr plnr irp. If t tstin ps sus, w strt t onstrution ps n usin t informtion otin in t tstin ps, w otin n upwr plnr min of G in top-own trvrsl of T. T rst of t ppr is orniz s follows. tion 2 sris som finitions n prsnts prliminry rsults. In tion 3 w sri our primry finins on upwr plnrity of sris-prlll irps wit 3. tion 4 prsnts our loritm to tst upwr plnrity n fin n upwr plnr rwin of ionnt sris-prlll irp wit 3. Finlly, tion 5 is onlusion. 2 Prliminris In tis stion w iv som finitions n prsnt prliminry rsults. Lt G = (V, E) onnt rp wit vrtx st V n st E. T r of vrtx v, (v) is t numr of s inint to v in G. W not
Upwr Plnr Drwins 31 t mximum of t r of t vrtis of G y (G). T onntivity κ(g) of rp G is t minimum numr of vrtis wos rmovl rsults in isonnt rp or sinl-vrtx rp K 1. W sy tt G is k-onnt if κ(g) k. A plnr rwin of G prtitions t pln into topoloilly onnt rions ll fs. T unoun f is ll t outr f, t rminin fs r ll innr fs. A pt in G is n orr list of istint vrtis v 1, v 2,...,v q V su tt (v i 1, v i ) E for ll i, 2 i q. A pt P is ll u, v-pt if u n v r t first n lst vrtis in P rsptivly. A rp G = (V, E) is ll sris-prlll rp (wit sour s n sink t) if itr G onsists of pir of vrtis onnt y sinl or tr xist two sris-prlll rps G i = (V i, E i ), i = 1, 2, wit sour s i n sink t i su tt V = V 1 V 2, E = E 1 E 2, n itr s = s 1, t 1 = s 2 n t = t 2 or s = s 1 = s 2 n t = t 1 = t 2 [REN05]. A pir {u, v} of vrtis of onnt rp G is split pir if tr xist two surps G 1 = (V 1, E 1 ) n G 2 = (V 2, E 2 ) stisfyin t followin two onitions: 1. V = V 1 V 2, V 1 V 2 = {u, v}; n 2. E = E 1 E 2, E 1 E 2 =, E 1 1, E 2 1. Tus vry pir of jnt vrtis is split pir. A split omponnt of split pir {u, v} is itr n (u, v) or mximl onnt surp H of G su tt {u, v} is not split pir of H. Lt G ionnt sris-prlll rp. Lt (s, t) n of G. T PQ-tr T of G wit rspt to rfrn = (s, t) sris rursiv omposition of G inu y its split pirs [GL99]. Tr T is root orr tr wos nos r of tr typs:, P n Q. E no x of T orrspons to surp of G, ll its prtinnt rp G(x). E no x of T s n ssoit ionnt multirp, ll t sklton of x n not y sklton(x). Tr T is rursivly fin s follows. Trivil Cs: In tis s, G onsists of xtly two prlll s n joinin s n t. T onsists of sinl Q-no x, n t sklton of x is G itslf. T prtinnt rp G(x) onsists of only t. Prlll Cs: In tis s, t split pir {s, t} s tr or mor split omponnts G 0, G 1,, G k, k 2, n G 0 onsists of only rfrn = (s, t). T root of T is P-no x. T sklton(x) onsists of k + 1 prlll s 0, 1,, k joinin s n t, wr 0 = = (s, t) n i, 1 i k, orrspons to G i. T prtinnt rp G(x) = G 1 G 2 G k is union of G 1, G 2,, G k. As n xmpl, t sklton of P-no P 2 in Fi. 4 onsists of tr prlll s joinin vrtis n n Fiur 4() pits t prtinnt rp of P 2. ris Cs: In tis s t split pir {s, t} s xtly two split omponnts, n on of tm onsists of t rfrn. On my ssum tt t otr split omponnt s ut-vrtis 1, 2,, k 1, k 2, tt prtition t omponnt into its loks G 1, G 2,, G k in tis orr from s to t. Tn t root of T is n -no x. T sklton of x is yl 0, 1,, k wr 0 =, 0 = s, k = t, n i joins i 1 n i, 1 i k. T prtinnt rp G(x) of no x is union of G 1, G 2,, G k. For xmpl, t sklton of -no 3 in
32 M. A. H. m n M. iur Rmn m n l k i j () f () i l G () f f f () f (f) j k (i,n) i n i P1 1 m l 2 3 l P1 (n,m) (l,m) i 1 i 2 3 P2 (,l) (j,i) (k,j)(l,k) (,i) x l (,l) l P2 4 5 (i,n)(n,m)(l,m) (j,i) (k,j)(l,k) (,i) x P3 4 5 (,)(,)(,) (,) 6 7 P3 (,)(,)(,) (,) (,)(,) (,)(f,)(f,) 6 7 () (,)(,) (,) (f,)(f,) f () Fi.4. ()A ionnt sris-prlll rp G wit = 3, () PQ-tr T of G wit rspt to rfrn (i, n), n skltons of P- n -nos, () t prtinnt rp G( 3) of -no 3, () t prtinnt rp G(P 2) of P-no P 2, () t prtinnt rp G( 5) of -no 5, (f) t prtinnt rp G(P 3) of P-no P 3, () PQ-tr T of G wit P-no P 1 s t root Fi. 4 is t yl, i, l,, n Fiur 4() pits t prtinnt rp G( 3 ) of 3. In of t ss mntion ov, w ll t t rfrn of no x. Expt for t trivil s, no x of T s ilrn x 1, x 2,, x k in tis orr; x i is t root of t PQ-tr of rp G(x i ) i wit rspt to t rfrn i, 1 i k. W ll i t rfrn of no x i, n ll t npoints of i t pols of no x i. T tr otin so fr s Q-no ssoit wit of G, xpt t rfrn. W omplt t PQ-tr T y in Q-no, rprsntin t rfrn, n mkin it t prnt of x so tt it oms t root of T. An xmpl of t PQ-tr of ionnt sris-prlll rp in Fi. 4() is illustrt in Fi. 4(), wr t rwn y tik lin in sklton is t rfrn of t sklton. T PQ-tr T fin ov is t on us in [REN05] n is spil s of n PQR-tr [DT96,GL99] wr tr is no R-no n t root of t tr is Q-no orrsponin to t rfrn. On n sily moify T to n PQ-tr T wit n ritrry P-no s t root s illustrt in Fi. 4(). Lt G plnr irp. G is sris-prlll irp if t unrlyin unirt rp of G is sris-prlll rp. T PQ-tr of sris-prlll irp G is xtly t sm s t on of t unrlyin unirt srisprlll rp of G. In t rminr of tis ppr, w onsir n PQ-tr
Upwr Plnr Drwins 33 T of sris-prlll irp G wit P-no s t root. If (G) = 2, tn t unrlyin unirt rp of G is yl n E V = 0. It s n sown in [HL05] tt ll yli irps wit E V < 2 r upwr plnr. Hn, for (G) = 2, G is lwys upwr plnr. On my tus ssum tt (G) 3, n tt t root P-no of T s tr or mor ilrn. Tn t prtinnt irp G(x) of no x is t surp of G inu y t s orrsponin to ll snnt Q-no of x. Bs on t ssumption tt (G) = 3, t followin fts ol [REN05]. Ft 1 Lt (s, t) t rfrn of n -no x of T, n lt x 1, x 2,, x k t ilrn of x in tis orr from s to t. Tn (i) il x i of x is itr P-no or Q-no; (ii) ot x 1 n x k r Q-nos; n (iii) x i 1 n x i+1 must Q-nos if x i is P-no wr 2 i k 1. Ft 2 E non-root P-no of T s xtly two ilrn. A il of nonroot P-no n n - or Q-no. A P-no in n PQ-tr T is primitiv if it os not v ny snnt P-no in T. Lt x primitiv P-no in T. Lt x l n x r t lft n rit il of x in T rsptivly. Tn t unrlyin unirt rp of G(x) = G(x l ) G(x r ) is yl n n t irp G(x) is upwr plnr [HL05]. Trfor, t prtinnt irp G(x) of vry primitiv P-no x in T is lwys upwr plnr. W fin tt t it of primitiv P-no is zro. T it of ny otr P-no is (i + 1) if t mximum of t its of its snnt P-nos is i. T P-no P 3 in Fi. 4() is primitiv P-no. T its of t otr two P-nos P 2 n P 1 in Fi. 4() r 1 n 2 rsptivly. Lt G plnr irp. A rwin Γ of G is n upwr plnr rwin if it s no -rossin n ll t s of G r rwn s simpl urvs monotonilly inrsin in t vrtil irtion. G is n upwr plnr irp if G mits n upwr plnr rwin. On n osrv tt t followin lmm ols for n upwr plnr irp G. Lmm 1. A irp G is upwr plnr if n only if vry surp H of G is upwr plnr. Lt G irp wit fix plnr min. A vrtx v of G is imol if t irulr list of s inint to v n prtition into two (possily mpty) lists, on onsistin of inomin s n t otr onsistin of outoin s. If ll vrtis of G r imol tn G is ll imol. Ayliity n imolity r nssry onitions for t upwr plnrity of n m plnr irp [BDLM94]. Howvr, ty r not suffiint onitions. Lt f f of n m plnr imol irp G n suppos tt t ounry of f is visit lokwis if f is n innr f, n ountrlokwis if f is t outr f. Lt α = ( 1, v, 2 ) triplt su tt v is vrtx of t ounry of f n 1, 2 r two inint s of v tt r onsutiv on t ounry of f. Triplt α is ll n nl of f. W ll n nl α swit
34 M. A. H. m n M. iur Rmn nl of f if itr t irtion of 1 is opposit to t irtion of 2 on t ounry of f or 1 n 2 oini. Not tt if 1 n 2 oini tn G is not ionnt. If 1 n 2 r ot inomin in v, tn α is sink-swit of f n if ty r ot outoin, tn α is sour-swit of f. A sour or sink of G is ll swit vrtx of G n vrtx tt is not swit vrtx is ll n orinry vrtx of G. In t rminr of tis ppr w rfr to swit nl of f f y llin it simply swit of f. Lt G n m plnr irp. Lt Γ n upwr plnr rwin of G n lt α n nl of f f of G. W ssin ll F to t nl α in f f if α is not swit of f. Otrwis α is swit of f, n w ll α in f wit lttr L if α s vlu rtr tn π in Γ n wit lttr if t vlu of α in Γ is lss tn π. W ssin lls to ll nls of G s mntion ov n otin ll m irp. W ll tis ll m irp n upwr plnr rprsnttion of G n not it y U G. T rwin Γ is si to n upwr plnr rwin tt prsrvs U G [DGL06]. Fiur 5() illustrts U G of t rp G in Fi. 5() for t upwr plnr rwin Γ in Fi. 5(). It is mntionl tt ny ritrry llin of t swits of G my not v orrsponin upwr plnr rwin n n my not rr s n upwr plnr rprsnttion of G. T onitions wi must mt in orr to otin U G r sri low. v1 v7 v2 v5 v3 v6 v4 v11 v8 () v10 v9 v7 L F L v2 v5 F F v1 F () F v3 F v6 L F F v4 Lv11 F F v8 L v10 v9 L v1 v2 v5 v6 () v10 v3 v11 v4 v8 v9 v7 Fi.5. Illustrtion of upwr plnr rprsnttion n upwr plnr rwin. Lt G irp wit fix plnr min. Lt Φ n ssinmnt wi ssins ll of itr L,, or F to nl of vry f of G. For vrtx v of G, w not y L(v), (v), n F(v) t numr of nls t v tt Φ lls wit L,, n F rsptivly. For f f of G, w not y L(f), (f), n F(f) t numr of nls of f tt r ll y Φ wit L,, n F rsptivly. W ll t ssinmnt Φ n upwr onsistnt ssinmnt if t followin two onitions ol for Φ: (i) for swit vrtx v of G, L(v) = 1, (v) = (v) 1, F(v) = 0, n for orinry vrtx v of G, L(v) = 0, (v) = (v) 2, F(v) = 2; n (ii) for innr f f, (f) L(f) = 2 n for t outr f f, (f) L(f) = 2.
Upwr Plnr Drwins 35 1 Pl (y p ) : Pr (y p ) : 2 9 10 8 13 11 4 6 P l (x 1 ) : Pr (x 1 ) : P l (r) : 14 Pr (r) = P l (y p ) : 12 15 17 () 3 5 16 18 19 7 8 9 10 11 12 13 8 14 () 4 5 9 6 7 1 () (f) 15 2 8 10 16 3 4 5 9 10 8 y 1 P r y 2 1 2 3 P P 4 x 1 5 6 x 2 7 9 10 11 12 13 17 18 19 14 15 16 y 3 x 3 x 4 x 5 x 6 T () y 1 r y p y 2 y 3 T () Fi.6. () A ionnt sris-prlll rp G, () n PQ-tr T of G, () T wit ummy P-no y p, () (f) pol-pts of no x 1, y p n r rsptivly. On n intuitivly unrstn t nssity of onitions (i) n (ii) for n upwr plnr rwin. Conition (i) must ol u to t nssity of imolity, wil onition (ii) must ol u to si omtri onsirtion for upwr plnrity. Conitions (i) n (ii) r lso suffiint for upwr plnrity of G s stt in [DGL06]. Hn t followin lmm ols. Lmm 2. Lt G n yli plnr imol m irp su tt nl of G is ssin ll L, or F unr som ssinmnt Φ. Tn t lllins of t nls in G fin n upwr plnr rprsnttion U G of G if n only if Φ is upwr onsistnt. Givn n upwr plnr rprsnttion U G of G, it is lwys possil to onstrut n upwr plnr strit-lin rwin of G in linr-tim [DGL06]. 3 Fsil Lllins In tis stion, w introu t notion of fsil st of vlus for lllin t nls of G to otin n upwr plnr min of G. Lt T ivn PQ-tr of G wit P-no r s its root. Tn r s tr ilrn n vry otr P-no of T s xtly two ilrn. Lt y 1, y 2 n y 3 t tr ilrn of r. W insrt ummy P-no y p s il of r n mk y 2 n y 3 t two ilrn of y p. Lt T t rsultin tr (s Fi. 6() n ()). Evry P-no of T s xtly two ilrn n t pols of r n y p in T r t sm now. For ny two P-nos z 1 n z 2 in T, w sy tt z 1 is t prnt P-no of z 2 (quivlntly, z 2 is il P-no of z 1 ) if
36 M. A. H. m n M. iur Rmn z 2 is snnt of z 1 n tr is no otr P-no twn z 1 n z 2 on t z 1, z 2 -pt in T. By tis finition, y p is il P-no of r. Lt x P-no wit pols u, v. Lt x l n x r t lft n rit il of x rsptivly. W fin two -isjoint u, v-pts P l (x) n P r (x) s follows: (i) if x is primitiv, tn of G(x l ) n G(x r ) is pt. In tis s, P l (x) = G(x l ), P r (x) = G(x r ) (s Fi. 6()). (ii) if x is not primitiv n is not t root of T, tn lt y not il P-no of x in t lft sutr of x n y not il P-no of x in t rit sutr of x. In tis s, P l (x) will onsist of ll t il Q-nos of x l n P l (y), for il P-no y in t lft sutr. imilrly, P r (x) will onsist of ll t il Q-nos of x r n P l (y ), for il P-no y in t rit sutr (s Fi. 6()). (iii) if x is t root of T, tn x l is itr n - or Q-no n x r is t ummy P-no. In tis s, P l (x) is fin s in s (ii) ov n P r (x) = P l (x r ). (s Fi. 6(f)). W ll of P l (x) n P r (x) pol pt of x. In t rminr of tis ppr, w us C(x) to not t yl P l (x) P r (x) n F(x) to not t f oun y C(x). Lt x non-primitiv P-no in T n y not il P-no of x. W ll swit of F(x) fr swit of F(x) if t swit is nitr on P l (y) nor t t pols of y for ny il P-no y of x. W now introu t notion of fsil llin of P l (x) n t fsil st of P-no x in T. Lt U G(x) n upwr plnr rprsnttion of G(x). Tn n upwr plnr rprsnttion of C(x) n otin from U G(x). Tis n on y simply ltin ll tos vrtis n s of G(x) wi r not in C(x). Lt U C(x) not tis upwr plnr rprsnttion of C(x) n Φ t orrsponin upwr onsistnt ssinmnt. Lt L(x) n (x) not t numr of L- n - lls ssin y Φ to tos swits of F(x) wi r on t pt P l (x). If L(x) = p n (x) = p + q, tn (x) L(x) = q. W sy tt q is fsil vlu of L for llin t swits of F(x) on pt P l (x). Lt Fsil(x) not t st of ll fsil vlus of L for llin t swits on pt P l (x). W rr Fsil(x) s t fsil st of t P- no x. An ssinmnt of lls to t swits on P l (x) is fsil llin of P l (x) if (x) L(x) = q for som q Fsil(x). T followin ft follows t finition of fsil llin. Ft 3 For ivn fsil vlu q Fsil(x), tr is orrsponin upwr plnr rprsnttion of G(x). Lt x non-primitiv P-no in T n y il P-no of x in T. in G(y) is surp of G(x), ivn U G(x) w n otin n upwr plnr rprsnttion U G(y) of G(y) n n t followin ft ols. Ft 4 For ivn fsil vlu q Fsil(x), tr is orrsponin fsil vlu q Fsil(y) for il P-no y of x. W now v t followin lmm.
Upwr Plnr Drwins 37 Lmm 3. G(x) s n upwr plnr rprsnttion if n only if P l (x) n ivn fsil llin. Proof. Nssity. T nssity of t onition follows from t finition of fsil llin. uffiiny. Lt us ssum tt P l (x) is ivn fsil llin orin to fsil vlu q Fsil(x). Tn it follows from Ft 3 n Ft 4 tt tr xists n ssinmnt Φ of - n L- lls to t swits of F(x) su tt ) P l (x) is ll orin to t fsil vlu q, ) for il P-no y of x, P l (y) rivs fsil llin, ) for y, swits of F(x) t t pols of y (if ny) r ssin lls in su wy tt P r (y) n m insi t f wr P l (y) is ivn fsil llin, n ) (F(x)) L(F(x)) = 2 from t finition of upwr onsistnt ssinmnt. in Φ xists, on n fin it y tryin vlu from t fsil st Fsil(y) of il P-no y. Tn tis sm pross my ppli rursivly on P l (y) for il P-no y of x n finlly U G(x) n omput. Q.E.D. W immitly t t followin orollry from Lmm 3. Corollry 1. Lt x P-no in T. Tn t prtinnt irp G(x) of x s no upwr plnr rprsnttion if n only if t st Fsil(x) is mpty. Lt u pol of y su tt tr is swit nl u x of F(x) t vrtx u. As mntion in onition () in t proof of Lmm 3, w n to ll u x in su wy tt P r (y) n m insi t f in wi P l (y) is ivn fsil llin. At t sm tim, w must lso nsur tt t llin of t swits t vrtx u stisfis onition (i) of n upwr onsistnt ssinmnt. in (G) = 3 n G is ionnt, t r of vry vrtx in G is itr two or tr. Any ll ssin to swit t vrtx of r two of G lwys stisfis onition (i) of upwr onsistnt ssinmnt. W trfor n to onntrt on llin t swits t t vrtis of r tr of G. in G is sris-prlll irp, only t pols of t P-nos of T n v r tr. In rr to llin t swits t t pols of t P-nos of T, w v t followin lmm. Lmm 4. Lt x n y two P-nos in T su tt x is t prnt of y. Lt u pol of y su tt tr is swit nl u x of F(x) t vrtx u. Tn u x must ll wit n L-ll wn P r (y) is m insi t f F(x) n wit n -ll wn P r (y) is m in t xtrior of t f F(x) if t followin () or () ol. () u is n orinry vrtx of G n, () u is swit vrtx of G n itr P r (y) is m insi t f F(x) wit lr nl t t swit of F(y) t pol u or P r (y) is m in t xtrior of t f F(x) wit smll nl t t swit of F(y) t pol u. W v omitt t proof of Lmm 4 in tis xtn strt. In of t two ss of Lmm 4, w fin u s n L-pol of no y. T followin lmm is irt onsqun of Lmm 4.
38 M. A. H. m n M. iur Rmn Lmm 5. Lt x n y two P-nos in T su tt x is t prnt of y in T. If ot t pols of y r L-pols, tn in orr to otin n upwr plnr rwin, ot t swits of F(x) t t pols of y must ssin t sm ll. T lls ssin to t swits (if ny) of F(y) t t pols of y ply importnt rols in upwr plnrity tstin s sri in t followin fts. Ft 5 Lt swit vrtx u of G pol of no y, n lt u y t swit nl of F(y) t pol u. Tn u is n L-pol of no y if () u y is ll wit L n F(y) is m s n innr f, n () u y is ll wit n F(y) is m s t outr f. Ft 6 Lt n orinry vrtx u of G pol of no y. Lt u ontin swit nl of F(y). Tn () F(y) must m s t outr f if u y is ll wit L, n () F(y) must m s n innr f if u y is ll wit. W omit t proofs of Ft 5 n Ft 6 r sin t fts r intuitiv onsquns of t finition of L-pols. Lt x P-no of T n y il P-no of x. W now fin litimt llin for no y wi will us xtnsivly trouout t rminr of tis ppr. A llin of t swits of F(x) on P l (y) n t t pols of y is ll litimt llin for no y if t followin () n () ol: () P l (y) is ivn fsil llin n () if pol u of y is n L-pol tn t llin of u x stisfis Lmm 4, otrwis ot n L lls r onsir for llin u x. In t rminr of tis ppr, w us Litimt(y) to not t st of vlus of L insi F(x) orrsponin to litimt llin for no y. W fin llin of t swits on P r (x) to litimt llin of P r (x) if it prforms litimt llin for il P-no y of x in t rit sutr of x n it onsirs ot n L lls for t fr swits on P r (x). W similrly fin litimt llin of P l (x). In t rminr of tis ppr, w us q r n q l to not t vlu of L insi F(x) for litimt llin of P r (x) n P l (x), rsptivly, n w us q pol to not t vlu of L insi F(x) for llin t swits (if ny) of F(x) t t two pols of x. W sy tt 2 (q pol + q r ) is possil fsil vlu of x. If w n fin litimt llin of P l (x) for wi q l = 2 (q pol + q r ), tn q l will fsil vlu of no x n will inlu in t fsil st Fsil(x) of x. As stt rlir, our ojtiv is to omput Fsil(x) for P-no x in T. Givn Fsil(y) for il P-no y of x, w n lwys omput Fsil(x). For tis purpos, on soul fin possil ssinmnt of lls to t swits of F(x) tt nsurs t onitions () () mntion in t proof of Lmm 3. Any loritm followin rut-for ppro to omplis tis woul yil xponntil tim omplxity. T ppro for onstrutin U G(x) outlin in t proof of Lmm 3 woul lso yil xponntil tim omplxity. In our loritm wi w sri in t nxt stion, w sow tt w n omput Fsil(x) in linr-tim y usin t onpts introu tus fr. Furtrmor, if G(x) is upwr plnr, tn w n lso otin U G(x) in linr-tim.
4 An Upwr Plnr Drwin Aloritm Upwr Plnr Drwins 39 In tis stion w iv linr-tim loritm to tst t upwr plnrity of ionnt sris-prlll irp G wit (G) = 3. If G is upwr plnr, tn w lso onstrut n upwr plnr rprsnttion of G in linr-tim. An outlin of our loritm is ivn low. Our loritm onsists of two pss, nmly, t tstin ps n t onstrution ps. In t tstin ps, w trvrs t P-nos of T in ottom-up fsion n t P-no x, w tst t upwr plnrity of G(x). For tis purpos, w omput t fsil st Fsil(x) of no x. If x is primitiv, tn omputin Fsil(x) is quit strit forwr. On t otr n, if x is non-primitiv, tn w n omput Fsil(x) from t fsil sts of t il P-nos of x. If w su in tis ottom-up trvrsl to fin Fsil(r), wr r is t root of T, tn w lr G s n upwr plnr irp n strt our son ps in wi w onstrut n upwr plnr rprsnttion of G. On t otr n, if w fin tt Fsil(x)= for ny P-no x in T, tn from Corollry 1 n Lmm 1, w lr tt G is not upwr plnr. On n sily unrstn tt if w onsir only t omintoril mins of t sklton of P-no of T, tn our ision rrin t upwr plnrity of G tt w mk in sinl trvrsl of T my inorrt. Trfor, w nsur tt our mto onsirs vry plnr min of t sklton of P-no of T ; nvrtlss, our loritm ivs linr-tim s w will sow in tis stion. In t onstrution ps, w prform top-own trvrsl of t P-nos of T. W strt t onstrution ps wit fsil llin of P l (r) wr r is t root of T. Tn in top-own trvrsl of T, t P-no x w ssin lls to t swits of F(x) su tt t ssinmnt stisfis onitions () () ivn in t proof of Lmm 3. Tis prour is rri on t sis of informtion tr in t tstin ps. At t n of tis trvrsl w otin t finl upwr plnr rprsnttion U G of G. W now strt wit t sription of our prour to trmin t fsil st of primitiv P-no. Lt x P-no in T. In t rminr of tis ppr, w us t symols n r, n l n n x to not t numr of swits of F(x) on t pt P r (x), on t pt P l (x) n t t two pols of x, rsptivly. W lso opt t nottion [low.. i] to not t st of intrs in wi t numrs r list in snin orr n t first numr is low, t lst numr is i n if not mntion xpliitly, t prioiity of t numrs is 2. Lt x primitiv P-no n q possil fsil vlu of x. Tn q will fsil vlu of x n inlu in Fsil(x) if q n l. Lt I 0 = [ n r + 2.. n r + 2], I = [ n r +(2 n x ).. n r +(2 n x )] n I + = [ n r +(2+n x ).. n r +(2+n x )]. Tn w v t followin lmms rrin t possil fsil vlus of primitiv P-no x in T wos proofs r omitt in tis xtn strt. Lmm 6. Lt x primitiv P-no of T. Lt I innr n I outr t st of possil fsil vlus of no x for min F(x) s n innr f n t outr f, rsptivly. Tn t followin () n () ol.
40 M. A. H. m n M. iur Rmn () I innr = I outr = I 0 = [ n r + 2.. n r + 2], if n x = 0; n () I innr = I = [ n r + (2 n x ).. n r + (2 n x )] n I outr = I + = [ n r + (2 + n x ).. n r + (2 + n x )], if n x > 0 n of ts n x pols of x is n orinry vrtx of G. Lmm 7. Lt x primitiv P-no of T. Lt I innr n I outr t st of possil fsil vlus of no x for min F(x) s n innr f n t outr f, rsptivly. If n x = 2 n on of t two pols of x is swit vrtx of G n t otr is n orinry vrtx of G, tn t followin () n () ol. () I innr = I I 0 = [ n r.. n r + 2] n I outr = I + I 0 = [ n r + 2.. n r + 4]; n () For vry q I 0, t pol of x wi is lso swit vrtx of G is n L-pol. Lmm 8. Lt x primitiv P-no of T. Lt I innr n I outr t st of possil fsil vlus of no x for min F(x) s n innr f n t outr f, rsptivly. If n x > 0 n of ts n x pols of x is swit vrtx of G, tn t followin () () ol. () For n x = 1, I innr = I outr = I I + n for n x = 2, I innr = I outr = I I + I 0. () For vry q I, of t n x pols of x is n L-pol if F(x) is m s t outr f. () For vry q I +, of t n x pols of x is n L-pol if F(x) is m s n innr f. () For vry q I 0, on of t pols of x is n L-pol if n x = 2. Hvin omput t fsil st for primitiv P-no, w now pro towrs t omputtion of fsil st of ny P-no in T. To omput fsil vlu for non-primitiv P-no x in T, w must nsur tt for vry il P-no y of x, w r prformin litimt llin. Trfor, w first monstrt ow w n fin t st Litimt(y) for il P-no y of x. Lt q Fsil(y). By ivin fsil llin to P l (y) stisfyin q Fsil(y), w n otin tr possil mins of F(y) s sown in Fi. 7() (). In Fi. 7() n () F(y) is m s n innr f. Hn, in ts two ss, xtly on of P r (y) n P l (y), ut not ot, pprs t t outr f. On t otr n, in Fi. 7(), F(y) is m s t outr f, n n ot P l (y) n P r (y) v n rwn rwn t t outr f. From mor tortil point of viw, t tr fiurs in Fi. 7() () tully orrspon to tr possil plnr mins of t sklton of no y. W n isr t otr tr possil plnr mins of t sklton of no y us ty r just t mirror rfltions of t tr mins sown. In orr to otin n min s sown in Fi. 7() w v to ll t swits on P l (y) in su wy tt t lls of ts swits yil L = q insi f F(x). imilrly, in orr to otin t mins sown in Fi. 7() n ()
Upwr Plnr Drwins 41 u F(x) v () u u u u u u u u u u u v Pl(y) v Pl(y) Pr(y) Pr(y) Pl(y) F(y) Pr(y) v v v v v v v v () () () v Pl(y) Fi.7. Tr possiilitis to onsir from P-no x to m t fil yl F(y). t lls of t swits on P l (y) soul yil L = q insi f F(x). W n trmin t litimt vlus of L insi F(x) for t tr snrios sown in Fi. 7 y onsirin t followin tr possil ss: (i) Bot t pols of y r L-pols: for t tr mins in Fi. 7() (), w soul v 2 q, 2 + q, 2 + q rsptivly s t vlu of L insi F(x). (ii) Extly on of t pols of y is n L-pol: w soul v 1 q, 1+q, 1+q rsptivly for t mins in Fi. 7() (). (iii) Non of t pols of y is n L-pol: w soul v q, +q, +q rsptivly for t mins in Fi. 7() (). For t ss (ii) n (iii), if pol of y ontins fr swit of F(x), tn t vlu of L insi F(x) for llin tt swit woul ±1, sin it n ssin itr of t two possil lls. W now sow ow w n omput Litimt(y) wn y is primitiv P-no. In t followin w first onsir only t litimt vlus rsultin from min F(y) s n innr f. Lt q m not t mximum of ts litimt vlus. In Lmm 10 w sow tt, if F(y) is m s t outr f, tn t most two nw litimt vlus n otin, nmly, q m +2 n q m + 4. W v sn in Lmm 6, 7 n 8 tt t st of fsil vlus wi n stisfi for min F(y) s n innr f is of t form: [lo.. i]. W now v t followin lmm rrin t litimt vlus for primitiv P-no y wn F(y) is m s n innr f. Lmm 9. Lt y primitiv P-no in T n x t prnt P-no of y in T. Lt n Lpol not t numr of L-pols of no y. Lt Fsil(y)= [lo.. i] n k not t numr of swits of F(x) t tos pols of y wi r not L-pols. Tn for min F(y) s n innr f t followin () n () ol. () If lo = i = 0 n n Lpol = 2 tn Litimt(y)= { 2, +2}; n () Otrwis, Litimt(y)= [ (mx + k).. (mx + k)], wr mx is t mximum of n Lpol lo n n Lpol i. W now v t followin lmm rrin t litimt vlus of primitiv P-no x wn F(x) is m s t outr f.
42 M. A. H. m n M. iur Rmn Lmm 10. Lt x primitiv P-no in T. Lt q m t mximum of ll t litimt vlus otin y min F(x) s n innr f. Tn t most two nw litimt vlus, nmly, q m + 2 n q m + 4 n otin y min F(x) s t outr f. In t followin lmm, w rss t issu of omputin Fsil(x) for non-primitiv P-no x in T. Lmm 11. Lt x non-primitiv P-no in T. Lt y 1,...,y l t il P-nos of x in T. Tn Fsil(x) n omput from Fsil(y 1 ),..., Fsil(y l ). Proof. Lt y 1, y 2,..., y lft t il P-nos in t lft sutr of x n y 1, y 2,...,y rit t il P-nos in t rit sutr of x. Lt not t it of t P-no x in T. W prov t lim y inution on. W first ssum tt = 1. Tn vry il P-no of x is primitiv. Lt y il P-no of x. Aorin to Lmm 6, 7 n 8, y s two typs of fsil vlus, nmly, t fsil vlus stisfyin wi F(y) n m s n innr f n t fsil vlus stisfyin wi F(y) n m s t outr f. Amon ll t il P-nos y of x, for t most on y, w n m F(y) s t outr f sin plnrity woul violt otrwis. Hn, for y, w first onsir tos vlus from Fsil(y) stisfyin wi w n m F(y) s n innr f, ltr w nl t fsil vlus stisfyin wi w n m F(y) s t outr f. As w v sown in Lmm 9, if y i is il P-no of x in t lft sutr of x, tn t st of litimt vlus for min F(y) s n innr f is [ p i.. p i ] wit prioiity of itr 2 or 4 for som intr p i (1 i lft). imilrly, if y i is il P-no of x in t rit sutr of x, tn t st of litimt vlus for min F(y) s n innr f is [ p i.. p i ] wit prioiity of itr 2 or 4 for som intr p i (1 i rit). Lt p not t numr of fr swits of F(x) on pt P r (x). in llin of of ts fr swits n yil L = ±1 insi F(x), w woul v [ p.. p ] s t st of vlus for llin ts swits. Trfor, t st of litimt vlus for llin of P r (x) will of t form [ (p + p i ).. (p + p i )] wit prioiity of itr 2 or 4. Tkin k = p + p i, w n otin [ k.. k] s t st of litimt vlus for llin of P r (x). From tis st of vlus, w n otin t st of possil fsil vlus of x (i.., w n otin I innr n I outr ) xtly in t sm wy s w v sri in Lmm 6, 7 n 8. It now rmins to trmin wi of ts possil fsil vlus will t fsil vlus of x. For tis purpos, w first trmin t litimt llin of P l (x) xtly in t sm wy s w trmin t litimt vlus for llin of P r (x). Evry possil fsil vlu of x wi is lso litimt vlu for llin of P l (x), will fsil vlu of x n n, will inlu in Fsil(x). It is mntionl tt, in tis omputtion, w o not n to k vry vlu from t formr st wit vry vlu of t lttr st. Rtr, w n otin t wol informtion in tim O(1) from t prioiity n t first n lst vlus of ts two sts. Hvin omput Fsil(x), w
Upwr Plnr Drwins 43 n omput Litimt(x) for min F(x) s n innr f s illustrt in Lmm 9 for primitiv P-no n w n lso omput t possil ns in ts litimt vlus if F(x) is m s t outr f s illustrt in Lmm 10 for primitiv P-no. W now onsir tos fsil vlus of il P-no y of x stisfyin wi F(y) n m s t outr f. W si prviously tt ny su min n inrs t litimt vlus for y y t most +2 n +4. Hn, rrlss of t oi of y, ny su min n us n of i {±2, ±4} in t litimt vlus for x. Lt Extrnl(x) t st of possil ns in t litimt vlus for x if F(x) or F(z) is m s t outr f wr z is snnt P-no of x. Tn Extrnl(x) {i + j : i {±2, ±4} n j {2, 4}} = [ 2.. + 8]. Alon wit Litimt(x), w pss tis st of possil ns to t prnt P-no of x in T. W nxt ssum tt > 1 n tt t ilrn of x v n t followin two quntitis to x. (i) Litimt(y) for vry il P-no y of x n (ii) t possil ns in t litimt vlus for no y tt n otin y min itr F(y) s t outr f, or F(z) s t outr f wr z is snnt P-no of y. In mnnr xtly similr to t s for = 1, w n omput t fsil vlus of x first y onsirin only tos fsil vlus of il P-no y of x wi n stisfi wil min F(y) s n innr f. From tis w trmin t st Litimt(x). Nxt w trmin t possil ns in t litimt vlus for no x tt r otinl y min itr F(x) s t outr f, or F(z) s t outr f wr z is snnt P-no of x. By oin so, w v in quipp ourslvs wit Fsil(x) n lso wit t ov two quntitis () n () wi w woul pss to t prnt of x if x is not t root of T, or if x is t root of T, tn w n strt our son ps of onstrutin U G y usin fsil vlu from Fsil(x). Q.E.D. W ll t loritm outlin in t proofs of Lmm 6, Lmm 7, Lmm 8 n Lmm 11 Aloritm UP-Tstr. W now v t followin torm. Torm 1. Lt G sris-prlll irp wit (G) 3. Tn t upwr plnrity of G n tst in linr-tim. Proof. Lt T t PQ-tr of G. From Lmm 6, Lmm 7, Lmm 8 n Lmm 11, w n fin Fsil(x) for ny P-no x in T y pplyin Aloritm UP-Tstr. If UP-Tstr fins Fsil(x) =, tn from Corollry 1, G(x) is not upwr plnr n n, from Lmm 1 G itslf is not upwr plnr. W n sow tt t oprtions rquir y Aloritm UP-Tstr to omput t fsil sts of ll t P-nos of T n prform in tim linr to t numr of P-nos in T. T tils of ts omputtions r omitt in tis xtn strt. in t numr of P-nos of T is linr in t numr of vrtis of G, t upwr plnrity of G n tst in tim O(n). Q.E.D. Finlly, w iv t followin torm rrin t onstrution of n upwr plnr rprsnttion of G, U G.
44 M. A. H. m n M. iur Rmn Torm 2. Lt r t root of t PQ-tr T of G. If G is upwr plnr, tn strtin wit fsil llin of P l (r), n upwr plnr rprsnttion of G n onstrut in linr-tim. Proof. Our proof is onstrutiv. W sow r ow w n prform fsil llin of P l (y) for il P-no y of x ivn tt P l (x) s n ll wit fsil vlu. Lt q t fsil vlu stisfi for llin P l (x). If q rquirs tt for som snnt P-no z of x, F(z) soul m s t outr f, tn t first w trmin tt P-no. Dpnin on t stisfi fsil vlu q, w know wt lls soul ssin to t swits (if ny) t t pols of x. Hn w ll t swits (if ny) t t pols of x. Lt L = q p insi F(x) for t lls ssin to t swits (if ny) t t pols of x. As sown in t proof of Lmm 11, w n sily omput t sts Litimt(y) tt ltotr yil t st Fsil(x). Lt t st of ll possil vlus for llin t swits on P l (x) [l.. ]. Tn lt i = q. W itrt trou of t omput litimt sts. Lt Litimt(y) =[l y.. y ]. If i > ( y l y ) tn w stisfy t fsil vlu orrsponin to l y for no y n ru i y y l y. Tn w pro wit t nxt no. Wn w fin i ( y l y ) t no y, w stisfy t fsil vlu orrsponin to ( y i) for tt P-no. For of t rminin P- nos in t lft sutr of x, w stisfy t fsil vlu orrsponin to y. W tn prform t sm oprtions in orr to stisfy t vlu 2 q q p for t swits on P r (x). Clrly, t wol tr n trvrs in linr-tim wil prformin ts oprtions t x wil t ompltion of t trvrsl inits tt w v otin n upwr plnr min of G in wi t swits v n ll orin to n upwr onsistnt ssinmnt. Tis omplts t proof of t lim. Q.E.D. 5 Conlusion In tis ppr, w v simpl linr-tim loritm to tst upwr plnrity n in t positiv s, otin n upwr plnr rwin of sris-prlll irp wit t mximum r tr. in our ttntion ws onfin to sris-prlll irps wit t mximum r tr, it looks iffiult to xtn tis loritm in strit forwr wy for mor nrl lsss of irps n lso for sris-prlll irps wit ir rs. It is lft s futur work to fin otr rtriztions of upwr plnrity of sris-prlll irps n vis ffiint loritms for upwr plnrity tstin n upwr plnr rwins of sris-prlll irps wit ir rs. Rfrns [BCDTT94] P. Brtolzzi, R. F. Con, G. Di Bttist, R. Tmssi, n I. G. Tollis, How to rw sris-prlll irp, Intrntionl Journl of Computtionl Gomtry n Applitions, 4 (4), pp. 385 402, 1994.
Upwr Plnr Drwins 45 [BDLM94] P. Brtolzzi, G. Di Bttist, G. Liott, n C. Mnnino, Upwr rwins of trionnt irps, Aloritmi, 6 (12), pp. 476 497, 1994. [BDMT98] P. Brtolzzi, G. Di Bttist, C. Mnnino n R. Tmssi Optiml upwr plnrity tstin of sinl-sour irps, IAM Journl on Computin, 27, pp. 132 169, 1998. [BL76] K.. Boot n G.. Lukr, Tstin t onsutiv ons proprty, intrvl rps, n rp plnrity usin PQ-tr loritms, J. Comp. ys. i., 13, pp. 335 379, 1976. [CDTT94] R. F. Con, G. Di Bttist, R. Tmssi, n I. G. Tollis, Dynmi rp rwin:trs, sris-prlll irps, n plnr st-irps, IAM Journl on Computin, 24 (5), pp. 970 1001, 1995. [CLR01] T. H. Cormn, C. E. Lisrson, R. L. Rivst, n C. tin, Introution to Aloritms, MGrw-Hill Book Compny, on Eition, 2001. [DGL06] W. Diimo, F. Giorno, G. Liott, Upwr spirlity n upwr plnrity tstin, Pro. of GD 05, Ltur Nots in Computr in, 3843, pp. 117 128. prinr-vrl, 2006. [DT96] G. Di Bttist n R. Tmssi, On-lin plnrity tstin, IAM J. Comput., 25(5), pp. 956 997, 1996. [GL99] A. Gr n G. Liott, Almost n-optiml plnr ortoonl rwins of ionnt r-3 plnr rps in qurti tim, Pro. of GD 99, Lt. Nots in Computr in, 1731, pp.38 48, 1999. [GT94] A. Gr n R. Tmssi, On t omputtionl omplxity of upwr n rtilinr plnrity tstin Pro. Grp Drwin 1994, Ltur Nots in Computr in, 894, pp. 286 297. prinr-vrl, 1995. [GT95] A. Gr n R. Tmssi, Upwr plnrity tstin, Orr, 12, pp. 109 133, 1995. [GT01] A. Gr n R. Tmssi, On t omputtionl omplxity of upwr n rtilinr plnrity tstin, IAM Journl on Computin, 31(2), pp. 601 625, 2001. [HL96] M. D. Hutton n A. Luiw, Upwr plnrity tstin of sinl-sour yli irps, IAM Journl on Computin, 25(2), pp. 291 311, 1996. [HL05] P. Hly n K. Lyn, Fix-prmtr trtl loritms for tstin upwr plnrity, Proins of OFEM 05, Ltur Nots in Computr in, 3381, pp. 199 208, 2005. [HT74] J. Hoproft n R. E. Trjn, Effiint plnrity tstin, Journl of t ACM, 21(4), pp. 549 568, 1974. [Pp95] A. Ppkosts, Upwr plnrity tstin of outrplnr s, Pro. of GD 95, Ltur Nots in Computr in, 894, pp. 298 306, 1995. [REN05] M.. Rmn, N. Ei, n T. Nisizki, No-n ortoonl rwins of sris-prlll rps, Pro. of GD 05, Ltur Nots in Computr in, 3843, pp. 409 420. prinr-vrl, 2006. [VTL82] J. Vls, R. E. Trjn n E. L. Lwlr, T Ronition of ris-prlll Dirps, IAM J. Comput., 11 (2), pp. 298 313, 1982.