Class Adapters

java.lang.Object
es.uam.eps.ir.relison.graph.Adapters

public class Adapters
extends java.lang.Object
Methods for filtering the users and edges from a graph.
  • Constructor Summary

    Constructors 
    Constructor Description
    Adapters()  
  • Method Summary

    Modifier and Type Method Description
    static <U> Graph<U> addAllAutoloops​(Graph<U> graph)
    Given a graph, obtains a version of the graph with all the possible autoloops.
    static <U> Graph<U> filteredGraph​(Graph<U> graph, java.util.function.Function<U,​java.util.function.IntPredicate> filter)
    Given a filter, it applies it to the edges in the graph.
    static <U> Graph<U> onlyTrainUsers​(Graph<U> graph, Graph<U> trainingGraph)
    Given two graphs (test and training graphs), generates a new graph containing only the users present in the second one.
    static <U> Graph<U> removeAutoloops​(Graph<U> graph)
    Given a graph, obtains a version of it without autoloops.
    static <U> Graph<U> undirected​(Graph<U> graph)
    Given a directed network, returns the undirected version
    static <U> Graph<U> unweighted​(Graph<U> graph)
    Given a weighted network, returns the unweighted version.

    Methods inherited from class java.lang.Object

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

  • Method Details

    • removeAutoloops

      public static <U> Graph<U> removeAutoloops​(Graph<U> graph)
      Given a graph, obtains a version of it without autoloops.
      Type Parameters:
      U - Type of the users.
      Parameters:
      graph - the original graph.
      Returns:
      a graph without autoloops.
    • addAllAutoloops

      public static <U> Graph<U> addAllAutoloops​(Graph<U> graph)
      Given a graph, obtains a version of the graph with all the possible autoloops.
      Type Parameters:
      U - Type of the users
      Parameters:
      graph - the original graph
      Returns:
      a graph with all the autoloops added.
    • onlyTrainUsers

      public static <U> Graph<U> onlyTrainUsers​(Graph<U> graph, Graph<U> trainingGraph)
      Given two graphs (test and training graphs), generates a new graph containing only the users present in the second one.
      Type Parameters:
      U - type of the users.
      Parameters:
      graph - the test graph.
      trainingGraph - the training graph.
      Returns:
      the graph if everything went OK, null otherwise.
    • unweighted

      public static <U> Graph<U> unweighted​(Graph<U> graph)
      Given a weighted network, returns the unweighted version.
      Type Parameters:
      U - type of the users.
      Parameters:
      graph - the original graph.
      Returns:
      the unweighted network if everything is OK, null otherwise.
    • undirected

      public static <U> Graph<U> undirected​(Graph<U> graph)
      Given a directed network, returns the undirected version
      Type Parameters:
      U - type of the users
      Parameters:
      graph - the original graph.
      Returns:
      the graph.
    • filteredGraph

      public static <U> Graph<U> filteredGraph​(Graph<U> graph, java.util.function.Function<U,​java.util.function.IntPredicate> filter)
      Given a filter, it applies it to the edges in the graph.
      Type Parameters:
      U - the type of the users.
      Parameters:
      graph - the original network.
      filter - the filter to apply.
      Returns:
      the filtered graph.