#! /usr/bin/env python3 # def moler_incidence ( ): #*****************************************************************************80 # ## moler_incidence() returns the incidence matrix for example 3. # # Discussion: # # This matrix appears on page 5 of the reference. # # We added a self-link for node 5, which otherwise has no outlinks. # # Licensing: # # This code is distributed under the GNU LGPL license. # # Modified: # # 10 April 2022 # # Author: # # John Burkardt # # Reference: # # Cleve Moler, # Experiments with Matlab, # Chapter 7: Google PageRank, # https://www.mathworks.com/moler/exm/chapters/pagerank.pdf # # Output: # # integer A(6,6), the incidence matrix. # import numpy as np A = np.zeros ( [ 6, 6 ] ) A = np.array ( [ \ [ 0, 1, 0, 0, 0, 1 ], \ [ 0, 0, 1, 1, 0, 0 ], \ [ 0, 0, 0, 1, 1, 1 ], \ [ 1, 0, 0, 0, 0, 0 ], \ [ 0, 0, 0, 0, 1, 0 ], \ [ 1, 0, 0, 0, 0, 0 ] ] ) return A if ( __name__ == '__main__' ): A = moler_incidence ( ) print ( A )