Class ClusteringCoefficientIncrement<U>
java.lang.Object
es.uam.eps.ir.relison.sna.metrics.pair.AbstractPairMetric<U>
es.uam.eps.ir.relison.sna.metrics.pair.ClusteringCoefficientIncrement<U>
- Type Parameters:
U- type of the users.
- All Implemented Interfaces:
PairMetric<U>
public class ClusteringCoefficientIncrement<U> extends AbstractPairMetric<U>
Computes the increment of clustering coefficient if a link is added.
-
Field Summary
Fields Modifier and Type Field Description private Graph<U>graphThe original network.private java.util.Map<U,java.util.Set<U>>insIncoming links.private doublenumTriadsThe current number of triads.private doublenumTrianglesThe current number of trianglesprivate java.util.Map<U,java.util.Set<U>>outsOutgoing links. -
Constructor Summary
Constructors Constructor Description ClusteringCoefficientIncrement() -
Method Summary
Modifier and Type Method Description 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.doublecompute(Graph<U> graph, U orig, U dest)Computes the value of the metric for a single pair of nodesjava.util.function.Function<U,java.lang.Double>computeDest(Graph<U> graph, U dest)Given a user, computes the value of a metric for all the possible pairs in the graph where the user is the destination.private java.util.function.Function<U,java.lang.Double>computeIndividual(Graph<U> graph, U node, boolean orig)java.util.function.Function<U,java.lang.Double>computeOrig(Graph<U> graph, U orig)Given a user, computes the value of a metric for all the possible pairs in the graph where the user is the origin.private doublecomputePair(Graph<U> graph, U u, U v, java.util.Set<U> uIn, java.util.Set<U> uOut, java.util.Set<U> vIn, java.util.Set<U> vOut)Computes the increment of the clustering coefficient for a pair of users.private voidcount(Graph<U> graph)Counts the number of triads and triangles in the graph.private voidcountTrianglesAndTriads(U u, it.unimi.dsi.fastutil.objects.Object2DoubleOpenHashMap<U> triads, it.unimi.dsi.fastutil.objects.Object2DoubleOpenHashMap<U> triangles, java.util.Set<U> uNeigh, java.util.Set<U> wNeigh)Auxiliar method for updating the number of triangles and triads.Methods inherited from class es.uam.eps.ir.relison.sna.metrics.pair.AbstractPairMetric
averageValue, averageValue, averageValueOnlyLinks, computeOnlyLinks
-
Field Details
-
graph
The original network. -
numTriads
private double numTriadsThe current number of triads. -
numTriangles
private double numTrianglesThe current number of triangles -
ins
Incoming links. -
outs
Outgoing links.
-
-
Constructor Details
-
ClusteringCoefficientIncrement
public ClusteringCoefficientIncrement()
-
-
Method Details
-
compute
Description copied from interface:PairMetricComputes 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:PairMetricComputes the value of the metric for all the possible pairs in the graph.- Specified by:
computein interfacePairMetric<U>- Overrides:
computein classAbstractPairMetric<U>- Parameters:
graph- The full graph.- Returns:
- A map containing the metrics for each node.
-
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:PairMetricComputes the value of the metric for a selection of pairs in the graph.- Specified by:
computein interfacePairMetric<U>- Overrides:
computein 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.
-
computePair
private double computePair(Graph<U> graph, U u, U v, java.util.Set<U> uIn, java.util.Set<U> uOut, java.util.Set<U> vIn, java.util.Set<U> vOut)Computes the increment of the clustering coefficient for a pair of users.- Parameters:
graph- the original graph.u- the origin user.v- the destination user.uIn- the incident nodes of the origin user.uOut- the adjacent nodes of the origin user.vIn- the incident nodes of the destination user.vOut- the adjacent nodes of the destination user.- Returns:
- the increment of clustering coefficient for the pair of users.
-
computeOrig
Description copied from interface:PairMetricGiven a user, computes the value of a metric for all the possible pairs in the graph where the user is the origin. As, for efficiency methods, all values might not be computed, the default value of the metric shall be retrieved from the outcome.- Specified by:
computeOrigin interfacePairMetric<U>- Overrides:
computeOrigin classAbstractPairMetric<U>- Parameters:
graph- the graph.orig- the origin node.- Returns:
- the map containing the values of the metric.
-
countTrianglesAndTriads
private void countTrianglesAndTriads(U u, it.unimi.dsi.fastutil.objects.Object2DoubleOpenHashMap<U> triads, it.unimi.dsi.fastutil.objects.Object2DoubleOpenHashMap<U> triangles, java.util.Set<U> uNeigh, java.util.Set<U> wNeigh)Auxiliar method for updating the number of triangles and triads.- Parameters:
u- the origin node.triads- the map for storing the number of triads.triangles- the map for storing the number of triangles.uNeigh- the neighborhoods of u.wNeigh- the neighborhoods of a neighbor of u.
-
computeDest
Description copied from interface:PairMetricGiven a user, computes the value of a metric for all the possible pairs in the graph where the user is the destination. As, for efficiency methods, all values might not be computed, the default value of the metric shall be retrieved from the outcome.- Specified by:
computeDestin interfacePairMetric<U>- Overrides:
computeDestin classAbstractPairMetric<U>- Parameters:
graph- the graph.dest- the origin node.- Returns:
- the map containing the values of the metric.
-
computeIndividual
-
count
Counts the number of triads and triangles in the graph.- Parameters:
graph- the graph.
-