Send Orders for Reprnts to reprnts@benthamscence.ae 4 The Open Cybernetcs & Systemcs Journal, 04, 8, 4-9 Open Access Fast Computaton of Shortest Path for Vstng Segments n the Plane Ljuan Wang,, Bo Jang *, Ansheng Deng and Q We College of Informaton Scence and Technology, Dalan Martme Unversty, Dalan, Chna, 606; Department of Informaton and Scence, Dalan Insttute of Scence and Technology, Dalan, Chna, 605 Abstract: Let s and t be two ponts n the plane, how to compute the Eucldean shortest path between s and t whch vsts a sequence of segments gven n the plane the problem to be dscussed n ths paper, especally, the stuaton of the adjacent segments ntersect s the focus of our study. In ths paper, we frst analyze the degeneraton applyng rubber-band algorthm to solve the problem and ntroduce the algorthm for computng Eucldean shortest path wth removng suffcently small segments. Then based on rubber-band algorthm, we present a new algorthm for solvng the degeneraton and computng the ESP by crossng over two segments to deal wth ntersecton and n our algorthm the adjacent segments order can be changed when they ntersect. Furthermore, we have mplemented the two algorthms and have appled a large test data to test them. The experments demonstrate that our algorthm s more effcent and effectve, and t has the same tme complexty as the rubber-band algorthm. Keywords: Eucldean shortest path, degeneraton, rubber-band algorthm, test data.. INTRODUCTION Eucldean shortest path (ESP) problem s one of the typcal problems n Computatonal Geometry. Its man am s to fnd the shortest path between two ponts for a gven seres of obstacles n Eucldean space []. In ths paper, we manly study the algorthms for computng the Eucldean shortest path between two ponts s and t of vstng a sequence of segments gven n the plane. Especally, the stuaton of the adjacent segments ntersecton s the focus of our study, but when three or more lne segments ntersect at one pont then t s not the scope of ths paper. The problem can be descrbed as follows. Let be a plane. Assume that there are n> segments s such that s sj sk =, for j k and,j,k =,,,n, see Fg. (), then how to compute the shortest path from s to t that vsts all the gven segments s (at least once) s our study, here, the vstng order needn t to be n the gven order. In Fg. (), the path lnked by dotted lnes s the ESP from s to t whch vsts 4 gven segments, and the vstng order s s 3 4. The ESP problem of vstng a sequence of segments has been ntensvely studed. When the gven segments don t ntersectuch as Funnel algorthm [] proposed by D. T. Lee and F. P. Preparata n 984, and rubber-band algorthm [3, 4] (denoted by R algorthm) proposed by Faje L and Renhard Kettle n 007. R algorthm has the K( ) O(n) tme, where K( )=(L 0 -L)/, L s the true length of the ESP of segment set S, L 0 that of an ntal path, and n s the 874-0X/4 Fg. ( ESP of vstng segments n the plane, for n=4. number of segments of the set S. In 0, Wang and Huo obtaned that the tme complexty of R algorthm s O(n ) when n s larger (.e.,n 500) by the experment. Furthermore, they ntroduced dvde and conquer nto R algorthm and reduced the tme complexty to O(n) [5]. When the gven segment may ntersect, many researchers have been studyng more effectve methods. LI Fa-je and KLETTE Renhard n 008 got an approxmaton soluton by removng suffcently small segments wthn an applcaton of R algorthm [4]. So far, no other effectve method has been reported yet. In ths paper, based on R algorthm, we present a new algorthm for computng the ESP of gven segments by the method of crossng over two segments to deal wth the ntersecton and n our algorthm the adjacent segments order can be changed n order to get the shorter path when they ntersect. The experments show that our algorthm s effcent and accurate for solvng the problem gven above.. THE DEGENERATION APPLYING ALGORITHM TO COMPUTE THE ESP The basc dea of R algorthm s that t computes the shortest path by local optmzaton and contnuous teraton. 04 Bentham Open
Fast Computaton of Shortest Path for Vstng Segments n the Plane The Open Cybernetcs & Systemcs Journal, 04, Volume 8 5 Except start pont and end pont, all the path ponts from the frst pont wll be updated one by one by each teraton. The algorthm wll not stop untl the total length of the path between two teratons only dffers by (the chosen accuracy) at most [3, 4]. In R algorthm, the teraton s computed accordng to the gven order of the segments. When any two segments of the segment set S don t ntersect, we can apply R algorthm to compute the ESP between two ponts s and t of vstng a sequence of segments n the gven order easly [3-5], but when they ntersect, t may be hard and even ncorrect to get the shortest path. Takng the Fg. () for example, f the calculated path ponts q on s and q + on s + are at the ntersecton of s and s + n current teraton, t s mpossble to compute new q' and q' + ( q q ', q q ' + + ) that makes q - q' q' + q + shorter than q - q q + q + n the later teraton processes. Because q and q + are both at the crossng of s and s +, the path ponts q and q + do not change n the later teraton process, obvously q - q q + q + sn't the optmal, except q -, q, q +, q + are on the same lne. We call the stuaton n ths example as a degeneraton path of the algorthm [3-5]. When the degeneraton appears, applyng R algorthm wll lead to falure. When the segments ntersect, assume that the segments s and s + ntersect at the pont C - and p + are the path ponts on s - and s + respectvely. Then, there are some cases among the ponts p - and p + and the segments s and s +, whch are as follows. Case p - and p + le on the dfferent sde of s and s + In ths case, the approach n the teraton process s as follows. If p passes through both s + and s +, obvously, p + s the local shortest path, denoted by, = p +, and the vstng order s the order of passng through s and s + ee Fg. (3 Otherwse, for Fg. (3a), there are many cases whch can be seen n Fg. (4 Accordng to R algorthm, we can choose one of the endponts of s as p or one of the endponts of s + as p + such that the local path s the shortest, and the vstng order s the same as above. Smlarly, for Fg. (3b), t can be done as Fg. (3a Snce there are other possble poston relatonshps between s and s +, (.e., they are vertcal), whch also can be done n a smlar way. In addton, n the flowng case and case 3, the method of dealng wth the endponts s the same as that of Fg. (3a (a) Fg. ( The degeneraton wth an applcaton of R algorthm. Removng suffcently small segments from segment s or s + at the ntersecton can avod the degeneraton [4]. Based on ths dea, n reference [6], the mproved R algorthm, denoted by A presented. The degeneraton can be avoded by applyng A when the adjacent segments ntersect, but the shortest path obtaned s only an approxmate because t s possble that the path through the ntersecton of the segments s the shortest. In ths paper, based on R algorthm, we propose the method of crossng over two segments to compute path ponts by analyzng the poston relatonshp between path ponts and segments, and we can change the order of the adjacent segments n order to get the shorter path when they ntersect. The method not only can solve the degeneraton effectvely but also t s more effcent and accurate than A. The experments show that our algorthm s correct and effectve. 3. THE METHOD OF DEALING WITH THE INTER- SECTED SEGMENTS When the segments do not ntersect, references [3-5] has presented the solvng method. (b) Fg. (3 p + passes through both s and s +. Case p - and p + le on the dfferent sde of s (s + ) and on the same sde of s + (s ) In ths case, t needs to compute the reflecton pont r on the lne segment s or s + to fnd the shortest path [7, 8]ee Fg. (5 The approach n the teratve process s as follows. If p p + only ntersects wth one of segments s and s +, the reflecton pont r les on the segment whch does not ntersect wth p, = + p r + rp +, and the vstng order s the order of passng through s and s +.
6 The Open Cybernetcs & Systemcs Journal, 04, Volume 8 Wang et al. (a) (b) (a) The reflecton pont les on s (c) (d) Fg. (4 p + does not ntersect wth s or s +. (a) The reflecton pont les on s (b) The reflecton pont les on s + Fg. (5 p - and p + le on the dfferent sde of s (s + ) and on the same sde of s + (s Case 3 p - and p + le on the same sde of s and s + In ths case, there are two cases whch are shown n Fgs. (6) and (7 () the case of computng one reflecton The two segments can be vsted by computng a reflecton pont (see Fg. 6 In ths case, obvously, = p r + rp +. It s worth notng that when passes through s or s + twce, we can select the nearest ntersecton to C as the p or p + n order to deal wth endponts easly. (b) The reflecton pont les on s + Fg. (6 p - and p + le on the same sde of s and s + (One reflecton pont () the case of computng two reflectons It needs to compute two reflectons when the two segments can t be vsted by computng a reflecton pont. The approach s as follows. We make the symmetrc pont of p - on s and the symmetrc pont of p + on s +, denoted by - and + respectvely. In ths case, there are three stuatons when computng the local shortest path (see Fg. 7 f ntersects wth s + and s + at the pont p and p + respectvely, and p and p + are on the same sde of p - and p +, they are the two reflectons and also the path ponts. If p p does not ntersect wth p, the shortest path s = p + + p + pp + + p, and the vstng + + order s the order of passng through s and s + (see Fg. (7a Otherwse, we need to change the vstng order of s and s + n order to get the shortest path, then = p + + p p + + pp + (see Fg. (7b f passes through the ntersecton C, n ths + case, the reflecton ponts concde wth C and they are also the path ponts (p =p + =C), = p C+ Cp +, and the vstng order s the order of passng through s and s +. It easly can be proved by makng two auxlary ponts and + on s and s + (see Fg. (7c f doesn t pass through the ntersecton C + and s dfferent from the sde of + p C and Cp +, = p C+ Cp +, the path ponts p and p + concde wth C, and the vstng order s the order of passng through s
Fast Computaton of Shortest Path for Vstng Segments n the Plane and s+ (see Fg. 7d Ths can be proved as follows. In Fg. (7d), we take two ponts and + on s and s+nce p ' p ' + p ' p ' + + p ' + p ' + = p p ' + p ' p ' + + p ' + p + ' C + Cp ' + = p C + Cp +, obvously ' C + Cp ' + < p ' p ' + p ' p ' + + p ' + p ' +, then p C + Cp + < p p ' + p ' p ' + + p ' + p +, = p C + Cp + follows. (a) The Open Cybernetcs & Systemcs Journal, 04, Volume 8 7 4. NEW ALGORITHM In ths paper, we adopt the method of crossng over two segments when two segments ntersect. The basc dea s as follows. Assume that s nterests wth s+, we can compute the path pont p on s and the path pont p+ on s+ accordng to the poston relatonshp between the path ponts p- and p+ and the segments s and s+. Next, we judge the poston relatonshp of s+ and s+,, f s + s + =, we compute the path pont p+ on s+ and p+3 on s+3. Otherwse, we compute the path pont p+ on s+ and p+ on s+. The new algorthm s denoted by A, whch conssts of Man procedure, Update procedure, ESPByOne procedure and ESPByTwo procedure. Man procedure s developed based on R algorthm whch s used to calculate the teraton process, Update procedure s used to compute the path ponts n each teraton, ESPByOne s the procedure of crossng over one segment to compute the path ponts, the detal has been presented n reference [7], ESPByTwo s the procedure of crossng two segments to compute the path ponts, whch s the core of ths paper. ESPByTwo procedure can be descrbed as follows. ESPByTwo( p + + ) procedure. Here and s + are two segments and p + are two path ponts on s and s +. The procedure s used to compute the new path ponts p and p + on s and s +. (b) Let s = p p +, L denote the path computed by ESPByOne procedure, and c s the ntersecton of s wth s +. Case p- and p+ le on the dfferent sde of s and s+ f ( s s && s + s ), assume that r and r are the ntersectons of s wth s, and s + wth s respectvely, then let p = r and p + = r, and f ( p r > p r ) then call swap ( s + ) and call swap( p + (c) Case p- and p+ le on the dfferent sde of s (s+) and on the same sde of s+( s) f ( s s s + s ) f ( s s ) then call ESPByOne( p + + ), assume that r and r are the ntersectons of L wth s, and L wth s + respectvely. Let p = r + = r and stemp = r p +, f ( s stemp ) then call swap ( s + ),and call swap ( p + else ESPByOne( p + ), assume that r and r are (d) Fg. (7 p- and p+ le on the same sde of s and s+ (Two reflecton ponts the ntersectons of L wth s, and L wth s + respectvely. Let p = r + = r and stemp = p r.
8 The Open Cybernetcs & Systemcs Journal, 04, Volume 8 Wang et al. Table. The Results of 0 Segments Sets by A and A. Segment Sets A Algorthm A Algorthm Iteraton Tmes ESP Iteraton Tmes ESP 00 6 36754 69 35647 00 376 8334 93 684 300 386 639 97 9467 400 40 67955 40 3784 500 454 033 46 56598 600 47 47585 434 6735 700 486 84348 447 8965 800 497 3843 458 04536 900 5 35896 487 4675 000 50 35840 490 76593 f ( s + stemp ) then call swap ( s ), and call swap ( p Case 3 p - and p + le on the same sde of s and s + ESPByOne( p + ), let r denotes the ntersecton of L wth s and stemp = p r. f ( s + stemp ), and r s the ntersecton, then let p = r = + r, call swap ( s ) and call swap ( p else ESPByOne( p + ), let r denotes the ntersecton of L wth s, and stemp = p + r. p ( f ( s stemp ), and r s the ntersecton, then let = r = + r, call swap ( s ) and call swap p + p, else we make the symmetrc pont of p - on s and that of p + on s, denoted by - and + respectvely, let stemp = p ' p ' +, r and r denote the ntersecton s wth stemp, and s wth stemp. f ( p and c le on the same sde of stemp ) then let p = p = c. + else let p = r, and p = + r. f ( p r p p call swap ( p + + ) then call swap ( s ) and 5. THE ANALYSIS OF RUNNING RESULT We have mplemented A and A wth C++ program and have appled 0 randomly generated segment sets to test the algorthms, and the sze of segments s 00, 00,,000 respectvely. The experment s results show that our algorthm s correct and effcent, whch can be shown n Table. From the Table, we can see that the ESP of A s shorter than that of A and the teraton tmes of A s less than that of A. Fg. (8 The runnng result of 0 segments of A and A. To make the result clearly vsble, we only present the result of 0 segments (see Fg. 8 The sold lnes are randomly generated segments, the path lnked by the thndotted-lnes from S to T s the ESP obtaned by the A and the path lnked by the thck-dotted-lnes from S to T s the ESP obtaned by the A. It s obvous that the ESP obtaned by A s shorter than ESP obtaned by A. In ths example, s 3 4 5 6 7 8 9 0 s the ntal gven order of segments. After runnng wth our algorthm, the output s s 4,s,s 3,s,s 6,s 5,s 7,s 9,s 8,s 0. We can see the vstng order has been changed and we can get the shorter path and the faster runnng tme. Furthermore, ths example contaned three poston relatonshps between path ponts and segments ds-
Fast Computaton of Shortest Path for Vstng Segments n the Plane The Open Cybernetcs & Systemcs Journal, 04, Volume 8 9 cussed above, for example, (p 3 6 ), (p 6 5 7 ) and (p 9,s 8,s 0,T) are the case, case and case3 respectvely. 6. CONCLUSION In ths paper, based on R algorthm, we present a new algorthm for computng the Eucldean shortest path of vstng a sequence of segments gven n the plane. When the adjacent segments ntersect, applyng the method of crossng over two segments to deal wth the ntersecton can effectvely solve the degeneraton caused by R algorthm. Furthermore, our algorthm can effcently and accurately compute the ESP of gven segments. Snce dealng wth degeneraton has not ncreased the tme complexty of R algorthm, t has the same tme complexty as R algorthm. Ths research has made prelmnary results, the stuaton of three or three more lne segments ntersect at one pont s an open problem [9]. CONFLICT OF INTEREST The authors confrm that ths artcle content has no conflct of nterest. ACKNOWLEDGEMENTS Ths work s supported by the Natonal Natural Scence Foundaton of Chna (No.673034, 677) and the General Project of Lao Nng Provnce Scence and Research (No. L0487 REFERENCES [] M. de Berg, O. Cheong, M. van Kreveld, M. Overmars, Computatonal Geometry: Algorths and Applcatons (3 rd Edton), Sprnger-Verlag Publshers: Berln, 009p. 0-. [] D. T. Lee and F. P. Preparata, Eucldean shortest paths n the presence of rectlnear barrers, Networks, vol. 4, no. 3p. 393-40, September.984. [3] F. L and R. Klette, Exact and approxmate algorthms for the calculaton of shortest paths, IMA J. Manag. Mathem., vol. 7, no.p.34-38, 006. [4] F. L and R. Klette, Shortest path algorthms for sequences of polygons, CAAI Trans. Intell. Syst., vol. 3, no. p. 3-30, 008. [5] L. Wang, L. Huo, and D. He, An mproved algorthm for eucldean shortest paths of vstng lne segments n the plane, J. Conver. Inform. Tech., vol. 6, no. 6p. 9-5, 0. [6] L. Wang, B. Jang, Q. We, D. He, Research on the algorthm for eucldean shortest paths of vstng lne segments n the plane, ICIC Express Lett., vol. 8, no. 6p. 683-687, 04. [7] X. Tan, Fast computaton of shortest watchman routes n smple polygon, Inform. Process. Lett., vol. 77, no. p. 7-33, 00. [8] A. Dumtrescu, J. S. B. Mtchell and P. yl sk, Watchman Route for Lne and segments, Algorthm. Theory SWAT 0 Lect. Notes Comp. Sc., vol.7357, no. 4p. 36-47, May. 0. [9] M. Dror, A. Efrat, A. Lubw and J. S. B. Mtchell, Tourng a sequence of polygons, In Proc. 35th Annu. ACM Sympos. Theory Comput., Calforna, USA, 003p. 473-48. Receved: September, 04 Revsed: November 30, 04 Accepted: December 0, 04 Wang et al.; Lcensee Bentham Open. Ths s an open access artcle lcensed under the terms of the Creatve Commons Attrbuton Non-Commercal Lcense (http://creatvecommons.org/- lcenses/by-nc/3.0/) whch permts unrestrcted, non-commercal use, dstrbuton and reproducton n any medumrovded the work s properly cted.