Discrete Mathematics with Graph Theory (3rd Edition) 348

Discrete Mathematics with Graph Theory (3rd Edition) 348 -...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
346 Solutions to Exercises od: #Since we assume the given digraph has a cycle, #eventually found=1 u := vector(n+l): #the vertices of V contain a cycle #because each has indegree 1. #We just have to find it u[l] := V[I]: U.-{u[I]}: k := 1: j := 1: while (j<=n) do od: if ((member(j,V)=true) and (A[j,u[k]]=I)) then fi: u[k+l] := j: #if there is an arc from j to u[k] #with j in V, then j is the next #vertex on the desired cycle if(member(u[k+l],U)=true) then j .- n+l: else fi: U .- U union {j}: V .- V minus {j}: k .- k+l: j .- 0: j .- j+l: > j := k: #since u[k+l] is first repeated vertex #of U, there is a cycle from u[j]=u[k+l] #to u[k+l], we just have to find j > while(u[j]<>u[k+l]) do j := j - 1: od: > S:= seq(u[i], i=j .. k+l): > lprint(/Here's a cycle: / , S); 6. There are two versions of an algorithm by Dijkstra for computing the shortest distance from a specified
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: vertex in a graph to every other vertex in weighted graph. These were described in Section 10.4. The Floyd-Warshall algorithm (discussed in the same section) computes the shortest distances between every pair of vertices in a (weighted) graph. In Section 11.2, we discussed the Bellman-Ford algorithm which finds the shortest path from a specified vertex to every other vertex in a weighted digraph devoid of negative weight cycles. In this section, we learned about Bellman's algorithm, which determines the shortest distance from a specified vertex in an acyclic digraph to every other vertex. 7. [BB] Since the undirected graph is a tree with n vertices, T has n - 1 arcs, by Theorem 12.1.6. 8. The answer is no. The digraph shown has a unique vertex v of indegree o but it is not a rooted tree because the unoriented graph has a cycle....
View Full Document

This note was uploaded on 11/08/2010 for the course MATH discrete m taught by Professor Any during the Summer '10 term at FSU.

Ask a homework question - tutors are online