Class Assortativity<U>

java.lang.Object
es.uam.eps.ir.relison.sna.metrics.graph.Assortativity<U>
Type Parameters:
U - Type of the users.
All Implemented Interfaces:
GraphMetric<U>
Direct Known Subclasses:
DegreeAssortativity

public class Assortativity<U>
extends java.lang.Object
implements GraphMetric<U>
Class for computing the assortativity of scalar values for a graph.

Reference: M.E.J. Newman. Assortative mixing in networks. Physical Review Letters 89(20), 208701 (2002)

  • Field Summary

    Fields 
    Modifier and Type Field Description
    private java.util.function.ToDoubleBiFunction<U,​Graph<U>> function
    Function for computing the values for each node.
  • Constructor Summary

    Constructors 
    Constructor Description
    Assortativity​(java.util.function.ToDoubleBiFunction<U,​Graph<U>> function)
    Constructor.
  • 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> res)
    Computes the assortativity for directed graphs.
    private double computeUndirected​(UndirectedGraph<U> graph, java.util.Map<U,​java.lang.Double> res)
    Computes the assortativity for undirected graphs.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • function

      private final java.util.function.ToDoubleBiFunction<U,​Graph<U>> function
      Function for computing the values for each node.
  • Constructor Details

    • Assortativity

      public Assortativity​(java.util.function.ToDoubleBiFunction<U,​Graph<U>> function)
      Constructor.
      Parameters:
      function - function to apply to the users.
  • Method Details

    • compute

      public double compute​(Graph<U> graph)
      Description copied from interface: GraphMetric
      Computes the value.
      Specified by:
      compute in interface GraphMetric<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> res)
      Computes the assortativity for directed graphs.
      Parameters:
      graph - the graph
      res - the values for each node
      Returns:
      the assortativity of the directed graph.
    • computeUndirected

      private double computeUndirected​(UndirectedGraph<U> graph, java.util.Map<U,​java.lang.Double> res)
      Computes the assortativity for undirected graphs.
      Parameters:
      graph - the graph
      res - the values for each node
      Returns:
      the assortativity of the undirected graph.