Package es.uam.eps.ir.relison.graph
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 versionstatic <U> Graph<U>unweighted(Graph<U> graph)Given a weighted network, returns the unweighted version.
-
Constructor Details
-
Adapters
public Adapters()
-
-
Method Details
-
removeAutoloops
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
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
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
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
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.
-