Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

[IN PYTHON] In this problem there will be a network containing N nodes, labelled as 1...N, and E edges. Any two nodes may be connected

[IN PYTHON]

In this problem there will be a network containing N nodes, labelled as 1...N, and E edges. Any two nodes may be connected by an undirected edge Euv and introduces a delay of time tuv in transfer of information between the nodes u and v. You will be given K queries where each query contains the source node and the destination node and you will be required to determine the minimum time it will take for a piece of information to start from the source node and reach at the destination node. You may assume that the size of information and the processing time at any node doesnt affect the travel time. Input Format The first line will contain a single positive integer N. The second line will contain a single positive integer E. Then E lines will follow, each line containing three space separated integers. The first two denoting node labels connected by an undirected edge which introduces a time delay denoted by the third integer. After that the next line will contain a positive integer K. Then K lines will follow each containing two space separated node labels, the first denoting the source node and the second one denoting the destination node for that query. Constraints 0 < N < 100 0 < E < N*(N-1)/2 0 < K < 20000 Network will be connected, i.e., there will be a path from one node to the other.

Output Format

K lines, each containing the minimum time required for the kth query.

Sample Input

4 3 1 2 1 2 3 1 3 4 1 3 1 4 3 2 4 3

Sample Output

3 1 1

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

Data Management Databases And Organizations

Authors: Richard T. Watson

3rd Edition

0471418455, 978-0471418450

More Books

Students also viewed these Databases questions

Question

1. Define the nature of interviews

Answered: 1 week ago

Question

2. Outline the different types of interviews

Answered: 1 week ago