Type Parameters:
U - type of the users.
All Implemented Interfaces:
GlobalReranker<U,​U>

public class DegreeGiniReranker<U>
extends GraphSwapReranker<U>
Optimizes the degree Gini of a graph.
  • Field Summary

    Fields 
    Modifier and Type Field Description
    private long count
    Number of nodes.
    private java.util.List<org.ranksys.core.util.tuples.Tuple2od<U>> degrees
    Sorted list that contains the degrees of the nodes.
    private java.util.Map<U,​java.lang.Integer> map
    Map that contains the positions of the nodes in the degrees list.
    private EdgeOrientation orient
    Selected orientation for the Degree Gini
    private double sum
    The total sum of the degrees.

    Fields inherited from class es.uam.eps.ir.relison.links.recommendation.reranking.global.swap.GraphSwapReranker

    graph, recs

    Fields inherited from class es.uam.eps.ir.relison.links.recommendation.reranking.global.swap.SwapLambdaReranker

    novMap, novStats, relStats

    Fields inherited from class es.uam.eps.ir.relison.links.recommendation.reranking.global.swap.SwapGreedyReranker

    cutOff

    Fields inherited from class es.uam.eps.ir.relison.links.recommendation.reranking.global.swap.SwapReranker

    globalvalue
  • Constructor Summary

    Constructors 
    Constructor Description
    DegreeGiniReranker​(double lambda, int cutOff, java.util.function.Supplier<Normalizer<U>> norm, Graph<U> graph, EdgeOrientation orient)
    Constructor
  • Method Summary

    Modifier and Type Method Description
    protected void computeGlobalValue()
    Computes the global value of the property we want to enhance.
    protected void innerUpdate​(U user, org.ranksys.core.util.tuples.Tuple2od<U> updated, org.ranksys.core.util.tuples.Tuple2od<U> old)
    Updates the different parameters of the reranker, further than changing the edges in the graph.
    private double newcoef​(U user, org.ranksys.core.util.tuples.Tuple2od<U> updated, org.ranksys.core.util.tuples.Tuple2od<U> old)
    Updates the parameters, considering that a new edge is added, and the old edge is removed.
    private double newcoefadd​(U user, org.ranksys.core.util.tuples.Tuple2od<U> updated)
    Updates the parameters, considering that a only new edge is added.
    private double newcoefdel​(U user, org.ranksys.core.util.tuples.Tuple2od<U> old)
    Updates the parameters, considering that the new edge is not added (only the old is removed.)
    protected double novAdd​(U u, org.ranksys.core.util.tuples.Tuple2od<U> newUser, org.ranksys.core.util.tuples.Tuple2od<U> oldUser)
    Computes the novelty if an edge is added to the graph
    protected double novAddDelete​(U u, org.ranksys.core.util.tuples.Tuple2od<U> newUser, org.ranksys.core.util.tuples.Tuple2od<U> oldUser)
    Computes the novelty if an edge is replaced by other
    protected double novDelete​(U u, org.ranksys.core.util.tuples.Tuple2od<U> newUser, org.ranksys.core.util.tuples.Tuple2od<U> oldUser)
    Computes the novelty if an edge is removed from the graph
    protected void update​(es.uam.eps.ir.ranksys.core.Recommendation<U,​U> reranked)
    Updates the reranking algorithm values, using a certain recommendation.

    Methods inherited from class es.uam.eps.ir.relison.links.recommendation.reranking.global.swap.GraphSwapReranker

    nov, rerankRecommendations, update

    Methods inherited from class es.uam.eps.ir.relison.links.recommendation.reranking.global.swap.SwapLambdaReranker

    rerankPermutation, selectItem, value, valuetop

    Methods inherited from class es.uam.eps.ir.relison.links.recommendation.reranking.global.swap.SwapGreedyReranker

    getBasePerm, rerankRecommendation

    Methods inherited from class java.lang.Object

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

    • degrees

      private final java.util.List<org.ranksys.core.util.tuples.Tuple2od<U>> degrees
      Sorted list that contains the degrees of the nodes.
    • map

      private final java.util.Map<U,​java.lang.Integer> map
      Map that contains the positions of the nodes in the degrees list.
    • orient

      private final EdgeOrientation orient
      Selected orientation for the Degree Gini
    • sum

      private double sum
      The total sum of the degrees. Equal to the number of edges in the network if both the graph and the selected orientation are directed, equal to the double in other case.
    • count

      private long count
      Number of nodes.
  • Constructor Details

    • DegreeGiniReranker

      public DegreeGiniReranker​(double lambda, int cutOff, java.util.function.Supplier<Normalizer<U>> norm, Graph<U> graph, EdgeOrientation orient)
      Constructor
      Parameters:
      lambda - trade-off between the original and novelty score (clustering coefficient).
      cutOff - maximum length of the recommendation ranking.
      norm - the normalization strategy.
      graph - the original graph.
      orient - orientation for selecting the degree.
  • Method Details

    • novAddDelete

      protected double novAddDelete​(U u, org.ranksys.core.util.tuples.Tuple2od<U> newUser, org.ranksys.core.util.tuples.Tuple2od<U> oldUser)
      Description copied from class: GraphSwapReranker
      Computes the novelty if an edge is replaced by other
      Specified by:
      novAddDelete in class GraphSwapReranker<U>
      Parameters:
      u - user to be recommended.
      newUser - the new recommendation
      oldUser - the old recommendation
      Returns:
      the novelty score.
    • novAdd

      protected double novAdd​(U u, org.ranksys.core.util.tuples.Tuple2od<U> newUser, org.ranksys.core.util.tuples.Tuple2od<U> oldUser)
      Description copied from class: GraphSwapReranker
      Computes the novelty if an edge is added to the graph
      Specified by:
      novAdd in class GraphSwapReranker<U>
      Parameters:
      u - user to be recommended.
      newUser - the new recommendation
      oldUser - the old recommendation
      Returns:
      the novelty score.
    • novDelete

      protected double novDelete​(U u, org.ranksys.core.util.tuples.Tuple2od<U> newUser, org.ranksys.core.util.tuples.Tuple2od<U> oldUser)
      Description copied from class: GraphSwapReranker
      Computes the novelty if an edge is removed from the graph
      Specified by:
      novDelete in class GraphSwapReranker<U>
      Parameters:
      u - user to be recommended.
      newUser - the new recommendation
      oldUser - the old recommendation
      Returns:
      the novelty score.
    • computeGlobalValue

      protected void computeGlobalValue()
      Description copied from class: GraphSwapReranker
      Computes the global value of the property we want to enhance.
      Specified by:
      computeGlobalValue in class GraphSwapReranker<U>
    • update

      protected void update​(es.uam.eps.ir.ranksys.core.Recommendation<U,​U> reranked)
      Description copied from class: SwapReranker
      Updates the reranking algorithm values, using a certain recommendation.
      Specified by:
      update in class SwapReranker<U,​U>
      Parameters:
      reranked - the recommendation.
    • innerUpdate

      protected void innerUpdate​(U user, org.ranksys.core.util.tuples.Tuple2od<U> updated, org.ranksys.core.util.tuples.Tuple2od<U> old)
      Description copied from class: GraphSwapReranker
      Updates the different parameters of the reranker, further than changing the edges in the graph.
      Specified by:
      innerUpdate in class GraphSwapReranker<U>
      Parameters:
      user - the target user.
      updated - the new candidate user.
      old - the old candidate user.
    • newcoefadd

      private double newcoefadd​(U user, org.ranksys.core.util.tuples.Tuple2od<U> updated)
      Updates the parameters, considering that a only new edge is added. Every edge that enters this function is considered to be undirected.
      Parameters:
      user - the target user.
      updated - the new candidate user.
      Returns:
      the new global value.
    • newcoef

      private double newcoef​(U user, org.ranksys.core.util.tuples.Tuple2od<U> updated, org.ranksys.core.util.tuples.Tuple2od<U> old)
      Updates the parameters, considering that a new edge is added, and the old edge is removed.
      Parameters:
      user - the target user.
      updated - the new candidate user.
      old - the old candidate user.
      Returns:
      the new global value.
    • newcoefdel

      private double newcoefdel​(U user, org.ranksys.core.util.tuples.Tuple2od<U> old)
      Updates the parameters, considering that the new edge is not added (only the old is removed.)
      Parameters:
      user - the target user.
      old - the old candidate user.
      Returns:
      the new global value.