Class AlternativeGiniFastGreedy<U>
java.lang.Object
es.uam.eps.ir.relison.sna.community.detection.modularity.balanced.AlternativeGiniFastGreedy<U>
- Type Parameters:
U- Type of the users
- All Implemented Interfaces:
CommunityDetectionAlgorithm<U>,DendogramCommunityDetectionAlgorithm<U>
public class AlternativeGiniFastGreedy<U> extends java.lang.Object implements CommunityDetectionAlgorithm<U>, DendogramCommunityDetectionAlgorithm<U>
Alternative version of Fast Greedy algorithm for optimizing modularity, taking into account the Gini of the size
of communities.
-
Field Summary
Fields Modifier and Type Field Description private doublelambdaBalance between modularity and the Gini of the size of communitiesprivate intoptimalNumCommsThe optimal number of communities. -
Constructor Summary
Constructors Constructor Description AlternativeGiniFastGreedy(double lambda)Constructor. -
Method Summary
Modifier and Type Method Description Communities<U>detectCommunities(Graph<U> graph)Computes the communities for a certain graph.Dendogram<U>detectCommunityDendogram(Graph<U> graph)Computes the community dendogram for a certain graph.private org.jooq.lambda.tuple.Tuple4<java.lang.Integer,java.lang.Integer,java.lang.Double,java.lang.Double>findOptimalJoint(Graph<U> graph, Communities<U> comm, it.unimi.dsi.fastutil.doubles.Double2DoubleMap freqs, java.util.List<java.lang.Double> sizes, double oldGini)Finds the optimal two communities to join.private doublenorm(double value, es.uam.eps.ir.ranksys.core.util.Stats stats)Normalizes scores, following a Min-Max convention.
-
Field Details
-
lambda
private final double lambdaBalance between modularity and the Gini of the size of communities -
optimalNumComms
private int optimalNumCommsThe optimal number of communities.
-
-
Constructor Details
-
AlternativeGiniFastGreedy
public AlternativeGiniFastGreedy(double lambda)Constructor.- Parameters:
lambda- balance between modularity and the Gini of the size of communities
-
-
Method Details
-
detectCommunities
Description copied from interface:CommunityDetectionAlgorithmComputes the communities for a certain graph.- Specified by:
detectCommunitiesin interfaceCommunityDetectionAlgorithm<U>- Parameters:
graph- The full graph.- Returns:
- The communities if everything went OK, null if not.
-
detectCommunityDendogram
Description copied from interface:DendogramCommunityDetectionAlgorithmComputes the community dendogram for a certain graph.- Specified by:
detectCommunityDendogramin interfaceDendogramCommunityDetectionAlgorithm<U>- Parameters:
graph- The full graph.- Returns:
- The dendogram if everything went OK, null if not.
-
findOptimalJoint
private org.jooq.lambda.tuple.Tuple4<java.lang.Integer,java.lang.Integer,java.lang.Double,java.lang.Double> findOptimalJoint(Graph<U> graph, Communities<U> comm, it.unimi.dsi.fastutil.doubles.Double2DoubleMap freqs, java.util.List<java.lang.Double> sizes, double oldGini)Finds the optimal two communities to join.- Parameters:
graph- The graphcomm- The current community divisionfreqs- map containing the sizes of communities as keys, and the number of communities with that size as value (thus allowing fast Gini computing)sizes- community sizes.oldGini- Gini for the previous iteration.- Returns:
- A 4-tuple containing: the id for the first comm. to join, the identifier for the second, the modularity increment and the Gini increment.
-
norm
private double norm(double value, es.uam.eps.ir.ranksys.core.util.Stats stats)Normalizes scores, following a Min-Max convention.- Parameters:
value- The original valuestats- The statistics of the distribution- Returns:
- the normalized value.
-