/****************************** Constructor **********************************/ // Personalized PageRank Algorithm: All node do random jump to Ego node public Model(Graph graph, double dampingFactor, int targetNode) { this.linkMatrix = graph.matrix; this.nNodes = graph.getCntAllNodes(); this.dampingFactor = dampingFactor; this.egoNode = targetNode; rank = new double[nNodes]; nextRank = new double[nNodes]; for (int i = 0; i < nNodes; i++) { // Initialize rank score of each node rank[i] = (i == targetNode) ? nNodes : 0; nextRank[i] = 0; } }
public Model(Graph graph, double dampingFactor, int targetNode) { this.graph = graph; this.nNodes = graph.getCntAllNodes(); this.dampingFactor = dampingFactor; rank = new double[nNodes]; nextRank = new double[nNodes]; restart = new double[nNodes]; for (int i = 0; i < nNodes; i++) { // Initialize rank score of each node rank[i] = (i == targetNode) ? nNodes : 0; nextRank[i] = 0; // Make restart weight restart[i] = (i == targetNode) ? 1d : 0; // [1, 0, 0, 0, 0, ... , 0, 0, 0]: Personalized PageRank } }