Class Data<U extends java.io.Serializable,I extends java.io.Serializable,F>
java.lang.Object
es.uam.eps.ir.relison.diffusion.data.Data<U,I,F>
- Type Parameters:
U- type of the users.I- type of the information pieces.F- type of the user and information pieces features.
public class Data<U extends java.io.Serializable,I extends java.io.Serializable,F>
extends java.lang.Object
Class that contains the basic information for simulations.
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<java.lang.String,Index<F>>featuresFeature indexes (stored by the name of the parameter).private Graph<U>graphThe graph in which the simulation will run.private java.util.List<java.lang.String>infoPiecesFeatureNamesList of features related to each information pieceprivate java.util.Map<java.lang.String,Relation<java.lang.Double>>infoPiecesFeaturesRelation between users and their features (allows identifying the information pieces that share the same feature, as well as the features of the different information pieces).private java.util.Map<java.lang.Integer,Information<I>>informationPieceDataAdditional information for the information pieces.private Index<I>informationPiecesInformation pieces index.private java.util.HashMap<java.lang.Long,java.util.HashMap<U,java.util.Set<I>>>propagatedByTSRelation between the timestamps and the pieces propagated by each user.private Relation<java.lang.Long>realPropagatedMap containing the information pieces which have been really propagated by the user.private java.util.HashMap<java.lang.Long,java.util.HashMap<U,java.util.Set<I>>>realPropagatedByTSRelation between the timestamps and the pieces repropagated by each user.private java.util.TreeSet<java.lang.Long>timestampsOrdered set of timestamps when information pieces where published in real life.private java.util.List<java.lang.String>userFeatureNamesList of features related to each individual user.private java.util.Map<java.lang.String,Relation<java.lang.Double>>userFeaturesRelation between users and their features (allows identifying the users that share the same feature, as well as the features of the different users).private Relation<java.lang.Integer>userInformationRelation between users and the propagated information (allows identifying both the information pieces created by a user, and the creator of the information piece.private Index<U>usersUser index. -
Constructor Summary
Constructors Constructor Description Data(Graph<U> graph, Index<U> users, Index<I> informationPieces, Relation<java.lang.Integer> userInformation)Simplest constructor.Data(Graph<U> graph, Index<U> users, Index<I> informationPieces, java.util.Map<java.lang.Integer,Information<I>> informationData, Relation<java.lang.Integer> userInformation)Constructor.Data(Graph<U> graph, Index<U> users, Index<I> informationPieces, java.util.Map<java.lang.Integer,Information<I>> informationData, Relation<java.lang.Integer> userInformation, java.util.Map<java.lang.String,Index<F>> features, java.util.List<java.lang.String> featureNames, java.util.Map<java.lang.String,Relation<java.lang.Double>> featureRel, boolean userfeatures)Constructor.Data(Graph<U> graph, Index<U> users, Index<I> informationPieces, java.util.Map<java.lang.Integer,Information<I>> informationData, Relation<java.lang.Integer> userInformation, java.util.Map<java.lang.String,Index<F>> features, java.util.List<java.lang.String> userFeatureNames, java.util.Map<java.lang.String,Relation<java.lang.Double>> userFeatures, java.util.List<java.lang.String> infoPiecesFeatureNames, java.util.Map<java.lang.String,Relation<java.lang.Double>> infoPiecesFeatures)Full constructor.Data(Graph<U> graph, Index<U> users, Index<I> informationPieces, java.util.Map<java.lang.Integer,Information<I>> informationData, Relation<java.lang.Integer> userInformation, java.util.Map<java.lang.String,Index<F>> features, java.util.List<java.lang.String> userFeatureNames, java.util.Map<java.lang.String,Relation<java.lang.Double>> userFeatures, java.util.List<java.lang.String> infoPiecesFeatureNames, java.util.Map<java.lang.String,Relation<java.lang.Double>> infoPiecesFeatures, Relation<java.lang.Long> realPropagated)Full constructor. -
Method Summary
Modifier and Type Method Description private voidbuildTimestampPieces()Builds the relationship between timestamps and pairs (user, piece).booleancontainsFeatureValue(java.lang.String feature, F value)Checks if a feature value exists.booleancontainsInformationPiece(I i)Indicates if data contains a certain information piece.booleancontainsUser(U u)Indicates if a user is contained in the data.java.lang.StringdataSummary()Obtains a string containing a summary of the data.booleandoesFeatureExist(java.lang.String feature)Checks if a feature is stored in the data.java.util.stream.Stream<F>getAllFeatureValues(java.lang.String parameter)Gets all possible values for a certain parameter.java.util.stream.Stream<I>getAllInformationPieces()Obtain all information pieces.java.util.stream.Stream<U>getAllUsers()Obtain all users.java.util.stream.Stream<U>getCreators(I piece)Obtains the creators of a single information piece.Index<F>getFeatureIndex(java.lang.String param)Returns an index for a given parameter.Graph<U>getGraph()Obtains the graph.java.util.List<java.lang.String>getInfoPiecesFeatureNames()Obtains the names of the information piece features.java.util.stream.Stream<org.ranksys.core.util.tuples.Tuple2od<F>>getInfoPiecesFeatures(I info, java.lang.String param)Obtains the features for a single information piece.Information<I>getInformation(I piece)Obtains the extended information of an information pieceIndex<I>getInformationPiecesIndex()Obtains an index for the different information pieces.java.util.stream.Stream<org.ranksys.core.util.tuples.Tuple2od<I>>getInformationPiecesWithFeature(java.lang.String feature, F value)Obtains all information pieces with a certain feature value.java.util.stream.Stream<I>getPieces(U user)Obtains the information pieces created by a user.java.util.stream.Stream<I>getPiecesByTimestamp(long timestamp, U user)Obtains the list of pieces that a user has propagated in a given time.java.util.stream.Stream<I>getRealPropagatedPieces(U user)Given a user, obtains the set of information pieces repropagated in a real scenario.java.util.stream.Stream<Tuple2ol<I>>getRealPropagatedPiecesWithTimestamp(U user)Given a user, obtains the set of information pieces repropagated in a real scenario.longgetRealPropagatedTimestamp(U user, I info)Obtains the timestamp for an information piece.java.util.stream.Stream<U>getRealPropagatedUsers(I piece)Given an information piece, obtains the set of users that repropagated them in a real scenario.java.util.stream.Stream<I>getRealPropPiecesByTimestamp(long timestamp, U user)Obtains the list of pieces which have been repropagated by a user at a given time.java.util.stream.Stream<U>getRealPropUsersByTimestamp(long timestamp)Obtains the list of users which have repropagated pieces at a given time.longgetTimestamp(I info)Obtains the timestamp for an information piece.java.util.TreeSet<java.lang.Long>getTimestamps()Obtains the list of timestamps.java.util.List<java.lang.String>getUserFeatureNames()Obtains the names of the user features.java.util.stream.Stream<org.ranksys.core.util.tuples.Tuple2od<F>>getUserFeatures(U user, java.lang.String param)Obtains the features for a single user.Index<U>getUserIndex()Obtains a user index for creating relations.java.util.stream.Stream<U>getUsersByTimestamp(long timestamp)Obtains the list of users which have propagated pieces at a given time.java.util.stream.Stream<org.ranksys.core.util.tuples.Tuple2od<U>>getUsersWithFeature(java.lang.String feature, F value)Obtains all users with a certain feature value.booleanisInfoPieceFeature(java.lang.String feature)Checks if a feature exists, and it is an information piece feature.booleanisRealRepropagatedPiece(U user, I piece)Checks if a user repropagated or not an information piece.booleanisUserFeature(java.lang.String feature)Checks if a feature exists, and it is a user feature.intnumFeatureValues(java.lang.String parameter)Gets the number of possible values for a certain parameter.intnumInformationPieces()Obtains the number of information pieces.intnumUsers()Obtain the number of users in the simulation.
-
Field Details
-
users
User index. -
informationPieces
Information pieces index. -
informationPieceData
private final java.util.Map<java.lang.Integer,Information<I extends java.io.Serializable>> informationPieceDataAdditional information for the information pieces. -
features
Feature indexes (stored by the name of the parameter). -
userInformation
Relation between users and the propagated information (allows identifying both the information pieces created by a user, and the creator of the information piece. -
graph
The graph in which the simulation will run. -
userFeatureNames
private final java.util.List<java.lang.String> userFeatureNamesList of features related to each individual user. -
infoPiecesFeatureNames
private final java.util.List<java.lang.String> infoPiecesFeatureNamesList of features related to each information piece -
userFeatures
Relation between users and their features (allows identifying the users that share the same feature, as well as the features of the different users). -
infoPiecesFeatures
Relation between users and their features (allows identifying the information pieces that share the same feature, as well as the features of the different information pieces). -
realPropagated
Map containing the information pieces which have been really propagated by the user. -
timestamps
private java.util.TreeSet<java.lang.Long> timestampsOrdered set of timestamps when information pieces where published in real life. -
propagatedByTS
private final java.util.HashMap<java.lang.Long,java.util.HashMap<U extends java.io.Serializable,java.util.Set<I extends java.io.Serializable>>> propagatedByTSRelation between the timestamps and the pieces propagated by each user. -
realPropagatedByTS
private final java.util.HashMap<java.lang.Long,java.util.HashMap<U extends java.io.Serializable,java.util.Set<I extends java.io.Serializable>>> realPropagatedByTSRelation between the timestamps and the pieces repropagated by each user.
-
-
Constructor Details
-
Data
public Data(Graph<U> graph, Index<U> users, Index<I> informationPieces, Relation<java.lang.Integer> userInformation)Simplest constructor. There is no additional information for information pieces, nor features.- Parameters:
graph- the social network graph.users- the user index.informationPieces- information pieces index.userInformation- relation between users and information pieces.
-
Data
public Data(Graph<U> graph, Index<U> users, Index<I> informationPieces, java.util.Map<java.lang.Integer,Information<I>> informationData, Relation<java.lang.Integer> userInformation)Constructor. There is no additional information for information pieces, nor features.- Parameters:
graph- the social network graph.users- the user index.informationPieces- information pieces index.informationData- detailed information about the information pieces.userInformation- relation between users and information pieces.
-
Data
public Data(Graph<U> graph, Index<U> users, Index<I> informationPieces, java.util.Map<java.lang.Integer,Information<I>> informationData, Relation<java.lang.Integer> userInformation, java.util.Map<java.lang.String,Index<F>> features, java.util.List<java.lang.String> featureNames, java.util.Map<java.lang.String,Relation<java.lang.Double>> featureRel, boolean userfeatures)Constructor. Only user / information pieces features.- Parameters:
graph- the social network graph.users- the user index.informationPieces- information pieces index.informationData- detailed information about the information pieces.userInformation- relation between users and information pieces.features- indexes for the different features.featureNames- the names of the user/pieces features.featureRel- relation between users/pieces and their features.userfeatures- true if features are related to users, false if they are related to information pieces.
-
Data
public Data(Graph<U> graph, Index<U> users, Index<I> informationPieces, java.util.Map<java.lang.Integer,Information<I>> informationData, Relation<java.lang.Integer> userInformation, java.util.Map<java.lang.String,Index<F>> features, java.util.List<java.lang.String> userFeatureNames, java.util.Map<java.lang.String,Relation<java.lang.Double>> userFeatures, java.util.List<java.lang.String> infoPiecesFeatureNames, java.util.Map<java.lang.String,Relation<java.lang.Double>> infoPiecesFeatures)Full constructor.- Parameters:
graph- the social network graph.users- the user index.informationPieces- information pieces index.informationData- detailed information about the information pieces.userInformation- relation between users and information pieces.features- indexes for the different features.userFeatureNames- the names of the user features.userFeatures- relation between users and their features.infoPiecesFeatureNames- the name for information pieces features.infoPiecesFeatures- relation between information pieces and their features.
-
Data
public Data(Graph<U> graph, Index<U> users, Index<I> informationPieces, java.util.Map<java.lang.Integer,Information<I>> informationData, Relation<java.lang.Integer> userInformation, java.util.Map<java.lang.String,Index<F>> features, java.util.List<java.lang.String> userFeatureNames, java.util.Map<java.lang.String,Relation<java.lang.Double>> userFeatures, java.util.List<java.lang.String> infoPiecesFeatureNames, java.util.Map<java.lang.String,Relation<java.lang.Double>> infoPiecesFeatures, Relation<java.lang.Long> realPropagated)Full constructor.- Parameters:
graph- the social network graph.users- the user index.informationPieces- information pieces index.informationData- detailed information about the information pieces.userInformation- relation between users and information pieces.features- indexes for the different features.userFeatureNames- the names of the user features.userFeatures- relation between users and their features.infoPiecesFeatureNames- the name for information pieces features.infoPiecesFeatures- relation between information pieces and their features.realPropagated- relation indicating which information pieces were repropagated in real scenario.
-
-
Method Details
-
buildTimestampPieces
private void buildTimestampPieces()Builds the relationship between timestamps and pairs (user, piece). -
getAllUsers
Obtain all users.- Returns:
- a stream containing all users.
-
numUsers
public int numUsers()Obtain the number of users in the simulation.- Returns:
- the number of users.
-
getUserIndex
Obtains a user index for creating relations.- Returns:
- the user index.
-
getAllInformationPieces
Obtain all information pieces.- Returns:
- a stream containing all information pieces.
-
numInformationPieces
public int numInformationPieces()Obtains the number of information pieces.- Returns:
- the number of information pieces.
-
getInformationPiecesIndex
Obtains an index for the different information pieces.- Returns:
- the information pieces index.
-
getInformation
Obtains the extended information of an information piece- Parameters:
piece- the information piece.- Returns:
- the extended information if the piece exists, null if it does not.
-
getCreators
Obtains the creators of a single information piece.- Parameters:
piece- the piece.- Returns:
- a stream of creators, empty if there are none.
-
getPieces
Obtains the information pieces created by a user.- Parameters:
user- the user.- Returns:
- a stream of information pieces, empty if there are none.
-
getTimestamp
Obtains the timestamp for an information piece.- Parameters:
info- the information piece.- Returns:
- the timestamp in case it exists, -1 if it does not.
-
getGraph
Obtains the graph.- Returns:
- the graph.
-
getUserFeatures
public java.util.stream.Stream<org.ranksys.core.util.tuples.Tuple2od<F>> getUserFeatures(U user, java.lang.String param)Obtains the features for a single user.- Parameters:
user- the user.param- the parameter.- Returns:
- a stream of pairs (parameter,value), empty if there are none.
-
getInfoPiecesFeatures
public java.util.stream.Stream<org.ranksys.core.util.tuples.Tuple2od<F>> getInfoPiecesFeatures(I info, java.lang.String param)Obtains the features for a single information piece.- Parameters:
info- the information piece.param- the parameter.- Returns:
- a stream of pairs (parameter,value), empty if there are none.
-
getAllFeatureValues
Gets all possible values for a certain parameter.- Parameters:
parameter- the parameter name.- Returns:
- a stream containing all the possible values if the parameter exists, an empty stream if it does not.
-
numFeatureValues
public int numFeatureValues(java.lang.String parameter)Gets the number of possible values for a certain parameter.- Parameters:
parameter- the parameter name.- Returns:
- the number of possible features if the parameter exists, 0 if it does not.
-
getFeatureIndex
Returns an index for a given parameter.- Parameters:
param- the parameter name.- Returns:
- the index if it exists, null if it does not.
-
containsUser
Indicates if a user is contained in the data.- Parameters:
u- the user.- Returns:
- true if the user is contained in the data, false if it is not.
-
containsInformationPiece
Indicates if data contains a certain information piece.- Parameters:
i- the information piece.- Returns:
- true if the user is contained in the data, false if it is not.
-
doesFeatureExist
public boolean doesFeatureExist(java.lang.String feature)Checks if a feature is stored in the data.- Parameters:
feature- the feature name.- Returns:
- true if the feature exists, false otherwise.
-
isUserFeature
public boolean isUserFeature(java.lang.String feature)Checks if a feature exists, and it is a user feature.- Parameters:
feature- the feature name.- Returns:
- true if the feature exists, false otherwise.
-
isInfoPieceFeature
public boolean isInfoPieceFeature(java.lang.String feature)Checks if a feature exists, and it is an information piece feature.- Parameters:
feature- the feature name.- Returns:
- true if the feature exists, false otherwise.
-
getUserFeatureNames
public java.util.List<java.lang.String> getUserFeatureNames()Obtains the names of the user features.- Returns:
- a list containing the user features.
-
getInfoPiecesFeatureNames
public java.util.List<java.lang.String> getInfoPiecesFeatureNames()Obtains the names of the information piece features.- Returns:
- a list containing the information piece features.
-
containsFeatureValue
Checks if a feature value exists.- Parameters:
feature- the feature name.value- the feature value we want to check.- Returns:
- true if the value exists, false otherwise.
-
getUsersWithFeature
public java.util.stream.Stream<org.ranksys.core.util.tuples.Tuple2od<U>> getUsersWithFeature(java.lang.String feature, F value)Obtains all users with a certain feature value.- Parameters:
feature- the name of the feature.value- the value of the feature.- Returns:
- a stream containing the different pairs (user, value) that are represented by the value parameter.
-
getInformationPiecesWithFeature
public java.util.stream.Stream<org.ranksys.core.util.tuples.Tuple2od<I>> getInformationPiecesWithFeature(java.lang.String feature, F value)Obtains all information pieces with a certain feature value.- Parameters:
feature- the name of the feature.value- the value of the feature.- Returns:
- a stream containing the different pairs (infopiece, value) that are represented by the value parameter.
-
getRealPropagatedUsers
Given an information piece, obtains the set of users that repropagated them in a real scenario.- Parameters:
piece- the information piece.- Returns:
- the stream of users that repropagated the piece.
-
getRealPropagatedPieces
Given a user, obtains the set of information pieces repropagated in a real scenario.- Parameters:
user- the user.- Returns:
- the stream of pieces repropagated by the user.
-
getRealPropagatedPiecesWithTimestamp
Given a user, obtains the set of information pieces repropagated in a real scenario.- Parameters:
user- the user.- Returns:
- the stream of pieces repropagated by the user and their timestamps.
-
isRealRepropagatedPiece
Checks if a user repropagated or not an information piece.- Parameters:
user- the user.piece- the piece.- Returns:
- true if the user repropagated the piece, false if he/she did not.
-
getRealPropagatedTimestamp
Obtains the timestamp for an information piece.- Parameters:
user- the user.info- the piece.- Returns:
- the timestamp if the user repropagated the piece, -1 if he/she did not.
-
getTimestamps
public java.util.TreeSet<java.lang.Long> getTimestamps()Obtains the list of timestamps.- Returns:
- the list of timestamps.
-
getPiecesByTimestamp
Obtains the list of pieces that a user has propagated in a given time.- Parameters:
timestamp- the timestamp.user- the user.- Returns:
- an stream containing the pieces propagated by the user at the given time.
-
getRealPropPiecesByTimestamp
Obtains the list of pieces which have been repropagated by a user at a given time.- Parameters:
timestamp- the timestamp.user- the user.- Returns:
- an stream containing the pieces repropagated by the user at the given time.
-
getUsersByTimestamp
Obtains the list of users which have propagated pieces at a given time.- Parameters:
timestamp- the timestamp.- Returns:
- a stream containing all users which have propagated information at the given time.
-
getRealPropUsersByTimestamp
Obtains the list of users which have repropagated pieces at a given time.- Parameters:
timestamp- the timestamp.- Returns:
- a stream containing all users which have repropagated information at the given time.
-
dataSummary
public java.lang.String dataSummary()Obtains a string containing a summary of the data.- Returns:
- The summary of the data.
-