Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

in python please! Connections between airports can be modelled as a graph. The nodes represent airports and the edges represent direct flight routes between two

image text in transcribed

in python please!

Connections between airports can be modelled as a graph. The nodes represent airports and the edges represent direct flight routes between two airports. Two nodes are connected by a edge if there is a direct flight between the two airports (for simplicity we assume that if there is a direct flight from airport X to airport Y, then there is also a direct flight from airport Y to airport X). The matrix direct_flights represents a network of 100 US airports as described above. We ask you to determine the number routes to get from O'Hare Airport (ORD) to Los Angeles International Airport (LAX) either directly or with one layover. 1) Compute a 100 x 100-matrix A such that the entry in the i-th row and the j-th column of A is the number of walks from node i to node ; of length at most 2. Store this matrix as atmost_1_layover. 2) Assuming that ORD is airport # 29 (the 30th row/column of the adjacency matrix when one-indexing) and LAX is airport # 89 (the 90 th row/column of the adjacency matrix when one-indexing). Find the number of ways of flying from ORD to LAX either directly or with one layover. Save this as num_options. The setup code gives the following variables: Name Type Description Network of direct connections, 100 x 100 adjacency matrix direct_flights numpy array Your code snippet should define the following variables: Name Type Description atmost_1_layover numpy array Network of connections with one layover, 100 x 100 adjacency matrix num_options integer Number of routes from ORD to LAX with at most one layover Connections between airports can be modelled as a graph. The nodes represent airports and the edges represent direct flight routes between two airports. Two nodes are connected by a edge if there is a direct flight between the two airports (for simplicity we assume that if there is a direct flight from airport X to airport Y, then there is also a direct flight from airport Y to airport X). The matrix direct_flights represents a network of 100 US airports as described above. We ask you to determine the number routes to get from O'Hare Airport (ORD) to Los Angeles International Airport (LAX) either directly or with one layover. 1) Compute a 100 x 100-matrix A such that the entry in the i-th row and the j-th column of A is the number of walks from node i to node ; of length at most 2. Store this matrix as atmost_1_layover. 2) Assuming that ORD is airport # 29 (the 30th row/column of the adjacency matrix when one-indexing) and LAX is airport # 89 (the 90 th row/column of the adjacency matrix when one-indexing). Find the number of ways of flying from ORD to LAX either directly or with one layover. Save this as num_options. The setup code gives the following variables: Name Type Description Network of direct connections, 100 x 100 adjacency matrix direct_flights numpy array Your code snippet should define the following variables: Name Type Description atmost_1_layover numpy array Network of connections with one layover, 100 x 100 adjacency matrix num_options integer Number of routes from ORD to LAX with at most one layover

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

Database Driven Web Sites

Authors: Joline Morrison, Mike Morrison

2nd Edition

? 061906448X, 978-0619064488

More Books

Students also viewed these Databases questions

Question

7. General Mills

Answered: 1 week ago

Question

3. Describe the strategic training and development process.

Answered: 1 week ago