private void initialize(int steps) { this.acceptDisconnectedGraph(false); if (steps <= 0) { throw new IllegalArgumentException("Number of steps must be > 0"); } this.max_iterations = steps; this.tolerance = -1.0; this.cumulative = false; }
/** * Creates an instance based on the specified graph, node priors (initial scores), and number of * steps to take. The edge weights (transition probabilities) are set to default values (a uniform * distribution over all outgoing edges). * * @param graph the input graph * @param node_priors the initial probability distribution (score assignment) * @param steps the number of times that {@code step()} will be called by {@code evaluate} */ public KStepMarkov(Network<N, E> graph, Function<N, Double> node_priors, int steps) { super(graph, node_priors, 0); initialize(steps); }
collectDisappearingPotential(v); 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); ? v_input * (1 - alpha) + getVertexPrior(v) * alpha : v_input; setOutputValue(v, new_value + getCurrentValue(v)); return Math.abs(getCurrentValue(v) - new_value);
/** 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); } }
KStepMarkov ranker = new KStepMarkov(viewerPanel.getCurrentGraph(), 8); ranker.evaluate(); StringBuffer sb = new StringBuffer(); sb.append("\t<position>" + i + "</position>\n"); sb.append("\t<node>" + list.get(i) + "</node>\n"); sb.append("\t<rank>" + (Double) ranker.getVertexScore(list.get(i)) + "</rank>\n"); sb.append("</entry>");
return super.update(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 + getCurrentValue(v)); return Math.abs(getCurrentValue(v) - new_value);
return super.update(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 + getCurrentValue(v)); return Math.abs(getCurrentValue(v) - new_value);
/** * Creates an instance based on the specified graph, edge weights, vertex * priors (initial scores), and number of steps to take. * @param graph the input graph * @param edge_weights the edge weights (transition probabilities) * @param vertex_priors the initial probability distribution (score assignment) * @param steps the number of times that {@code step()} will be called by {@code evaluate} */ public KStepMarkov(Hypergraph<V,E> graph, Function<E, ? extends Number> edge_weights, Function<V, Double> vertex_priors, int steps) { super(graph, edge_weights, vertex_priors, 0); initialize(steps); }
private void initialize(int steps) { this.acceptDisconnectedGraph(false); if (steps <= 0) throw new IllegalArgumentException("Number of steps must be > 0"); this.max_iterations = steps; this.tolerance = -1.0; this.cumulative = false; }
/** * Creates an instance based on the specified graph, vertex * priors (initial scores), and number of steps to take. The edge * weights (transition probabilities) are set to default values (a uniform * distribution over all outgoing edges). * @param graph the input graph * @param vertex_priors the initial probability distribution (score assignment) * @param steps the number of times that {@code step()} will be called by {@code evaluate} */ public KStepMarkov(Hypergraph<V,E> graph, Transformer<V, Double> vertex_priors, int steps) { super(graph, vertex_priors, 0); initialize(steps); }
private void initialize(int steps) { this.acceptDisconnectedGraph(false); if (steps <= 0) throw new IllegalArgumentException("Number of steps must be > 0"); this.max_iterations = steps; this.tolerance = -1.0; this.cumulative = false; }
/** * Creates an instance based on the specified graph, vertex * priors (initial scores), and number of steps to take. The edge * weights (transition probabilities) are set to default values (a uniform * distribution over all outgoing edges). * @param graph the input graph * @param vertex_priors the initial probability distribution (score assignment) * @param steps the number of times that {@code step()} will be called by {@code evaluate} */ public KStepMarkov(Hypergraph<V,E> graph, Function<V, Double> vertex_priors, int steps) { super(graph, vertex_priors, 0); initialize(steps); }
private void initialize(int steps) { Preconditions.checkArgument(steps >= 0, "Number of steps must be > 0"); this.acceptDisconnectedGraph(false); this.max_iterations = steps; this.tolerance = -1.0; this.cumulative = false; }
/** * Creates an instance based on the specified graph, edge weights, vertex * priors (initial scores), and number of steps to take. * @param graph the input graph * @param edge_weights the edge weights (transition probabilities) * @param vertex_priors the initial probability distribution (score assignment) * @param steps the number of times that {@code step()} will be called by {@code evaluate} */ public KStepMarkov(Hypergraph<V,E> graph, Transformer<E, ? extends Number> edge_weights, Transformer<V, Double> vertex_priors, int steps) { super(graph, edge_weights, vertex_priors, 0); initialize(steps); }
/** * Creates an instance based on the specified graph, edge weights, node priors (initial scores), * and number of steps to take. * * @param graph the input graph * @param edge_weights the edge weights (transition probabilities) * @param node_priors the initial probability distribution (score assignment) * @param steps the number of times that {@code step()} will be called by {@code evaluate} */ public KStepMarkov( Network<N, E> graph, Function<E, ? extends Number> edge_weights, Function<N, Double> node_priors, int steps) { super(graph, edge_weights, node_priors, 0); initialize(steps); }
/** * Creates an instance based on the specified graph, vertex priors (initial * scores), and number of steps to take. The edge weights (transition * probabilities) are set to default values (a uniform distribution over all * outgoing edges). * * @param graph * the input graph * @param vertex_priors * the initial probability distribution (score assignment) * @param steps * the number of times that {@code step()} will be called by * {@code evaluate} */ public KStepMarkov(Hypergraph<V, E> graph, Transformer<V, Double> vertex_priors, int steps) { super(graph, vertex_priors, 0); initialize(steps); }
/** * Creates an instance based on the specified graph, edge weights, vertex * priors (initial scores), and number of steps to take. * * @param graph * the input graph * @param edge_weights * the edge weights (transition probabilities) * @param vertex_priors * the initial probability distribution (score assignment) * @param steps * the number of times that {@code step()} will be called by * {@code evaluate} */ public KStepMarkov(Hypergraph<V, E> graph, Transformer<E, ? extends Number> edge_weights, Transformer<V, Double> vertex_priors, int steps) { super(graph, edge_weights, vertex_priors, 0); initialize(steps); }
/** * Creates an instance based on the specified graph and number of steps to * take. The edge weights (transition probabilities) and vertex initial scores * (prior probabilities) are set to default values (a uniform * distribution over all outgoing edges, and a uniform distribution over * all vertices, respectively). * @param graph the input graph * @param steps the number of times that {@code step()} will be called by {@code evaluate} */ public KStepMarkov(Hypergraph<V,E> graph, int steps) { super(graph, ScoringUtils.getUniformRootPrior(graph.getVertices()), 0); initialize(steps); }
/** * Creates an instance based on the specified graph and number of steps to take. The edge weights * (transition probabilities) and node initial scores (prior probabilities) are set to default * values (a uniform distribution over all outgoing edges, and a uniform distribution over all * nodes, respectively). * * @param graph the input graph * @param steps the number of times that {@code step()} will be called by {@code evaluate} */ public KStepMarkov(Network<N, E> graph, int steps) { super(graph, ScoringUtils.getUniformRootPrior(graph.nodes()), 0); initialize(steps); }
/** * Creates an instance based on the specified graph and number of steps to * take. The edge weights (transition probabilities) and vertex initial scores * (prior probabilities) are set to default values (a uniform * distribution over all outgoing edges, and a uniform distribution over * all vertices, respectively). * @param graph the input graph * @param steps the number of times that {@code step()} will be called by {@code evaluate} */ public KStepMarkov(Hypergraph<V,E> graph, int steps) { super(graph, ScoringUtils.getUniformRootPrior(graph.getVertices()), 0); initialize(steps); }