Class MatrixBasedVertexMetric<U>
java.lang.Object
es.uam.eps.ir.relison.sna.metrics.vertex.MatrixBasedVertexMetric<U>
- Type Parameters:
U- type of the users.
- All Implemented Interfaces:
VertexMetric<U>
- Direct Known Subclasses:
EigenvectorCentrality,KatzCentrality
public abstract class MatrixBasedVertexMetric<U> extends java.lang.Object implements VertexMetric<U>
Vertex metric based on matrices.
-
Field Summary
Fields Modifier and Type Field Description private MatrixLibrarylibraryThe matrix library to use. -
Constructor Summary
Constructors Constructor Description MatrixBasedVertexMetric()Default constructor.MatrixBasedVertexMetric(MatrixLibrary library)Constructor. -
Method Summary
Modifier and Type Method Description java.util.Map<U,java.lang.Double>compute(Graph<U> graph)Computes the value of the metric for all the users in the graph.java.util.Map<U,java.lang.Double>compute(Graph<U> graph, java.util.stream.Stream<U> users)Computes the value of the metric for a subset of the users in the graph.doublecompute(Graph<U> graph, U user)Computes the value of the metric for a single user.protected abstract double[]getCOLTScores(Graph<U> graph)Obtains the values of the metric for the different users using the COLT library.protected abstract double[]getJBLASScores(Graph<U> graph)Obtains the values of the metric for the different users using the JBLAS library.protected abstract double[]getMTJScores(Graph<U> graph)Obtains the values of the metric for the different users using the MTJ library.double[]getScores(Graph<U> graph)Obtains the value of the metric for each user.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface es.uam.eps.ir.relison.sna.metrics.VertexMetric
averageValue, averageValue
-
Field Details
-
library
The matrix library to use.
-
-
Constructor Details
-
MatrixBasedVertexMetric
Constructor.- Parameters:
library- the matrix library to use.
-
MatrixBasedVertexMetric
public MatrixBasedVertexMetric()Default constructor. If possible, uses the JBLAS library. Otherwise, it takes the COLT library.
-
-
Method Details
-
compute
Description copied from interface:VertexMetricComputes the value of the metric for all the users in the graph.- Specified by:
computein interfaceVertexMetric<U>- Parameters:
graph- The graph.- Returns:
- A map relating the users with the values of the metric.
-
compute
Description copied from interface:VertexMetricComputes the value of the metric for a single user.- Specified by:
computein interfaceVertexMetric<U>- Parameters:
graph- The graph.user- The user to compute.- Returns:
- the value of the metric.
-
compute
public java.util.Map<U,java.lang.Double> compute(Graph<U> graph, java.util.stream.Stream<U> users)Description copied from interface:VertexMetricComputes the value of the metric for a subset of the users in the graph.- Specified by:
computein interfaceVertexMetric<U>- Parameters:
graph- the graph.users- the stream of users.- Returns:
- a map relating users with the values of the metric. Nodes not in the graph will not be included in the map.
-
getScores
Obtains the value of the metric for each user.- Parameters:
graph- the network.- Returns:
- an array containing the value of the metric for each user.
-
getJBLASScores
Obtains the values of the metric for the different users using the JBLAS library.- Parameters:
graph- the network.- Returns:
- an array containing the value of the metric for each user.
-
getMTJScores
Obtains the values of the metric for the different users using the MTJ library.- Parameters:
graph- the network.- Returns:
- an array containing the value of the metric for each user.
-
getCOLTScores
Obtains the values of the metric for the different users using the COLT library.- Parameters:
graph- the network.- Returns:
- an array containing the value of the metric for each user.
-