Class ShrinkingASL<U>
java.lang.Object
es.uam.eps.ir.relison.sna.metrics.pair.AbstractPairMetric<U>
es.uam.eps.ir.relison.sna.metrics.distance.pair.ShrinkingASL<U>
- Type Parameters:
U
- type of the users.
- All Implemented Interfaces:
PairMetric<U>
public class ShrinkingASL<U> extends AbstractPairMetric<U>
Computes the variation of the average shortest path length if a link is
included in the graph.
-
Field Summary
Fields Modifier and Type Field Description private DistanceCalculator<U>
dc
Distance calculator. -
Constructor Summary
Constructors Constructor Description ShrinkingASL()
Constructor.ShrinkingASL(DistanceCalculator<U> dc)
Constructor. -
Method Summary
Modifier and Type Method Description double
averageValue(Graph<U> graph)
Computes the average value of the metricdouble
averageValue(Graph<U> graph, java.util.stream.Stream<Pair<U>> pair, int pairCount)
Computes the average value of a certain group of pairs.java.util.Map<Pair<U>,java.lang.Double>
compute(Graph<U> graph)
Computes the value of the metric for all the possible pairs in the graph.java.util.Map<Pair<U>,java.lang.Double>
compute(Graph<U> graph, java.util.stream.Stream<Pair<U>> pairs)
Computes the value of the metric for a selection of pairs in the graph.double
compute(Graph<U> graph, U orig, U dest)
Computes the value of the metric for a single pair of nodesprivate double
computeDirected(Graph<U> graph, U u, U v, java.util.Set<U> uCIn, java.util.Set<U> vCOut, java.util.Set<U> uCOut, java.util.Set<U> vCIn, java.util.Map<U,java.util.Map<U,java.lang.Double>> distances, java.util.TreeMap<java.lang.Double,java.util.List<Pair<U>>> pairsAtDistance, java.util.TreeMap<java.lang.Double,java.lang.Long> counter, double sum, double count)
Given a pair, computes the value of the metric in case the graph is directed.private double
computePair(Graph<U> graph, U u, U v, java.util.Set<U> uCIn, java.util.Set<U> vCOut, java.util.Map<U,java.util.Map<U,java.lang.Double>> distances, double sum, double count)
Computes the metric for an individual pair of users.private double
computePair(Graph<U> graph, U u, U v, java.util.Set<U> uCIn, java.util.Set<U> vCOut, java.util.Set<U> uCOut, java.util.Set<U> vCIn, java.util.Map<U,java.util.Map<U,java.lang.Double>> distances, java.util.TreeMap<java.lang.Double,java.util.List<Pair<U>>> pairsAtDistance, java.util.TreeMap<java.lang.Double,java.lang.Long> counter, double sum, double count)
Given a pair, computes the value of the metric.private double
computeUndirected(Graph<U> graph, U u, U v, java.util.Set<U> uCIn, java.util.Set<U> vCOut, java.util.Map<U,java.util.Map<U,java.lang.Double>> distances, java.util.TreeMap<java.lang.Double,java.util.List<Pair<U>>> pairsAtDistance, java.util.TreeMap<java.lang.Double,java.lang.Long> counter, double sum, double count)
Given a pair, computes the value of the metric in case the graph is undirected.Methods inherited from class es.uam.eps.ir.relison.sna.metrics.pair.AbstractPairMetric
averageValueOnlyLinks, computeDest, computeOnlyLinks, computeOrig
-
Field Details
-
dc
Distance calculator.
-
-
Constructor Details
-
ShrinkingASL
public ShrinkingASL()Constructor. -
ShrinkingASL
Constructor.- Parameters:
dc
- distance calculator.
-
-
Method Details
-
compute
Description copied from interface:PairMetric
Computes the value of the metric for a single pair of nodes- Parameters:
graph
- The full graph.orig
- The origin node of the edge.dest
- The destiny node of the edge.- Returns:
- The value of the metric for that edge.
-
compute
Description copied from interface:PairMetric
Computes the value of the metric for all the possible pairs in the graph.- Specified by:
compute
in interfacePairMetric<U>
- Overrides:
compute
in classAbstractPairMetric<U>
- Parameters:
graph
- The full graph.- Returns:
- A map containing the metrics for each node.
-
computePair
private double computePair(Graph<U> graph, U u, U v, java.util.Set<U> uCIn, java.util.Set<U> vCOut, java.util.Map<U,java.util.Map<U,java.lang.Double>> distances, double sum, double count)Computes the metric for an individual pair of users.- Parameters:
graph
- the graph.u
- the origin user.v
- the destination user.uCIn
- the incoming component of user u.vCOut
- the outgoing component of user v.distances
- the distances.sum
- the sum of finite distances.count
- the number of pairs connected by finite distances.- Returns:
- the value of the metric.
-
compute
public java.util.Map<Pair<U>,java.lang.Double> compute(Graph<U> graph, java.util.stream.Stream<Pair<U>> pairs)Description copied from interface:PairMetric
Computes the value of the metric for a selection of pairs in the graph.- Specified by:
compute
in interfacePairMetric<U>
- Overrides:
compute
in classAbstractPairMetric<U>
- Parameters:
graph
- The full graph.pairs
- A stream containing the selected pairs.- Returns:
- A map containing the metrics for each pair in the stream that exists.
-
averageValue
Description copied from interface:PairMetric
Computes the average value of the metric- Specified by:
averageValue
in interfacePairMetric<U>
- Overrides:
averageValue
in classAbstractPairMetric<U>
- Parameters:
graph
- The full graph.- Returns:
- The average value of the metric
-
averageValue
Description copied from interface:PairMetric
Computes the average value of a certain group of pairs.- Specified by:
averageValue
in interfacePairMetric<U>
- Overrides:
averageValue
in classAbstractPairMetric<U>
- Parameters:
graph
- the full graph.pair
- a stream containing the selected pairs.pairCount
- the number of pairs in the stream.- Returns:
- The average value of the metric for those pairs.
-
computePair
private double computePair(Graph<U> graph, U u, U v, java.util.Set<U> uCIn, java.util.Set<U> vCOut, java.util.Set<U> uCOut, java.util.Set<U> vCIn, java.util.Map<U,java.util.Map<U,java.lang.Double>> distances, java.util.TreeMap<java.lang.Double,java.util.List<Pair<U>>> pairsAtDistance, java.util.TreeMap<java.lang.Double,java.lang.Long> counter, double sum, double count)Given a pair, computes the value of the metric.- Parameters:
graph
- the original graph.u
- the origin user.v
- the destination user.uCIn
- the in-component of the origin user.vCOut
- the out-component of the destination user.uCOut
- the out-component of the origin user.vCIn
- the in-component of the destination user.distances
- a map containing the distances between pairs.pairsAtDistance
- a map ccontaining the pairs at a given distance.counter
- counts how many pairs there are at a given distance.sum
- sum of the finite distances between pairs in the original graph.count
- number of finite distances between pairs in the original graph.- Returns:
- the value of the metric for that pair.
-
computeDirected
private double computeDirected(Graph<U> graph, U u, U v, java.util.Set<U> uCIn, java.util.Set<U> vCOut, java.util.Set<U> uCOut, java.util.Set<U> vCIn, java.util.Map<U,java.util.Map<U,java.lang.Double>> distances, java.util.TreeMap<java.lang.Double,java.util.List<Pair<U>>> pairsAtDistance, java.util.TreeMap<java.lang.Double,java.lang.Long> counter, double sum, double count)Given a pair, computes the value of the metric in case the graph is directed.- Parameters:
graph
- the original graph.u
- the origin user.v
- the destination user.uCIn
- the in-component of the origin user.vCOut
- the out-component of the destination user.uCOut
- the out-component of the origin user.vCIn
- the in-component of the destination user.distances
- a map containing the distances between pairs.pairsAtDistance
- a map ccontaining the pairs at a given distance.counter
- counts how many pairs there are at a given distance.sum
- sum of the finite distances between pairs in the original graph.count
- number of finite distances between pairs in the original graph.- Returns:
- the value of the metric for that pair.
-
computeUndirected
private double computeUndirected(Graph<U> graph, U u, U v, java.util.Set<U> uCIn, java.util.Set<U> vCOut, java.util.Map<U,java.util.Map<U,java.lang.Double>> distances, java.util.TreeMap<java.lang.Double,java.util.List<Pair<U>>> pairsAtDistance, java.util.TreeMap<java.lang.Double,java.lang.Long> counter, double sum, double count)Given a pair, computes the value of the metric in case the graph is undirected.- Parameters:
graph
- the original graph.u
- the origin user.v
- the destination user.uCIn
- the in-component of the origin user.vCOut
- the out-component of the destination user.distances
- a map containing the distances between pairs.pairsAtDistance
- a map ccontaining the pairs at a given distance.counter
- counts how many pairs there are at a given distance.sum
- sum of the finite distances between pairs in the original graph.count
- number of finite distances between pairs in the original graph.- Returns:
- the value of the metric for that pair.
-