Question: 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

 in python please! Connections between airports can be modelled as a

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!