Bhelors thesis Grph theory Route prolems Author: Aolphe Nikwigize Dte: 986 - -5 Sujet: Mthemtis Level: First level (Bhelor) Course oe: MAE
Astrt In this thesis we will review some route prolems whih re prt of grph theory prolems. In more etils it will ontin the si of grph theory, some well-known lgorithms relte to route prolems, n ifferent route prolems solve y these lgorithms.
Contents. INTRODUCTION...4. BASIC GRAPH THEORY...5. DEFINITION AND GRAPH REPRESENTATION...5. MORE DEFINITIONS...6.3 IMPORTANT THEOREM IN THIS ARTICLE...7 3. MINIMUM SPANNING TREE...8 3. RELATED ALGORITHMS TO MINIMUM SPANNING TREE...8 3. MINIMUM SPANNING TREE APPLICATIONS... 4. SHORTEST PATH PROBLEM...3 4. DIJKSTRA S ALGORITHM...3 4. EXAMPLE...3 5. CHINESE POSTMAN PROBLEM...6 5. FLEURY S ALGORITHM...6 5. EXAMPLE OF CHINESE POSTMAN PROBLEM...7 6. THE TRAVELLING SALESMAN PROBLEM (TSP)...0 6. HARDNESS OF HAMILTON CIRCUIT...0 6. THE CLOSEST INSERTION ALGORITHM...0 6.3 PROGRESS ON TSP METHOD... 6.4 SWEDEN TOUR... 7. SUMMARY...3 8. REFERENCES...4
. Introution People in Königserg ity (now Kliningr, Russi) trie to evise route roun the ity whih woul ross eh of seven riges just one. Sine their ttempts h lwys file, mny of them elieve tht the tsk ws impossile, ut it ws not until 736 when one of the leing mthemtiins of the time, Leonhr Euler, prove it. He wrote n rtile in whih he not only elt with this prtiulr prolem, ut lso gve generl metho for other prolems of the sme type. This prolem llowe fountion of grph theory. Sine then, it hs evelope with Euler n other mthemtiins n it s still ynmi prt of isrete mthemti. Grph theory hs surprising numer of pplitions: in physis, iology, hemistry, soil, ommere, n omputer siene. In this rtile I will tret the route prolems. First we tke look t some si of grph theory, n then we will isuss minimum spnning trees. Finlly we will el with shortest pth prolems n ifferent iruits in route prolem.
. Bsi grph theory. Definition n grph representtion Definition: A grph G = (V, E) mens pir (V, E) onsisting of finite non- empty set V of verties (lle lso points, noes, or just ots), n finite set E of eges, where some pir of verties is onnete y one or more eges. Exmple: Here we hve grph G with verties V = {,,,, e, f} n the eges E = {e, e, e 3, e 4, e 5, e 6, e 7, e 8, e 9, e 0, e, e } e e 8 f e 7 e e e9 e 0 e e 5 e e 3 e 4 e 6 A grph n e represente s igrm or s mtrix ut in this rtile it will e only igrm representtion. There re three ifferent kins of grphs: An unirete grph is grph in whih ny pths in the grph hve no speifi iretion. Exmple: The following grph is unirete. Let e enote G. A irete grph is grph whih ny pth in the grph hve speifi iretion. Exmple: The elow grph is irete n we nme it G 3.
A mixe grph is grph whih omines oth unirete n irete properties. Here oming n exmple of mixe grph G 4.. More efinitions Definition: Two verties (v, v ) re jent (neighours) if they re joine y the sme ege e n the ege e is si to e inient with the verties (v, v ). If we tke grph G s exmple the vertex in grph G is neighour of four verties (,,, f) n is only neighour of two verties (, ). Definition: The egree of vertex is the numer of eges tht re inient with this vertex. For exmple vertex in grph G hs egree four n hs egree three. Definition: A loop is n ege whih joins one vertex to itself. Exmple: in grph G we hve only one loop nmely the ege e. Definition: Prllel eges re two or more ifferent eges whih join the sme pir of verties. Exmple: In the Grph G only two pir eges re prllel: (e, e 3 ) n (e 5, e 6 ). Definition: A simple grph is grph whih ontins no loops n no prllel eges. Definition: A weighte grph is grph whih every ege in the grph is represente y numer lle its weight. Definition: A Pth (wlk) is sequene of eges. In grph G we hve mny ifferent pths ut we only gve two exmples: e e 0 e 5 e 7, e e 8 e 7 e 6 e 4. Definition: A iruit (yle or tour) is pth in whih the strt n en vertex is the sme. In grph G e e 8 e 7 e 6 e 4 e e is iruit. Definition: An Euler iruit is iruit whih ontins every ege of the given grph one n only one. Definition: A Hmilton iruit is iruit whih ll verties in grph our one n only one.
Definition: A omplete grph is simple unirete grph whih ll ifferent pir of its verties is joine y n ege. Definition: A tree is n unirete simple grph whih ontins no iruits. Exmple of tree: Definition: A onnete grph is grph in whih ny pir of verties in the grph n e oune y one or more eges. All previous exmple grphs re onnete. Definition: A rige ege in grph is n ege suh tht if we elete it then the grph woul not e onnete nymore. Exmple: ll eges for ny tree re riges. Definition: A su-grph of grph G = (V, E), is grph G = (V, E ) where V n E re suset of V n E respetively. For exmple the following grphs re su-grph of G..3 Importnt theorem in this rtile The Hnshking theorem: For ny grph G = (V, E): eg (v) = e where eg mens vertex egree. Proof: Let v n v e jent verties in grph join y n ege e, eg (v ) = eg (v ) = n eg (v ) + eg (v ) = e. This is not n exeption for v n v ut it works for every pir jent verties in the grph. This mens tht eg (v) = e. Euler theorem: A onnete grph G is Euler if n only if the egree of every vertex is even. Proof: Let G = (V, E) e grph with only even verties egree. Choose ny strt vertex v n tre out pth ritrrily suh tht every ege in grph must e hosen one n only one. Sine even-vertex egree onition ssures tht eh vertex rrive t n e left, the pth must e inevitle finish to v. So it is ler tht the iruit is Euler.
3. Minimum spnning tree Given n unirete onnete weighte grph G, minimum spnning tree of G is onnete tree G su-grph of G tht ontins ll the verties of G n where the sum of its weight is smll numer s possile. 3. Relte lgorithms to minimum spnning tree In this prt we tke look just two fmous lgorithms: Kruskl s lgorithm n Prim s lgorithm. These two lgorithms help to fin minimum spnning tree. We strt with Kruskl s lgorithm. Kruskl s lgorithm uils minimum spnning tree y ing smllest eges y sening of its weight. Metho: Selet the eges e i of G whih hve smllest weight mong the eges of G. e i oes not form loop n yle. A the other eges e j y sening of its weight. The eges e j must stisfy follow onitions: (i) Hve smllest weight (ii) Hve not lrey een hosen (iii) Do not form yle with the simple pth solution. Continue to other eges with the sme proeure. 3 If G hs n numer of verties, stop fter n- eges hve een hosen. Prim s lgorithm uils minimum spnning tree y one ege t the time. Metho:. Choose ny vertex v of the grph G n let v e the strt vertex.. Selet vertex v of G neighour with v suh tht v n v join y n ege with the smllest weight (If mny verties neighour hve eges with sme weight, selet just one t rnom). 3. First hoose verties of G neighour with verties whih form pth solution {v, v }, selet one vertex v 3 whih is lose s possile to the pth solution. The vertex v 3 hve not lrey een hosen in solution. A the other verties with the sme proeure. 4. If G hs n numer of verties, stop fter n- eges hve een hosen.
Exmple: Fin the minimum spnning tree for the following grph: 3 4 5 e 6 Kruskl s lgorithm Prim s lgorithm. Choose eges with the smllest weight n these eges on t form yle. In given figure re n =. So E s = {, } 3 6 4 e 5. A other eges with smllest weight whih re not E s in n not form yle. The ege form yle, we n not hoose it. So we selet only =. {,, } eome new tree solution. Choose ny strt point in figure, let e the strt point. V s = {}. We selet the nerest vertex to V s = {}, in grph the nerest vertex is. So {} eome our tree solution. 4 3 5 e 6 3 4 5 e 6
3. A other eges with the sme proeure in point. We get e = 3 so E s = {,,, e } 4. We stop for the numer of eges is equl to 5 - = 4 (where 5 re totl numer of verties). So {,,, e} is tree solution tht we hve een looking for. 3 6 4 3 5 e e 3. We vertex with the sme proeure in point. Then we hve {, } like our new tree solution. 3 4 4. We follow the sme proeure n we get the following tree solution {,, } 5 e 6 3 4 6 5 e 5. The nerest vertex to V s = {,, } is e n we hve V s = {,,, e}. Now the numer of eges is equl to 5 - = 4 (where 5 re totl numer of verties), we stop n we hve the following tree solution. 3 e
3. Minimum spnning tree pplitions A hef of Communition Compny wnts to instll his ompny in the Småln provine. The prolem is to onnet ll ities in the provine. They wish tht the istne of ities onnetion will e s short s possile, in orer to erese uget mteril. They nee to know lso how long istne etween the ities is in totlly in orer to uy neessry mterils. This prolem will e solve y grph theory. First we rw grph etween ll the ities. Then we pply speifi lgorithm to onnet ll ities in the provine. We hoose Kruskl s lgorithm n get the following solution.
An istne is equl to 34 km, Prolem solve.
4. Shortest pth prolem Short pth prolems onsist to etermine minimum weight pth etween two or more speifie verties. For exmple we use short pth prolems to fin shortest route etween two or more speifie ities. We tke look for one lgorithm whih reltes to shortest pth prolems. This fmous lgorithm is lle Dijkstr s lgorithm. 4. Dijkstr s lgorithm For ny positive weighte grph, Dijkstr s lgorithm llows us to fin shortest pth etween two or more speifie verties. This lgorithm works for unirete, irete, n mixe grphs. Metho: Let L e weight of shortest pth in solution from given strt vertex, M weight of ege etween the en vertex of L to its neighour verties in grph, n K = L + M.. Strt with n K () = 0, other verties in grph re unermine n we lel them.. Choose ll verties u neighour to n K (u) = L () + M (, u) n note their weight. Now vertex hs een visite. 3. Visit other verties of grph with the sme proeure in. If ny vertex hs or more K selet K with minimum weight. 4. If n- verties hve een visite stop (where n is numer of verties). 4. Exmple Use Dijkstr s lgorithm to fin the shortest pth from vertex to vertex i of the following grph. f 3 i 3 5 e g
We strt with L () = 0, other verties re unetermine n we lel. Verties e f g i v K (v ) 0 L () = 0. There re 4 verties neighor to :,,, n e. K () = L () + M (, ) = 0 + = K () = L () + M (, ) = 0 + = K () = L () + M (, ) = 0 + = K (e) = L () + M (, e) = 0 + 3 = 3 So hs een visite. Verties e f g i (v ) K (v ) 0 3 Now we hve unvisite verties n with shortest pth L () = L () =. Now we will visit n : There re unvisite verties n f neighor to vertex. K () = L () +M (, ) = + = 3 K (f) = L () +M (, f) = + =. There is only one unvisite vertex e neighor to vertex. K (e) = L () +M (, e) = + = < 3, we erese 3 to. Verties n hve een visite. Verties e f g i (v ) K (v ) 0 We got 3 unvisite verties n e with shortest pth L () = L (e) = L (f ) = n will visit it. We strt with vertex, there re unvisite verties e n f neighor to vertex. K (e) = L () + M (, e) = + = 4 > we remin K (f) = L () + M (, f) = + = 3 > we remin Then we tke vertex e. There re unvisite verties f n g neighor to e. K (f) = L (e) + M (e, f) = + = 3 > we remin K (g) = L (e) + M (e, g) = + = 4 Finlly we visit vertex f. There unvisite verties g n i neighor to f. K (g) = L (f) + M (f, g) = + 5 = 7> 4 we remin 4 K (i) = L (f) + M (f, i) = + 3 = 5. Verties, e, n f hve een visite.
Verties (v ) e f g i K (v ) 0 4 5 Now we hve left just one unvisite vertex g n L (g) = 4.There is only one unvisite vertex i neighor to vertex g. K (i) = L (g) + M (g, i) = 4 + = 6 > 5 we remin 5. Now we visite ll verties of grph n our pth solution is following: f 3 i 3 5 e g
5. Chinese postmn prolem In 96 Chinese mthemtiin Kun pulishe for ny given zone wy to turn one n only one ll street from given strt ple n ome k to this ple. It is ler tht Euler iruit is involve where the ities re verties n the streets re the eges. If ny given grph is not Euler, there is lwys possiility to uplite verties with o egree in orer to get n Euler grph. The terms uplite mens to prllel ege with the sme weight to ny given pir verties of grph. In orer to get short Euler iruit s possile we hve to fin miniml pth n uplite it. It is ler tht when we uplite we nee Dijkstr s lgorithm in orer to fin miniml pth. To fin n Euler iruit for ny given grph we my use fmous lgorithm whih is lle Fleury s lgorithm. Let just tke look for this lgorithm. 5. Fleury s lgorithm. Choose ny strt n en vertex v 0 of given Euler grph.. Choose mong verties neighour with v 0, selet one t rnom whih it is not rige. But if there is no hoie you hve to pik the rige. 3. Continue to eges with the sme proeure in n every ege hve to e hosen one n only one. 4. If ll eges of given grph hve een hosen stop. Exmple: for fining Euler iruit for following grph f 3 i 3 5 e g First we hek if this grph is Euler. We see tht the eges, f, e, n g hve o egree; oring to theorem the given grph is not n Euler grph. We hve to uplite these eges whih hve o egree. With help of Dijkstr s lgorithm, we uplite the ege (, f) n the (e, g) in orer to fin short iruit s possile. We get the following grph:
3 f 3 5 e g i Now it is time to hoose ny strt vertex. Let the vertex e strt n en vertex. With Fleury s lgorithm we fin the following Euler iruit: figefgeef. f 3 3 5 e g i 5. Exmple of Chinese postmn prolem The hefs in Småln me eision to renovte ll streets whih onnet Småln ities. It is ler tht they nee to know from their offier how they will trvel roun ll streets one n k to offier. Here grph theory pplies to fin short iruit s possile. We tke previous exmple. The following ities hve o egree: Växjö, Lesseo, Torss, Mönsterås, Sävsjö, Vetln, Hultsfre, Vimmery, Eksjö, Nässjö, Vggery, n Gnosjö. We nee Dijkstr s lgorithm for uplite short pth s possile in orer to fin shortest iruit. I get the following result:
Tke Jönköping s strt en ity of our serhing iruit. With help of Fleury s lgorithm we get the following iruit solution:
The eges re lelle in the orer in wht they re trverse uring the trip.
6. The trvelling slesmn prolem (TSP) TSP is se on Hmilton iruits. Given ny strt ity the ojetive of TPS is to visit ll ities one n only one n then return k to the strt ity n the iruit hs to e miniml s possile. To fin the shortest Hmilton iruit is lot more omplite thn it my pper. 6. Hrness of Hmilton iruit Firstly there is no theorem whih shows us tht given grph hs Hmilton iruit. Seonly no lgorithms gurntee tht foun Hmilton iruit is optiml. Finlly it tkes quite long time to fin Hmilton iruit. For exmple if grph is omplete with n numer of verties, we hve (n - )! / numer of ifferent possile iruit. The following tle shows how muh time the omputers tke to fin Hmilton iruit [3]: 5 8 0 5 8 0 verties iruit Time miroses 50.5 millises 8,440 0.8 ses 9,958,400 0 ses 87,78,9,00. hours 77,843,74,048,000 5.64 yers 60 8 550 04 46 000 97 yers One lgorithm whih n le us to fin n lmost optiml Hmilton iruit is lle insertion lgorithm. 6. The losest insertion lgorithm This lgorithm wlks for omplete grph. Let G = (V, E) e Hmiltonin grph. Choose ny strt vertex v of G. Selet one vertex v of G suh s the iruit v v v is short s possile. 3. Continue to verties with the sme proeure in. But from n 4 uil ifferent Hmilton iruit for exmple v v v 3 v 4 v ; v v v 4 v 3 v ; v v 4 v v 3 v ; selet the shortest iruit. 4. If ll verties hve een hosen stop.
Exmple: Fin Hmilton iruit for the following grph. e 4 5 3 6 5 6 9 7 4 We hoose = v s the strt vertex. The losest vertex to is vertex e = v. The next vertex losest to iruit solution is vertex = v 3. Now we hve the iruit e. We hve here vertex = v 4 losest to iruit e. Now we hve the following ifferent iruits: v v v 3 v 4 v = e hs length + 7 + 6 + 4 = 9 v v v 4 v 3 v = e hs length + 6 + 6 + 3 = 7 v v 4 v v 3 v = e hs length 4 + 6 + 7 + 3 = 0 The iruit e is smllest n the vertex = v 5 is losest to the iruit. We hve the following ifferent iruits: v v v 3 v 4 v 5 v = e hs length + 6 + 6 + 4 + 5 = 3 v v v 3 v 5 v 4 v = e hs length + 6 + 9 + 4 + 3 = 4 v v v 5 v 3 v 4 v = e hs length + 5 + 9 + 6 + 3 = 5 v v 5 v v 3 v 4 v = e hs length 5 + 5 + 6 + 6 + 3 = 5 So our optiml Hmilton iruit is e: e 5 6 6 4 The lgorithm gives us the iruit solution e = 3 s n optiml Hmilton iruit ut it miss for exmple the iruit e = whih is smller thn the lgorithm iruits solution.
6.3 Progress on TSP metho Nevertheless gret progress hs een one espite TSP hrness. Reserh llowe some effetive metho whih n solve prolem with severl ities. These methos re following [3]: Met-heuristis tht n otin upper ouns within 0.0% of optiml even when n =,000,000. This metho solve 4- ity prolem in USA 954 ( Cutting-plne methos tht n otin lower ouns within 0.% of optiml for n up to 00,000 or so. This metho n the next oth solve the Sween tour in 004, see setion 6.4 elow Brnh-n-ut methos tht n solve instnes with n up to 0.000 to proven optimlity. 6.4 Sween tour The Sween tour is 4.978 -ities prolem whih ws solve in My 004 y the following Reserh Tem: Dvi Applegte, AT&T Ls - Reserh Roert Bixy, ILOG n Rie University Všek Chvátl, Rutgers University Willim Cook, Georgi Teh Kel Helsgun, Roskile University This tour is pproximtely 7.500 km long n it took one yer n two months to fin the solution. They use rnh- n-ut n utting-plnes metho to solve this prolem. The iruit hs een roken in 00 legs. Let us see some legs of the tour [4]: Legs Numer of ities Distne (km) Stokholm to Soertlje 66 507 Soertlje to Uppsl 5 67 3 Uppsl to Sigtun 4 87 4 Sigtun to Hofors 596 365 5 Hofors to Heemor 60 44
7. Summry In this rtile we hve seen how mny lgorithm works. Some lgorithms yiel the sme result ut their proeures to otin the solution re ifferent. In this se we hve for exmple Prim s lgorithm n Kruskl s lgorithm. The ig ifferene is tht for Prim s lgorithm we just one ege t the time ut in Kruskl s lgorithm we n one or more t the time. Other ifferene is tht in omputer Prim s lgorithm is usully fster thn Kruskl s ut y hn it is ler tht the opposite hols. We took lso look to Dijkstr s lgorithm whih llow us to fin not only shortest pth etween two speifi verties, it lso llow us to get shortest pth from ny given strt vertex to ny vertex in grph. It is well remrkle tht this lgorithm gives sme result s GPS. This lgorithm my e le to e use in GPS systems. Finlly we oserve two ifferent iruits. Euler iruits re esy to etermine whether grph hs n Euler iruit is esy, s well s to fin suh iruit euse there is speifi theorem to Euler grph n lgorithm whih gurntee to fin n Euler iruit. Even if grph hs not Euler iruit there is possile to get it y uplite the verties with o egree in grph. In opposite for Hmilton iruit there is neither theorem nor lgorithm like in Euler iruit whih gurntee us tht grph hs Hmilton iruit or tht given Hmilton iruit is optiml. Nevertheless the mthemtiins keep serhing n the Sween tour shows tht there is some goo progress in fining minimum Hmilton iruits.
8. Referenes [] John Clrk, Derek Alln Holton. A first look t grph theory. Deprtment of Mthemtis n Sttistis University of Otgo (New Zeln) [] Vsuev, C. Grph theory with pplitions. New Delhi, 006. [3] http://www.lns..uk/stff/lethfo/tsp 0--. [4] http://www.tsp.gteh.eu 0- -.
SE-39 8 Klmr / SE-35 95 Växjö Tel +46 (0)77-8 80 00 fm@lnu.se Lnu.se/fm