4/25/12 Outlin Prt 10. Grphs CS 200 Algorithms n Dt Struturs Introution Trminology Implmnting Grphs Grph Trvrsls Topologil Sorting Shortst Pths Spnning Trs Minimum Spnning Trs Ciruits 1 2 Eulr s rig prolm (Brigs of Konigsrg Prolm) Ciruits Rivr Btwn Eg Bnk D A An Cyl Eg Btwn Eg Btwn A n CA n C A spil yl tht psss through vry vrtx (or g) in grph xtly on n rturns k to th pl it strt. Eg Btwn Isln C C n D Isln D Eg Btwn Rivr Eg Btwn B n Eg C Btwn B n D Bnk B n C B Eulr Is it possil to trvl ross vry rig without rossing ny rig mor thn on? hmp://yskrthi.worprss.om/2006/07/31/ulr- n- th- rigs- of- konigsrg Eulr s rig prolm (Brigs of Konigsrg Prolm) 4 Eulr pths/iruits Eulr pth: A pth tht visits h g only on in th grph Eulr iruit: A yl tht visits h g only on in th grph Eulr Is it possil to trvl ross vry rig without rossing ny rig mor thn on? hmp://yskrthi.worprss.om/2006/07/31/ulr- n- th- rigs- of- konigsrg 5 1
Exmpl: Dos ny grph hv n Eulr iruit? Exmpl: Dos ny grph hv n Eulr pth? 7 8 Exmpl: Dos ny grph hv n Eulr iruit? Eulr pths/iruits f g Is thr simpl ritrion tht llows us to trmin whthr grph hs n Eulr iruit or pth? 9 Eulr Pths Eulr Ciruits Thorm: A onnt multigrph hs n Eulr pth iff it hs xtly two vrtis of o gr Thorm: A onnt multigrph with t lst two vrtis hs n Eulr iruit iff h vrtx hs n vn gr. 2
Mohmm s Simitrs Hmiltonin Pths/Ciruits f Cn Mohmm s simitrs rwn without lizing pnil n th rwing gins n ns t th sm point? i g h j k A Hmiltonin pth/iruit: pth/iruit tht visits vry vrtx xtly on. Dfin for irt n unirt grphs. Is thr n ffiint wy to trmin whthr grph hs Hmiltonin iruit? - - f- i- - - - - g- h- j- i- k- g- - - 13 Dos ny grph hv Hmilton iruit or Hmilton pth? DIRAC s Thorm If G is simpl grph with n vrtis with n 3 suh tht th gr of vry vrtx in G is t lst n/2, thn G hs Hmilton iruit. 15 16 Or s Thorm Hmiltonin Pths/Ciruits If G is simpl grph with n vrtis with n 3 suh tht g(u)+g(v) n for vry pir of nonjnt vrtis u n v in G, thn G hs Hmilton iruit. Dir n Or s thorms provi suffiint onition for onnt simpl grph to hv Hmilton iruit. Thy o NOT provi nssry onition for th xistn of Hmilton iruit This prolm longs to lss of prolms for whih it is liv thr is no ffiint (polynomil running tim) lgorithm. 17 3
4/25/12 Th Trvling Slsmn Prolm (TSP) Exmin ll possil Hmilton iruits n slt on of minimum totl lngth With n itis.. TSP: Givn list of i^s n thir pirwis istns, fin shortst possil tour tht visits h ity xtly on. (n-1)! Diffrnt Hmilton iruits Ignor th rvrs orr iruits (n-1)!/2 13,509 i^s n towns in th US tht hv mor thn 500 rsints An op^ml TSP tour through Grmny s 15 lrgst i^s (on out of 14!/2) With 50 itis 12,413,915,592,536,072,670,862,289,04 7,373,375,038,521,486,354,677,760,000, 000,000 routs hmp://www.tsp.gth.u/ 20 Th thr u^li^s prolm Hous A Using Hmilton Ciruits Hous B? Plnr Grphs You r signing mirohip onntions twn ny two units nnot ross Hous C 21 Plnr Grphs You r signing mirohip onntions twn ny two units nnot ross Th grph sriing th hip must plnr hmp://www.mom.org/ Is this grph plnr? plnr non- plnr hmp://n.wikipi.org/wiki/plnr_grph 24 4
Chip Dsign You wnt mor thn plnrity: th lngths of th onntions n to s short s possil (fstr, n lss ht is gnrt) hmp://www.mom.org/ 5