Question: CHW 5 . 1 . So many options: Flying from O'Hare to LAX with at most one layover Connections between airports can be modelled by
CHW So many options: Flying from O'Hare to LAX with at most one layover
Connections between airports can be modelled by a graph. The nodes represent airports, and the edges represent nonstop flight routes between the airports. Two nodes are connected by a edge if there is a nonstop flight between the two airports; for simplicity, we assume that if there is a nonstop flight from one airport to another, there is a returning nonstop flight so that the graph is undirected.
The matrix nonstopflights represents a network of US airports as described above. We ask you to determine the number of distinct routes to fly from O'Hare Airport ORD to Los Angeles International Airport LAX with at most one layover that is either nonstop or with exactly one layover
Compute a matrix A such that the entry in the th row and the th column of is the number of walks from node to node of length at most Store this matrix as atmostlayover.
Assuming that ORD is airport # the rowcolumn of the adjacency matrix when oneindexing and LAX is airport # the rowcolumn of the adjacency matrix when oneindexing Compute the number of distict routes to fly from ORD to LAX with at most one layover. Save this as numoptions.
The setup code gives the following variables:
tableNameType,Descriptionnonstopflights,tablenumpyarraytableNetwork of nonstop flight connections,
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
