Question: IN PYTHON CODING: (5 pts) Write a function transitive closure(A) that computes and returns the transitive closure A*. You may assume that A is a
IN PYTHON CODING:

(5 pts) Write a function transitive closure(A) that computes and returns the transitive closure A*. You may assume that A is a 2D list containing only Os and 1s, and A is square (same number of rows and columns). You should call your previously written matrix add boolean and matrix power functions Example: Let Then calling transitive_ closure(R) should return [0, 0, 1, 1], [0, 1, 1, 1], [0, 0,1, 1], [0, 0, 1, 111 Be sure to thoroughly test your fiunctions after you've written them! You can use the matrix print function to make your results easier to read Hints The dentin marm is the n n matrix consisting of ls down the principal diagonal (where the row and column numbers are the same) and 0s everywhere else. For example, the 3 3 identity matrix is . Multiplying the identity matrix by any matrix A of the same dimensions results in A itself Given a 2D list A len (A) returns the number of rows in A len(A[i]) returns the number of columns in row i of A If A contains the same number of columns in every row (which we are assuming for this lab), len (A[O]) returns the number of columns in A To create a 2D list A with r rows and c columns, where every element is initialized to 0, you can use this syntax A- [oj*c for i in range (r) 1
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
