Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Given an undirected graph G = ( V , E ) with n vertices and m edges, and a positive ( not necessarily unique )

Given an undirected graph G=(V,E) with n vertices and m edges, and a positive
(not necessarily unique) edge cost ce for each edge in E. We are also given q pairs
of vertices Q={(u1,v1),dots,(uq,vq)}. Decide for each pair (u,v) in Q if there is a
path between u and v in G.
Task: Design an algorithm that solves this problem in O(q*(m+n)) time.
Implementation and Testing: Implement your algorithm (in Ed) and test it on
the following graph instances: Graph8, Graph250, Graph1ooo. Each instance is
given as a text file using the following format:
For example, the text below describes the instance depicted in Fig. 1. Note that
the vertices are numbered from o to n-1 and that the two queries are (0,1) and
(0,2)
Your program should read input from the text file. Your program only needs to
print out '1'(= yes, there is a path in G between u and v) or '?'' no, there is no
path connecting u and v in G) for each of the q query pairs. You should separate
each 1/o with a new line. A scaffold is provided for Python for you.
Your code will not be benchmarked or tested for time complexity, but for full
points it must be able to run instances similar to "Graph1ooo", and each test will
time out after 5 seconds. Your program will also be tested on several hidden test
cases.
If the query is (0,1) on the figure 1 below then the answer should be 'o' while
the answer to the query (0,2) on the same graph should be '1 Figure 1: Illustrating the graph described in Question 1, with n=4 and m=3.'.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Handbook Of Relational Database Design

Authors: Candace C. Fleming, Barbara Von Halle

1st Edition

0201114348, 978-0201114348

More Books

Students also viewed these Databases questions

Question

Define housing ratios 1 and 2.

Answered: 1 week ago