Class Infomap<U extends java.io.Serializable>
java.lang.Object
es.uam.eps.ir.relison.sna.community.detection.modularity.Infomap<U>
- Type Parameters:
U
- Type of the users.
- All Implemented Interfaces:
CommunityDetectionAlgorithm<U>
public class Infomap<U extends java.io.Serializable> extends java.lang.Object implements CommunityDetectionAlgorithm<U>
Community detection algorithm using the Infomap algorithm.
Uses the Infomap C++ implementation by Rosvall and Bergstrom (link), downloaded at 06 November 2018.
Reference: M. Rosvall and C. Bergstrom. Maps of random walks on complex networks reveal community structure. Proceedings of the National Academy of Sciences 105(4), pp. 1118-1123 (2008)
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
DOWNLOADLINK
Download link for the Infomap C++ library.private java.lang.String
exec
Executable path.private int
numTrials
Number of trials.private static int
NUMTRIALS
Pre-fixed number of trials.private static int
RANDOMSEED
Pre-fixed random seedint
seed
Random seed.private java.lang.String
temp
Temporary path where we want to store the auxiliar networks. -
Constructor Summary
Constructors Constructor Description Infomap(java.lang.String temp)
Constructor.Infomap(java.lang.String temp, int numTrials)
Constructor.Infomap(java.lang.String temp, int numTrials, int seed)
Constructor.Infomap(java.lang.String exec, java.lang.String temp)
Constructor.Infomap(java.lang.String exec, java.lang.String temp, int numTrials)
Constructor.Infomap(java.lang.String exec, java.lang.String temp, int numTrials, int seed)
Full constructor. -
Method Summary
Modifier and Type Method Description Communities<U>
detectCommunities(Graph<U> graph)
Computes the communities for a certain graph.private Communities<U>
detectCommunities(Graph<U> graph, java.lang.String network, java.lang.String path)
Method that calls the Infomap community detector, and executes it.
-
Field Details
-
DOWNLOADLINK
private static final java.lang.String DOWNLOADLINKDownload link for the Infomap C++ library.- See Also:
- Constant Field Values
-
RANDOMSEED
private static final int RANDOMSEEDPre-fixed random seed- See Also:
- Constant Field Values
-
NUMTRIALS
private static final int NUMTRIALSPre-fixed number of trials.- See Also:
- Constant Field Values
-
seed
public final int seedRandom seed. -
exec
private java.lang.String execExecutable path. -
temp
private final java.lang.String tempTemporary path where we want to store the auxiliar networks. -
numTrials
private final int numTrialsNumber of trials.
-
-
Constructor Details
-
Infomap
public Infomap(java.lang.String exec, java.lang.String temp, int numTrials, int seed)Full constructor.- Parameters:
exec
- location of the executabletemp
- location of temporal files.numTrials
- number of trials before obtaining the communities.seed
- the random seed.
-
Infomap
public Infomap(java.lang.String exec, java.lang.String temp, int numTrials)Constructor. Sets the random seed at a prefixed value.- Parameters:
exec
- location of the executable.temp
- location of the temporal files.numTrials
- number of trials before obtaining the communities.
-
Infomap
public Infomap(java.lang.String exec, java.lang.String temp)Constructor. Sets the number of trials and the random seed at a prefixed value.- Parameters:
exec
- path to the Infomap executable for directed networks.temp
- Temporary path where we want to store the auxiliar networks.
-
Infomap
public Infomap(java.lang.String temp)Constructor. Sets the number of trials and the random seed at a prefixed value. It copies the executable from the resources folder into the temporary files folder.- Parameters:
temp
- temporary path where we want to store all the auxiliar networks.
-
Infomap
public Infomap(java.lang.String temp, int numTrials)Constructor. Sets the number of trials and the random seed at a prefixed value. It copies the executable from the resources folder into the temporary files folder.- Parameters:
temp
- temporary path where we want to store all the auxiliar networks.numTrials
- number of trials before obtaining the communities.
-
Infomap
public Infomap(java.lang.String temp, int numTrials, int seed)Constructor. Sets the number of trials and the random seed at a prefixed value. It copies the executable from the resources folder into the temporary files folder.- Parameters:
temp
- temporary path where we want to store all the auxiliar networks.numTrials
- number of trials before obtaining the communities.seed
- the random seed.
-
-
Method Details
-
detectCommunities
Description copied from interface:CommunityDetectionAlgorithm
Computes the communities for a certain graph.- Specified by:
detectCommunities
in interfaceCommunityDetectionAlgorithm<U extends java.io.Serializable>
- Parameters:
graph
- The full graph.- Returns:
- The communities if everything went OK, null if not.
-
detectCommunities
private Communities<U> detectCommunities(Graph<U> graph, java.lang.String network, java.lang.String path)Method that calls the Infomap community detector, and executes it.- Parameters:
graph
- the network graph.network
- a name of a file containing the network.path
- the path where the network is contained.- Returns:
- the communities
-