Counting Paths Between Vertices. Isomorphism of Graphs. Isomorphism of Graphs. Isomorphism of Graphs. Isomorphism of Graphs. Isomorphism of Graphs

Similar documents
Solutions for HW9. Bipartite: put the red vertices in V 1 and the black in V 2. Not bipartite!

Graph Theory. Simple Graph G = (V, E). V={a,b,c,d,e,f,g,h,k} E={(a,b),(a,g),( a,h),(a,k),(b,c),(b,k),...,(h,k)}

CS 491G Combinatorial Optimization Lecture Notes

Mid-Term Examination - Spring 2014 Mathematical Programming with Applications to Economics Total Score: 45; Time: 3 hours

1 PYTHAGORAS THEOREM 1. Given a right angled triangle, the square of the hypotenuse is equal to the sum of the squares of the other two sides.

Lecture 6: Coding theory

CIT 596 Theory of Computation 1. Graphs and Digraphs

Lecture 2: Cayley Graphs

18.06 Problem Set 4 Due Wednesday, Oct. 11, 2006 at 4:00 p.m. in 2-106

Lecture 4: Graph Theory and the Four-Color Theorem

CSE 332. Sorting. Data Abstractions. CSE 332: Data Abstractions. QuickSort Cutoff 1. Where We Are 2. Bounding The MAXIMUM Problem 4

Euler and Hamilton Paths

22: Union Find. CS 473u - Algorithms - Spring April 14, We want to maintain a collection of sets, under the operations of:

Connectivity in Graphs. CS311H: Discrete Mathematics. Graph Theory II. Example. Paths. Connectedness. Example

Minimal DFA. minimal DFA for L starting from any other

Surds and Indices. Surds and Indices. Curriculum Ready ACMNA: 233,

Algebra 2 Semester 1 Practice Final

Factorising FACTORISING.

CS 2204 DIGITAL LOGIC & STATE MACHINE DESIGN SPRING 2014

Algorithms & Data Structures Homework 8 HS 18 Exercise Class (Room & TA): Submitted by: Peer Feedback by: Points:

I 3 2 = I I 4 = 2A

Data Structures LECTURE 10. Huffman coding. Example. Coding: problem definition

Total score: /100 points

CS261: A Second Course in Algorithms Lecture #5: Minimum-Cost Bipartite Matching

Numbers and indices. 1.1 Fractions. GCSE C Example 1. Handy hint. Key point

Arrow s Impossibility Theorem

Implication Graphs and Logic Testing

CS311 Computational Structures Regular Languages and Regular Grammars. Lecture 6

2.4 Theoretical Foundations

CS 573 Automata Theory and Formal Languages

Necessary and sucient conditions for some two. Abstract. Further we show that the necessary conditions for the existence of an OD(44 s 1 s 2 )

Section 1.3 Triangles

Graph Algorithms. Vertex set = { a,b,c,d } Edge set = { {a,c}, {b,c}, {c,d}, {b,d}} Figure 1: An example for a simple graph

NON-DETERMINISTIC FSA

Nondeterministic Finite Automata

Discrete Structures, Test 2 Monday, March 28, 2016 SOLUTIONS, VERSION α

Area and Perimeter. Area and Perimeter. Solutions. Curriculum Ready.

PYTHAGORAS THEOREM WHAT S IN CHAPTER 1? IN THIS CHAPTER YOU WILL:

Logic, Set Theory and Computability [M. Coppenbarger]

Intermediate Math Circles Wednesday, November 14, 2018 Finite Automata II. Nickolas Rollick a b b. a b 4

Project 6: Minigoals Towards Simplifying and Rewriting Expressions

p-adic Egyptian Fractions

The DOACROSS statement

Finite State Automata and Determinisation

Discrete Structures Lecture 11

CS241 Week 6 Tutorial Solutions

Particle Physics. Michaelmas Term 2011 Prof Mark Thomson. Handout 3 : Interaction by Particle Exchange and QED. Recap

Exercise sheet 6: Solutions

Chapter 4 State-Space Planning

Regular expressions, Finite Automata, transition graphs are all the same!!

Lecture 2: January 27

Section 2.1 Special Right Triangles

I1 = I2 I1 = I2 + I3 I1 + I2 = I3 + I4 I 3

If the numbering is a,b,c,d 1,2,3,4, then the matrix representation is as follows:

Convert the NFA into DFA

for all x in [a,b], then the area of the region bounded by the graphs of f and g and the vertical lines x = a and x = b is b [ ( ) ( )] A= f x g x dx

Arrow s Impossibility Theorem

6.5 Improper integrals

Math Lecture 23

Section 2.3. Matrix Inverses

Automata and Regular Languages

Now we must transform the original model so we can use the new parameters. = S max. Recruits

where the box contains a finite number of gates from the given collection. Examples of gates that are commonly used are the following: a b

Something found at a salad bar

SIMPLE NONLINEAR GRAPHS

First Midterm Examination

On a Class of Planar Graphs with Straight-Line Grid Drawings on Linear Area

Subsequence Automata with Default Transitions

First Midterm Examination

How do we solve these things, especially when they get complicated? How do we know when a system has a solution, and when is it unique?

For a, b, c, d positive if a b and. ac bd. Reciprocal relations for a and b positive. If a > b then a ab > b. then

CARLETON UNIVERSITY. 1.0 Problems and Most Solutions, Sect B, 2005

COMPUTING THE QUARTET DISTANCE BETWEEN EVOLUTIONARY TREES OF BOUNDED DEGREE

On the Spectra of Bipartite Directed Subgraphs of K 4

Monochromatic Plane Matchings in Bicolored Point Set

Comparing the Pre-image and Image of a Dilation

15-451/651: Design & Analysis of Algorithms December 3, 2013 Lecture #28 last changed: November 28, 2013

Bases for Vector Spaces

Surface maps into free groups

System Validation (IN4387) November 2, 2012, 14:00-17:00

Maximum size of a minimum watching system and the graphs achieving the bound

CS 360 Exam 2 Fall 2014 Name

CS 275 Automata and Formal Language Theory

Probability The Language of Chance P(A) Mathletics Instant Workbooks. Copyright

Lecture 8: Abstract Algebra

Global alignment. Genome Rearrangements Finding preserved genes. Lecture 18

The Word Problem in Quandles

= state, a = reading and q j

Common intervals of genomes. Mathieu Raffinot CNRS LIAFA

Pre-Lie algebras, rooted trees and related algebraic structures

Momentum and Energy Review

Computational Biology Lecture 18: Genome rearrangements, finding maximal matches Saad Mneimneh

Graph States EPIT Mehdi Mhalla (Calgary, Canada) Simon Perdrix (Grenoble, France)

Prefix-Free Regular-Expression Matching

50 AMC Lectures Problem Book 2 (36) Substitution Method

Intermediate Math Circles Wednesday 17 October 2012 Geometry II: Side Lengths

A Short Introduction to Self-similar Groups

12/3/12. Outline. Part 10. Graphs. Circuits. Euler paths/circuits. Euler s bridge problem (Bridges of Konigsberg Problem)

The University of Nottingham SCHOOL OF COMPUTER SCIENCE A LEVEL 2 MODULE, SPRING SEMESTER MACHINES AND THEIR LANGUAGES ANSWERS

Equivalent fractions have the same value but they have different denominators. This means they have been divided into a different number of parts.

Transcription:

Isomorphism of Grphs Definition The simple grphs G 1 = (V 1, E 1 ) n G = (V, E ) re isomorphi if there is ijetion (n oneto-one n onto funtion) f from V 1 to V with the property tht n re jent in G 1 if n only if f() n f() re jent in G, for ll n in V 1. Suh funtion f is lle n isomorphism. In other wors, G 1 n G re isomorphi if their verties n e orere in suh wy tht the jeny mtries M G1 n M G re ientil. Isomorphism of Grphs From visul stnpoint, G 1 n G re isomorphi if they n e rrnge in suh wy tht their isplys re ientil (of ourse without hnging jeny). Unfortuntely, for two simple grphs, eh with n verties, there re n! possile isomorphisms tht we hve to hek in orer to show tht these grphs re isomorphi. However, showing tht two grphs re not isomorphi n e esy. Nov 1 CS 3 1 Nov 1 CS 3 Isomorphism of Grphs For this purpose we n hek invrints, tht is, properties tht two isomorphi simple grphs must oth hve. For exmple, they must hve the sme numer of verties, the sme numer of eges, n the sme egrees of verties. Note tht two grphs tht iffer in ny of these invrints re not isomorphi, ut two grphs tht mth in ll of them re not neessrily isomorphi. Nov 1 CS 3 3 Isomorphism of Grphs I Are the following two grphs isomorphi? e e Solution Yes, they re isomorphi, euse they n e rrnge to look ientil. You n see this if in the right grph you move vertex to the left of the ege {, }. Then the isomorphism f from the left to the right grph is f() = e, f() =, f() =, f() =, f(e) =. Nov 1 CS 3 Isomorphism of Grphs II How out these two grphs? e Solution No, they re not isomorphi, euse they iffer in the egrees of their verties. Vertex in right grph is of egree one, ut there is no suh vertex in the left grph. Nov 1 CS 3 e Counting Pths Between Verties Theorem (p. 88, p. 8 th e.). Suppose G is grph with verties {v 1,v,,v n } n A is the nxn jeny mtrix of G. G n e irete or unirete n multiple eges n loops re llowe. Then the (i,j) th entry of A r is the numer of ifferent pths of length r from v i to v j. Nov 1 CS 3 1

Proof We use inution on r, pth length. Bse Cse r=1. True y efinition of the jeny mtrix A = A 1. A ij = the numer of eges from v i to v j. Inution Step. Suppose true for r-1. (A r ) ij = k=1n (A r-1 ) ik * A kj. Eh term of the sum represents the numer of pths of length r-1 from v i to v k, multiplie y the numer of eges from v k to v j. The sum of these over k is extly the numer of pths of length r from v i to v j. Counting pths etween verties Rell we hve seen this theorem efore, when we were looking t trnsitive losures of reltions, t lest for the se of grphs without multiple eges. Nov 1 CS 3 7 Nov 1 CS 3 8 Use the jeny mtrix A G for the following grph G se on the orer of verties,,,, to ompute pths of vrious lengths in the grph. There re no pths of length > 3. Shortest Pth Prolems We n ssign weights to the eges of grphs, for exmple to represent the istne etween ities in rilwy network Chigo 7 Toronto Boston New York Nov 1 CS 3 9 Nov 1 CS 3 1 Shortest Pth Prolems Suh weighte grphs n lso e use to moel omputer networks with response times or osts s weights. One of the most interesting questions tht we n investigte with suh grphs is Wht is the shortest pth etween two verties in the grph, tht is, the pth with the miniml sum of weights long the wy? This orrespons to the shortest trin onnetion or the fstest onnetion in omputer network. Dijkstr s lgorithm is n itertive proeure tht fins the shortest pth etween two verties n in weighte grph. It proees y fining the length of the shortest pth from to suessive verties n ing these verties to istinguishe set of verties S. The lgorithm termintes one it rehes the vertex. Nov 1 CS 3 11 Nov 1 CS 3 1

proeure Dijkstr(G weighte onnete simple grph with verties = v, v 1,, v n = n positive weights w(v i, v j ), where w(v i, v j ) = if {v i, v j } is not n ege in G) for i = 1 to n L(v i ) = L() = S = {the lels re now initilie so tht the lel of is ero n ll other lels re, n the istinguishe set of verties S is empty} while S egin u = vertex not in S with miniml L(u) S = S {u} for ll verties v not in S if L(u) + w(u, v) < L(v) then L(v) = L(u) + w(u, v) {this s vertex to S with miniml lel n uptes the lels of verties not in S} en {L() = length of shortest pth from to } Nov 1 CS 3 13 Nov 1 CS 3 1 () 1 8 3 1 e Step Nov 1 CS 3 1 1 8 3 1 () e Step 1 Nov 1 CS 3 1 3 (, () ) 1 (, ) 3 (, () ) 1 8 (,, ) ) 1 8 3 1 () e 1 (, ) Step Nov 1 CS 3 17 1 8 3 1 () e 1 (, ) Step 3 Nov 1 CS 3 18 3

3 (, () ) 1 8 (,, ) ) 3 (, () ) 1 8 (,, ) ) 1 8 3 Step 1 (,,, ) 1 () e 1 1 (, ),, ) Nov 1 CS 3 19 1 8 3 13 1 (, (,,,,,, ) e) 1 () e 1 1 (, ),, ) Step Nov 1 CS 3 Step 1 3 (, () ) 1 8 (,, ) ) () 8 1 1 13 (, (,,,,,, ) e) e 1 1 (, ),, ) Nov 1 CS 3 1 3 Theorem Dijkstr s lgorithm fins the length of shortest pth etween two verties in onnete simple unirete weighte grph. Theorem Dijkstr s lgorithm uses O(n ) opertions (itions n omprisons) to fin the length of the shortest pth etween two verties in onnete simple unirete weighte grph. Plese tke look t pges 79 to 71 ( th e. 1 to 3) for the ook s tretment of Dijkstr s lgorithm. Nov 1 CS 3 Proof tht works proeure Dijkstr(G verties = v, v 1,, v n =, w(v i, v j )>, w(v i, v j ) = if {v i, v j } not n ege in G) for i = 1 to n {L(v i ) = ;L() = ;S = } // loop invrint v S, L(v) = length of shortest pth in G from to v, n u S, L(u) = length of shortest pth to u, suh tht ll verties in the pth exept u re in S. while S egin u = vertex not in S with miniml L(u) S = S {u} for ll verties v not in S if L(u) + w(u, v) < L(v) then L(v) = L(u) + w(u, v) en // n psses through the loop, t most n opertions eh. {L() = length of shortest pth from to } Nov 1 CS 3 3 Fining the shortest pth We n moify Dijkstr s lgorithm to fin not just the length of the shortest pth, ut the pth itself. For eh vertex v, keep list of the shortest pth so fr to v, s list of verties. Initilly L(v) = n the list is empty. Eh time we reset L(v) y L(v) = L(u) + w(u, v) we reset v s list to e u s list followe y v Nov 1 CS 3

The Trveling Slesmn Prolem The trveling slesmn prolem is one of the lssil prolems in omputer siene. A trveling slesmn wnts to visit numer of ities n then return to his strting point. Of ourse he wnts to sve time n energy, so he wnts to etermine the shortest pth for his trip. We n represent the ities n the istnes etween them y weighte, omplete, unirete grph. The prolem then is to fin the iruit of minimum totl weight tht visits eh vertex extly one. Nov 1 CS 3 The Trveling Slesmn Prolem Wht pth woul the trveling slesmn tke to visit the following ities? Chigo 7 Toronto 7 New York Boston Solution The shortest pth is Boston, New York, Chigo, Toronto, Boston (, miles). Nov 1 CS 3 The Trveling Slesmn Prolem Question Given n verties, how mny ifferent yles C n n we form y onneting these verties with eges? Solution We first hoose strting point. Then we hve (n 1) hoies for the seon vertex in the yle, (n ) for the thir one, n so on, so there re (n 1)! hoies for the whole yle. However, this numer inlues ientil yles tht were onstrute in opposite iretions. Therefore, the tul numer of ifferent yles C n is (n 1)!/. Nov 1 CS 3 7 The Trveling Slesmn Prolem Unfortuntely, no lgorithm solving the trveling slesmn prolem with polynomil worst-se time omplexity hs yet een evise. This mens tht for grphs with lrge numer of verties, solving the trveling slesmn prolem is imprtil. In these ses, we n use pproximtion lgorithms tht etermine pth whose length my e slightly lrger thn the trveling slesmn s pth, ut n e ompute with polynomil time omplexity. For exmple, rtifiil neurl networks n o suh n effiient pproximtion tsk. Nov 1 CS 3 8 The Kőnigserg rige prolem (se 1.) The town of Kőnigserg h seven riges onneting prts of the ity. People wonere if one oul wlk over the riges, rossing eh rige extly one. See http//mthforum.org/is/prolems/riges1.html The Kőnigserg rige prolem This prolem ws solve y the Swiss mthemtiin Euler in 173. Perhps his ws the first result in grph theory. Nov 1 CS 3 9 Nov 1 CS 3 3

Euler iruits & pths Def. An Euler iruit is simple iruit ontining every ege of the grph. ( simple mens it oes not ontin the sme ege twie). Def. An Euler pth is simple pth ontining every ege of the grph. (en vertex my iffer from strt vertex) Euler iruits Theorem 1 (p. 9, th e. p. 3) A onnete multigrph with t lest two verties hs n Euler iruit iff eh vertex hs even egree. Proof This is simple ut powerful result, n it s not hr to see why it s true Nov 1 CS 3 31 Nov 1 CS 3 3 If the grph hs n Euler iruit then eh time the iruit enters vertex there must e nother ege for it to leve. The exeption is the strt vertex. When the pth enters this vertex t the en of the iruit the mthing ege is the first ege on the pth. En of proof of Theorem 1, p 9 Conversely, if every vertex hs even egree, if we strt pth t n ritrry vertex n keep going s long s possile, seleting only unuse eges, we will hve to stop only when we get to the strt vertex. This is euse every vertex hs even egree, so if there is wy in, there is wy out. If we hve use every ege we re one. If we hve not use every ege, strt nother pth t the first vertex, u, on our route tht hs n unuse ege. If we keep going s long s possile we ll en t u. We n this new pth to our originl one, tking it the first time we visit u. Repeting this proess we ll onstrut iruit whih uses every ege in the grph extly one, n is thus n Euler iruit. Nov 1 CS 3 33 Nov 1 CS 3 3 Euler Pths Theorem (p. 97, th e. p. 37). A onnete multigrph hs n Euler pth ut not n Euler iruit iff it hs extly two verties of o egree. Note tht this theorem tells us tht the Kőnigserg rige prolem hs no solution. Proof of Th. Suppose we strt pth t one of the verties of o egree. If we one more ege, onneting oth verties of o egree then Th. 1 tells us we hve iruit. Removing this extr ege gives us n Euler pth. If we hve more thn two verties of o egree n oul onstrut n Euler pth we oul one extr ege n get n Euler iruit. But this woul ontrit Th. 1 sine we woul still hve verties of o egree. Nov 1 CS 3 3 Nov 1 CS 3 3