def google_rank ( x, G ): #*****************************************************************************80 # ## google_rank() uses the power method on the Google matrix. # # Licensing: # # This code is distributed under the MIT license. # # Modified: # # 12 February 2025 # # Author: # # John Burkardt # # Input: # # real x(n): the current rank vector. # # real G(n,n): the Google matrix. # # Output: # # real Gx(n): the rank vector, updated by one step. # import numpy as np n = G.shape[0] # # Carry out many iterations. # Normalization is not necessary because G is a transition matrix. # x = np.matmul ( G, x ) # # Compare three successive iterates. # Gx = np.matmul ( G, x ) index = np.arange ( 0, n ) Output = np.column_stack ( [ index, x, Gx ] ) print ( '' ) print ( ' x -> G*x' ) print ( Output ) return Gx