/*! This file is auto-generated */ .wp-block-button__link{color:#fff;background-color:#32373c;border-radius:9999px;box-shadow:none;text-decoration:none;padding:calc(.667em + 2px) calc(1.333em + 2px);font-size:1.125em}.wp-block-file__button{background:#32373c;color:#fff;text-decoration:none} Q14E You are given a strongly connect... [FREE SOLUTION] | 91Ó°ÊÓ

91Ó°ÊÓ

You are given a strongly connected directed graph G=(V,E) with positive edge weights along with a particularv0∈V . Give an efficient algorithm for finding shortest paths between all pairs of nodes, with the one restriction that these paths must all pass throughv0 .

Short Answer

Expert verified

All Pairs Shortest Path Algorithm is used to find the shortest distance between all pairs of nodes in a graph.

Step by step solution

01

Floyd-Warshall Algorithm

The algorithm is used to compute the shortest distance between every pair of vertices in a weighted graph. A graph with all edges having a numerical weight is called a Weighted graph.

02

Shortest distance Algorithm

The algorithm to find the shortest path between i and j through a particular vertex between all pairs is:

for all (i,j)∈E     dist(i,j,v0)=s(i,j)

Here,dist(i,j,v0) is the distance between vertices i and j with intermediate vertex v0.

The shortest path between all pairs of vertices (i,j)with the intermediate nodev0 is calculated as:

for i=1 to n:      for j=1 to n:          dist(i,j,v0)=mindist(i,v0,v0-1)+dist(v0,j,v0-1)+dist(i,j,v0-1)

Here, n is the number of vertices

Hence, an algorithm to find the shortest path between every node pair of a graph with one common intermediate node is obtained.

Unlock Step-by-Step Solutions & Ace Your Exams!

  • Full Textbook Solutions

    Get detailed explanations and key concepts

  • Unlimited Al creation

    Al flashcards, explanations, exams and more...

  • Ads-free access

    To over 500 millions flashcards

  • Money-back guarantee

    We refund you if you fail your exam.

Over 30 million students worldwide already upgrade their learning with 91Ó°ÊÓ!

One App. One Place for Learning.

All the tools & learning materials you need for study success - in one app.

Get started for free

Most popular questions from this chapter

Squares.Design and analyse an algorithm that takes as input an undirected graph G(V,E) and determines whether graph contains a simple cycle (that is, a cycle which doesn’t intersect itself) of length four. Its running time should be at mostO(V3) time.

You may assume that the input graph is represented either as an adjacency matrix or with adjacency lists, whichever makes your algorithm simpler.

You are given a directed graph G(V,E)with (possibly negative) weighted edges, along with a specific node s∈Vand a tree T=(V,E'),E'⊂E. Give an algorithm that checks whether T is a shortest-path tree for G with starting point s . Your algorithm should run in linear time.

Shortest paths are not always unique: sometimes there are two or more different paths with the minimum possible length. Show how to solve the following problem in O((|V|+|E|)log|V|)time.

Input:An undirected graph G=(V,E);edge lengths le>0; starting vertex s∈V.

Output:A Boolean array for each node u , the entry usp[u]should be true if and only if there is a unique shortest path s to u (Note:usp[s]=true)

Generalized shortest-paths problem.In Internet routing, there are delays on lines but also, more significantly, delays at routers. This motivates a generalized shortest-paths problem.

Suppose that in addition to having edge lengths {Ie:e∈E} ,a graph also has vertex costs {cV:v∈V} . Now define the cost of a path to be the sum of its edge lengths, plusthe costs ofall vertices on the path (including the endpoints). Give an efficient algorithm for the followingproblem.

Input:A directed graph G={V,E} positive edge lengths Ie and positive vertex costs cv; a starting vertex s∈v.

Output:An array cost[.] such that for every vertex u,costu, is the least cost of any path from s to u (i.e., the cost of the cheapest path), under the defnition above.

Notice that cost[s]=c.

You are given a set of cities, along with the pattern of highways between them, in the form of an undirected graph G = (V , E). Each stretch of highway e∈Econnects two cities, and you know its length in miles, le. You want to get from city s to city t. There’s one problem: your car can only hold enough gas to cover L miles. There are gas stations in each city, but not between cities. Therefore, you can only take a route if every one of its edges has length le≤L

(a) Given the limitation on your car’s fuel tank capacity, show how to determine in linear time whether there is a feasible route from sto t.

(b) You are now planning to buy a new car, and you want to know the minimum fuel tank capacity that is needed to travel from s to t. Give anO[(V+E)log|V|]algorithm to determine this.

See all solutions

Recommended explanations on Computer Science Textbooks

View all explanations

What do you think about this solution?

We value your feedback to improve our textbook solutions.

Study anywhere. Anytime. Across all devices.