Class PearsonCorrelation<U>
java.lang.Object
es.uam.eps.ir.relison.sna.metrics.graph.PearsonCorrelation<U>
- Type Parameters:
U
- Type of the users.
- All Implemented Interfaces:
GraphMetric<U>
- Direct Known Subclasses:
DegreePearsonCorrelation
public class PearsonCorrelation<U> extends java.lang.Object implements GraphMetric<U>
Class for computing the Pearson correlation of scalar values for a graph.
-
Field Summary
Fields Modifier and Type Field Description private java.util.function.ToDoubleBiFunction<U,Graph<U>>
destinyFunction
Function for computing the values for each destiny node in the link.private java.util.function.ToDoubleBiFunction<U,Graph<U>>
originFunction
Function for computing the values for each origin node in the link. -
Constructor Summary
-
Method Summary
Modifier and Type Method Description double
compute(Graph<U> graph)
Computes the value.private double
computeDirected(DirectedGraph<U> graph, java.util.Map<U,java.lang.Double> originRes, java.util.Map<U,java.lang.Double> destinyRes)
Computes the assortativity for directed graphs.private double
computeUndirected(UndirectedGraph<U> graph, java.util.Map<U,java.lang.Double> originRes, java.util.Map<U,java.lang.Double> destinyRes)
Computes the assortativity for directed graphs.
-
Field Details
-
originFunction
Function for computing the values for each origin node in the link. -
destinyFunction
Function for computing the values for each destiny node in the link.
-
-
Constructor Details
-
PearsonCorrelation
public PearsonCorrelation(java.util.function.ToDoubleBiFunction<U,Graph<U>> originFunction, java.util.function.ToDoubleBiFunction<U,Graph<U>> destinyFunction)Constructor- Parameters:
originFunction
- Function for computing the values for each origin node in the link.destinyFunction
- Function for computing the values for each destiny node in the link.
-
-
Method Details
-
compute
Description copied from interface:GraphMetric
Computes the value.- Specified by:
compute
in interfaceGraphMetric<U>
- Parameters:
graph
- graph metric.- Returns:
- the value of the metric.
-
computeDirected
private double computeDirected(DirectedGraph<U> graph, java.util.Map<U,java.lang.Double> originRes, java.util.Map<U,java.lang.Double> destinyRes)Computes the assortativity for directed graphs.- Parameters:
graph
- the graph.originRes
- the values for the origin node.destinyRes
- the values for the destination node.- Returns:
- the Pearson correlation of the directed graph.
-
computeUndirected
private double computeUndirected(UndirectedGraph<U> graph, java.util.Map<U,java.lang.Double> originRes, java.util.Map<U,java.lang.Double> destinyRes)Computes the assortativity for directed graphs.- Parameters:
graph
- the graph.originRes
- the values for the origin node.destinyRes
- the values for the destination node.- Returns:
- the Pearson correlation of the undirected graph.
-