||'''Book'''|| Linear Algebra || ||'''Author'''|| Gilbert Strang || ||'''Edition'''|| || /* code_begins */ {{{ #To find adjacency matrix of the graph in problem 4 print 'The adjacency matrix is' A = matrix([[0,1,1,1],[1,0,1,1],[1,1,0,1],[1,1,1,0]]) print A print 'To find the no. of 2 step paths from a node to another we square the adjacency matrix' print 'The square of adjacency matrix is ' b = A**2 print A**2 def no_of_2step_paths(i,j): return b[i-1][j-1] print 'For example the no of 2-step paths from node-1 to node-3 is ', print no_of_2step_paths(1,3) }}} /* code_ends */ * '''Solution by''': * Arnab Basu, Student, IIT Roorkee * Amit Tewari, Student, IIT Roorkee * Rachit Jha, Student, IIT Roorkee * Shubham Mittal, Student, IIT Roorkee