HW2_April2018_solutions.pdf

2 describe an algorithm to determine if g has an

Info icon This preview shows pages 2–4. Sign up to view the full content.

View Full Document Right Arrow Icon
2. Describe an algorithm to determine if G has an infinite path. Prove that it is correct. Solution: Claim 1. Inf ( p ) is a subset of a strongly-connected component We need to prove both ”existence” and ”uniqueness” of such a strongly- connected component: Existence: Let u, v be any arbitrary pair of vertices in the path p . There must be a path from u to v and v to u . Hence, the there must exist a strongly connected component C with size | C | ≥ Inf ( p ) Uniqueness: Suppose there exist one more strongly component contain- ing the vertices in Inf ( p ) Let C 0 be the a different strongly component which containing vertices Inf ( p ), u C v C 0 similarly, there must be paths be- tween u and v . Hence C 0 and C are also strongly connected and C = C 0 . contradiction. Hence, proven. Part(2): 1. Reverse G to G R O ( E ) = O ( V 2 ) 2. Do DFS on G R and select the node v with highest postvisit number O ( V + E ) O ( V 2 ) 2
Image of page 2

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
3. Explore from v and add the reachable nodes set S into SCCs 4. Remove S from G R : G R = G R - S and repeat 2 until G R = 5. If SCC 6 = return True (Any strongly connected component will contain Infinite path (from part1) ) 4. Suppose we have a directed graph with non-negative edge weights. It is possible for this graph to have multiple shortest paths between two nodes. In class, we saw how to find the length of the shortest path from a node s to all other nodes. Suppose that in addition to finding the length of these shortest paths, we also want to know how many shortest paths there are. Describe
Image of page 3
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern