Class VoltageScorer<V,E>
- java.lang.Object
-
- edu.uci.ics.jung.algorithms.scoring.AbstractIterativeScorer<V,E,java.lang.Double>
-
- edu.uci.ics.jung.algorithms.scoring.VoltageScorer<V,E>
-
- All Implemented Interfaces:
VertexScorer<V,java.lang.Double>
,IterativeContext
public class VoltageScorer<V,E> extends AbstractIterativeScorer<V,E,java.lang.Double> implements VertexScorer<V,java.lang.Double>
Assigns scores to vertices according to their 'voltage' in an approximate solution to the Kirchoff equations. This is accomplished by tying "source" vertices to specified positive voltages, "sink" vertices to 0 V, and iteratively updating the voltage of each other vertex to the (weighted) average of the voltages of its neighbors.The resultant voltages will all be in the range
[0, max]
wheremax
is the largest voltage of any source vertex (in the absence of negative source voltages; see below).A few notes about this algorithm's interpretation of the graph data:
- Higher edge weights are interpreted as indicative of greater influence/effect than lower edge weights.
- Negative edge weights (and negative "source" voltages) invalidate the interpretation of the resultant values as voltages. However, this algorithm will not reject graphs with negative edge weights or source voltages.
- Parallel edges are equivalent to a single edge whose weight is the sum of the weights on the parallel edges.
- Current flows along undirected edges in both directions, but only flows along directed edges in the direction of the edge.
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Collection<V>
sinks
protected java.util.Map<V,? extends java.lang.Number>
source_voltages
-
Fields inherited from class edu.uci.ics.jung.algorithms.scoring.AbstractIterativeScorer
edge_weights, graph, hyperedges_are_self_loops, max_delta, max_iterations, output_reversed, tolerance, total_iterations
-
-
Constructor Summary
Constructors Constructor Description VoltageScorer(Hypergraph<V,E> g, com.google.common.base.Function<? super E,? extends java.lang.Number> edge_weights, java.util.Collection<V> sources, java.util.Collection<V> sinks)
Creates an instance with the specified graph, edge weights, source vertices (each of whose 'voltages' are tied to 1), and sinks.VoltageScorer(Hypergraph<V,E> g, com.google.common.base.Function<? super E,? extends java.lang.Number> edge_weights, java.util.Map<V,? extends java.lang.Number> source_voltages, java.util.Collection<V> sinks)
Creates an instance with the specified graph, edge weights, source voltages, and sinks.VoltageScorer(Hypergraph<V,E> g, com.google.common.base.Function<? super E,? extends java.lang.Number> edge_weights, V source, V sink)
Creates an instance with the specified graph, edge weights, source, and sink.VoltageScorer(Hypergraph<V,E> g, java.util.Collection<V> sources, java.util.Collection<V> sinks)
Creates an instance with the specified graph, source vertices (each of whose 'voltages' are tied to 1), and sinks.VoltageScorer(Hypergraph<V,E> g, java.util.Map<V,? extends java.lang.Number> source_voltages, java.util.Collection<V> sinks)
Creates an instance with the specified graph, source voltages, and sinks.VoltageScorer(Hypergraph<V,E> g, V source, V sink)
Creates an instance with the specified graph, edge weights, source, and sink.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
initialize()
Initializes the state of this instance.double
update(V v)
Updates the value forv
.-
Methods inherited from class edu.uci.ics.jung.algorithms.scoring.AbstractIterativeScorer
acceptDisconnectedGraph, afterStep, collectDisappearingPotential, done, evaluate, getAdjustedIncidentCount, getCurrentValue, getEdgeWeight, getEdgeWeights, getIterations, getMaxIterations, getOutputValue, getTolerance, getVertexScore, isDisconnectedGraphOK, setCurrentValue, setEdgeWeights, setHyperedgesAreSelfLoops, setMaxIterations, setOutputValue, setTolerance, step, swapOutputForCurrent, updateMaxDelta
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface edu.uci.ics.jung.algorithms.scoring.VertexScorer
getVertexScore
-
-
-
-
Constructor Detail
-
VoltageScorer
public VoltageScorer(Hypergraph<V,E> g, com.google.common.base.Function<? super E,? extends java.lang.Number> edge_weights, java.util.Map<V,? extends java.lang.Number> source_voltages, java.util.Collection<V> sinks)
Creates an instance with the specified graph, edge weights, source voltages, and sinks.- Parameters:
g
- the input graphedge_weights
- the edge weights, representing conductivitysource_voltages
- the (fixed) voltage for each sourcesinks
- the vertices whose voltages are tied to 0
-
VoltageScorer
public VoltageScorer(Hypergraph<V,E> g, com.google.common.base.Function<? super E,? extends java.lang.Number> edge_weights, java.util.Collection<V> sources, java.util.Collection<V> sinks)
Creates an instance with the specified graph, edge weights, source vertices (each of whose 'voltages' are tied to 1), and sinks.- Parameters:
g
- the input graphedge_weights
- the edge weights, representing conductivitysources
- the vertices whose voltages are tied to 1sinks
- the vertices whose voltages are tied to 0
-
VoltageScorer
public VoltageScorer(Hypergraph<V,E> g, java.util.Collection<V> sources, java.util.Collection<V> sinks)
Creates an instance with the specified graph, source vertices (each of whose 'voltages' are tied to 1), and sinks. The outgoing edges for each vertex are assigned weights that sum to 1.- Parameters:
g
- the input graphsources
- the vertices whose voltages are tied to 1sinks
- the vertices whose voltages are tied to 0
-
VoltageScorer
public VoltageScorer(Hypergraph<V,E> g, java.util.Map<V,? extends java.lang.Number> source_voltages, java.util.Collection<V> sinks)
Creates an instance with the specified graph, source voltages, and sinks. The outgoing edges for each vertex are assigned weights that sum to 1.- Parameters:
g
- the input graphsource_voltages
- the (fixed) voltage for each sourcesinks
- the vertices whose voltages are tied to 0
-
VoltageScorer
public VoltageScorer(Hypergraph<V,E> g, com.google.common.base.Function<? super E,? extends java.lang.Number> edge_weights, V source, V sink)
Creates an instance with the specified graph, edge weights, source, and sink. The source vertex voltage is tied to 1.- Parameters:
g
- the input graphedge_weights
- the edge weights, representing conductivitysource
- the vertex whose voltage is tied to 1sink
- the vertex whose voltage is tied to 0
-
VoltageScorer
public VoltageScorer(Hypergraph<V,E> g, V source, V sink)
Creates an instance with the specified graph, edge weights, source, and sink. The source vertex voltage is tied to 1. The outgoing edges for each vertex are assigned weights that sum to 1.- Parameters:
g
- the input graphsource
- the vertex whose voltage is tied to 1sink
- the vertex whose voltage is tied to 0
-
-
Method Detail
-
initialize
public void initialize()
Initializes the state of this instance.- Overrides:
initialize
in classAbstractIterativeScorer<V,E,java.lang.Double>
-
update
public double update(V v)
Description copied from class:AbstractIterativeScorer
Updates the value forv
.- Specified by:
update
in classAbstractIterativeScorer<V,E,java.lang.Double>
- Parameters:
v
- the vertex whose value is to be updated- Returns:
- the updated value
- See Also:
AbstractIterativeScorer.update(Object)
-
-