public class LeidenAlgorithm extends IterativeCPMClusteringAlgorithm
The Leiden algorithm consists of three phases:
These phases are repeated until no further improvements can be made. By
default, local moving of nodes is performed using the FastLocalMovingAlgorithm
.
Modifier and Type | Field and Description |
---|---|
static double |
DEFAULT_RANDOMNESS
Default randomness parameter.
|
protected IncrementalCPMClusteringAlgorithm |
localMovingAlgorithm
Local moving algorithm.
|
protected java.util.Random |
random
Random number generator.
|
protected double |
randomness
Randomness parameter.
|
DEFAULT_N_ITERATIONS, nIterations
DEFAULT_RESOLUTION, resolution
Constructor and Description |
---|
LeidenAlgorithm()
Constructs a Leiden algorithm.
|
LeidenAlgorithm(double resolution,
int nIterations,
double randomness,
IncrementalCPMClusteringAlgorithm localMovingAlgorithm,
java.util.Random random)
Constructs a Leiden algorithm for a specified resolution parameter,
number of iterations, randomness parameter, and local moving algorithm.
|
LeidenAlgorithm(double resolution,
int nIterations,
double randomness,
java.util.Random random)
Constructs a Leiden algorithm for a specified resolution parameter,
number of iterations, and randomness parameter.
|
LeidenAlgorithm(java.util.Random random)
Constructs a Leiden algorithm.
|
Modifier and Type | Method and Description |
---|---|
LeidenAlgorithm |
clone()
Clones the algorithm.
|
IncrementalCPMClusteringAlgorithm |
getLocalMovingAlgorithm()
Returns the local moving algorithm.
|
double |
getRandomness()
Returns the randomness parameter.
|
protected boolean |
improveClusteringOneIteration(Network network,
Clustering clustering)
Improves a clustering by performing one iteration of the Leiden
algorithm.
|
void |
setLocalMovingAlgorithm(IncrementalCPMClusteringAlgorithm localMovingAlgorithm)
Sets the local moving algorithm.
|
void |
setRandomness(double randomness)
Sets the randomness parameter.
|
void |
setResolution(double resolution)
Sets the resolution parameter.
|
getNIterations, improveClustering, setNIterations
findClustering
calcQuality, getResolution, removeCluster, removeSmallClustersBasedOnNNodes, removeSmallClustersBasedOnWeight
public static final double DEFAULT_RANDOMNESS
protected double randomness
protected IncrementalCPMClusteringAlgorithm localMovingAlgorithm
protected java.util.Random random
public LeidenAlgorithm()
public LeidenAlgorithm(java.util.Random random)
random
- Random number generatorpublic LeidenAlgorithm(double resolution, int nIterations, double randomness, java.util.Random random)
resolution
- Resolution parameternIterations
- Number of iterationsrandomness
- Randomness parameterrandom
- Random number generatorpublic LeidenAlgorithm(double resolution, int nIterations, double randomness, IncrementalCPMClusteringAlgorithm localMovingAlgorithm, java.util.Random random)
resolution
- Resolution parameternIterations
- Number of iterationsrandomness
- Randomness parameterlocalMovingAlgorithm
- Local moving algorithmrandom
- Random number generatorpublic LeidenAlgorithm clone()
clone
in class CPMClusteringAlgorithm
public double getRandomness()
public IncrementalCPMClusteringAlgorithm getLocalMovingAlgorithm()
public void setResolution(double resolution)
setResolution
in class CPMClusteringAlgorithm
resolution
- Resolution parameterpublic void setRandomness(double randomness)
randomness
- Randomness parameterpublic void setLocalMovingAlgorithm(IncrementalCPMClusteringAlgorithm localMovingAlgorithm)
localMovingAlgorithm
- Local moving algorithmprotected boolean improveClusteringOneIteration(Network network, Clustering clustering)
The Leiden algorithm consists of three phases:
These phases are repeated until no further improvements can be made.
improveClusteringOneIteration
in class IterativeCPMClusteringAlgorithm
network
- Networkclustering
- Clustering