/** * Updates the value for this vertex. Called by <code>step()</code>. */ @Override public double update(V v) { collectDisappearingPotential(v); double v_input = 0; for (E e : graph.getInEdges(v)) { // For graphs, the code below is equivalent to // V w = graph.getOpposite(v, e); // total_input += (getCurrentValue(w) * // getEdgeWeight(w,e).doubleValue()); // For hypergraphs, this divides the potential coming from w // by the number of vertices in the connecting edge e. int incident_count = getAdjustedIncidentCount(e); for (V w : graph.getIncidentVertices(e)) { if (!w.equals(v) || hyperedges_are_self_loops) { v_input += (getCurrentValue(w) * getEdgeWeight(w, e).doubleValue() / incident_count); } } } // modify total_input according to alpha double new_value = alpha > 0 ? v_input * (1 - alpha) + getVertexPrior(v) * alpha : v_input; setOutputValue(v, new_value); return Math.abs(getCurrentValue(v) - new_value); }
/** * Cleans up after each step. In this case that involves allocating the * disappearing potential (thus maintaining normalization of the scores) * according to the vertex probability priors, and then calling * <code>super.afterStep</code>. */ @Override protected void afterStep() { // distribute disappearing potential according to priors if (disappearing_potential > 0) { for (V v : graph.getVertices()) { setOutputValue(v, getOutputValue(v) + (1 - alpha) * (disappearing_potential * getVertexPrior(v))); } disappearing_potential = 0; } super.afterStep(); }
/** * Collects the "disappearing potential" associated with nodes that have no outgoing edges. Nodes * that have no outgoing edges do not directly contribute to the scores of other nodes. These * values are collected at each step and then distributed across all nodes as a part of the * normalization process. */ @Override protected void collectDisappearingPotential(N v) { if (graph.outDegree(v) == 0) { Preconditions.checkState(isDisconnectedGraphOK(), "Outdegree of " + v + " must be > 0"); disappearing_potential += getCurrentValue(v); } } }
/** Updates the value for this node. Called by <code>step()</code>. */ @Override public double update(N v) { collectDisappearingPotential(v); double v_input = 0; for (N u : graph.predecessors(v)) { for (E e : graph.edgesConnecting(u, v)) { v_input += (getCurrentValue(u) * getEdgeWeight(u, e).doubleValue()); } } // modify total_input according to alpha double new_value = alpha > 0 ? v_input * (1 - alpha) + getNodePrior(v) * alpha : v_input; setOutputValue(v, new_value); return Math.abs(getCurrentValue(v) - new_value); }
/** * Cleans up after each step. In this case that involves allocating the disappearing potential * (thus maintaining normalization of the scores) according to the node probability priors, and * then calling <code>super.afterStep</code>. */ @Override protected void afterStep() { // distribute disappearing potential according to priors if (disappearing_potential > 0) { for (N v : graph.nodes()) { setOutputValue( v, getOutputValue(v) + (1 - alpha) * (disappearing_potential * getNodePrior(v))); } disappearing_potential = 0; } super.afterStep(); }
PageRankWithPriors<String, Integer> ranker = new PageRankWithPriors<String, Integer>(graph, new Transformer<String, Double>() { @Override ranker.evaluate(); int i = 0; for (String pmid : graph.getVertices()) { q.add(new Ranking<String>(i++, ranker.getVertexScore(pmid), pmid));
/** Updates the value for this node. Called by <code>step()</code>. */ @Override public double update(N v) { if (!cumulative) { return super.update(v); } collectDisappearingPotential(v); double v_input = 0; for (N u : graph.predecessors(v)) { for (E e : graph.edgesConnecting(u, v)) { v_input += (getCurrentValue(u) * getEdgeWeight(u, e).doubleValue()); } } // modify total_input according to alpha double new_value = alpha > 0 ? v_input * (1 - alpha) + getNodePrior(v) * alpha : v_input; setOutputValue(v, new_value + getCurrentValue(v)); // FIXME: DO WE NEED TO CHANGE HOW DISAPPEARING IS COUNTED? NORMALIZE? return Math.abs(getCurrentValue(v) - new_value); } }
PageRankWithPriors<String, Integer> ranker = new PageRankWithPriors<>(graph, new Function<String, Double>() { @Override ranker.evaluate(); int i = 0; for (String pmid : graph.getVertices()) { q.add(new Ranking<>(i++, ranker.getVertexScore(pmid), pmid));
public double update(V v) { if (!cumulative) { return super.update(v);
public double update(V v) collectDisappearingPotential(v); int incident_count = getAdjustedIncidentCount(e); for (V w : graph.getIncidentVertices(e)) v_input += (getCurrentValue(w) * getEdgeWeight(w,e).doubleValue() / incident_count); v_input * (1 - alpha) + getVertexPrior(v) * alpha : v_input; setOutputValue(v, new_value); return Math.abs(getCurrentValue(v) - new_value);
/** * Cleans up after each step. In this case that involves allocating the disappearing * potential (thus maintaining normalization of the scores) according to the vertex * probability priors, and then calling * <code>super.afterStep</code>. */ @Override protected void afterStep() { // distribute disappearing potential according to priors if (disappearing_potential > 0) { for (V v : graph.getVertices()) { setOutputValue(v, getOutputValue(v) + (1 - alpha) * (disappearing_potential * getVertexPrior(v))); } disappearing_potential = 0; } super.afterStep(); }
/** * Collects the "disappearing potential" associated with vertices that have * no outgoing edges. Vertices that have no outgoing edges do not directly * contribute to the scores of other vertices. These values are collected * at each step and then distributed across all vertices * as a part of the normalization process. */ @Override protected void collectDisappearingPotential(V v) { if (graph.outDegree(v) == 0) { if (isDisconnectedGraphOK()) disappearing_potential += getCurrentValue(v); else throw new IllegalArgumentException("Outdegree of " + v + " must be > 0"); } } }
return super.update(v);
public double update(V v) collectDisappearingPotential(v); int incident_count = getAdjustedIncidentCount(e); for (V w : graph.getIncidentVertices(e)) v_input += (getCurrentValue(w) * getEdgeWeight(w,e).doubleValue() / incident_count); v_input * (1 - alpha) + getVertexPrior(v) * alpha : v_input; setOutputValue(v, new_value); return Math.abs(getCurrentValue(v) - new_value);
/** * Cleans up after each step. In this case that involves allocating the disappearing * potential (thus maintaining normalization of the scores) according to the vertex * probability priors, and then calling * <code>super.afterStep</code>. */ @Override protected void afterStep() { // distribute disappearing potential according to priors if (disappearing_potential > 0) { for (V v : graph.getVertices()) { setOutputValue(v, getOutputValue(v) + (1 - alpha) * (disappearing_potential * getVertexPrior(v))); } disappearing_potential = 0; } super.afterStep(); }
/** * Collects the "disappearing potential" associated with vertices that have * no outgoing edges. Vertices that have no outgoing edges do not directly * contribute to the scores of other vertices. These values are collected at * each step and then distributed across all vertices as a part of the * normalization process. */ @Override protected void collectDisappearingPotential(V v) { if (graph.outDegree(v) == 0) { if (isDisconnectedGraphOK()) { disappearing_potential += getCurrentValue(v); } else { throw new IllegalArgumentException( "Outdegree of " + v + " must be > 0"); } } } }
return super.update(v);
/** * Collects the "disappearing potential" associated with vertices that have * no outgoing edges. Vertices that have no outgoing edges do not directly * contribute to the scores of other vertices. These values are collected * at each step and then distributed across all vertices * as a part of the normalization process. */ @Override protected void collectDisappearingPotential(V v) { if (graph.outDegree(v) == 0) { if (isDisconnectedGraphOK()) disappearing_potential += getCurrentValue(v); else throw new IllegalArgumentException("Outdegree of " + v + " must be > 0"); } } }