public static float[] GetPageRank(float[,] matrix, float percentJumping) { int level = matrix.GetLength(0); //percentJumping = 1 - percentJumping; GetBinaryMatrix(ref matrix, level); GetStochasticMatrix(ref matrix, level, percentJumping); //float[] vector = CreateVector(level); float[] vector = MyCreateVector(level); float[] pagerank = null; // new float[level]; int count = 0; do { pagerank = VecTools.MultiplyVectorByMatrix(matrix, vector); //pagerank = VecTools.Normalize(pagerank); if (VecTools.Equals(pagerank, vector, 0.001f)) { break; } else { for (int i = 0; i < level; i++) { vector[i] = pagerank[i]; } } count++; } while (count < 1000); //pagerank = VecTools.Normalize(pagerank); for (int i = 0; i < pagerank.Length; i++) { pagerank[i] = (float)Math.Round(pagerank[i], 3); } return(pagerank); }
public override string ToString() { return(VecTools.Stringify(this.elements)); }