Class SurpriseMeasure
java.lang.Object
org.graphstream.algorithm.measure.SurpriseMeasure
- All Implemented Interfaces:
Algorithm
public class SurpriseMeasure extends Object implements Algorithm
Surprise measure.
Description from Wikipedia :
Surprise (denoted S) is a measure of community structure in complex networks.
The name Surprise derives from the fact that its maximization finds the most
surprising partition into communities of the network, that is, the most
unlikely one. S accurately evaluates, in a global manner, the quality of a
partition using a cumulative hypergeometric distribution.
- Scientific Reference :
- Rodrigo Aldecoa, Ignacio Marin, "Deciphering Network Community Structure by Surprise", 2011, PLoS ONE 6(9)
-
Field Summary
-
Constructor Summary
Constructors Constructor Description SurpriseMeasure()
Default constructor.SurpriseMeasure(String communityAttributeKey)
Constructor allowing to set the node attribute key containing index of organizations.SurpriseMeasure(String communityAttributeKey, String surpriseAttributeKey)
Same asSurpriseMeasure(String)
but allowing to set the graph attribute that will contain the result of the computation. -
Method Summary
Modifier and Type Method Description static double
binomialCoefficient(double n, double r)
Helper to compute the binomial coefficient.void
compute()
Run the algorithm.static double
cumulativeHypergeometricDistribution(double xStart, double xEnd, double N, double n, double k)
Helper to compute the cumulative hypergeometric distribution.String
defaultResult()
double
getSurprise()
Get the last computed surprise value contained in the graph.static double
hypergeometricDistribution(double x, double N, double n, double k)
Helper to compute the hypergeometric distribution.void
init(org.graphstream.graph.Graph graph)
Initialization of the algorithm.void
setCommunityAttributeKey(String communityAttributeKey)
-
Field Details
-
ATTRIBUTE
Default attribute key where the result of the algorithm, a double value, is stored.- See Also:
- Constant Field Values
-
-
Constructor Details
-
SurpriseMeasure
public SurpriseMeasure()Default constructor. -
SurpriseMeasure
Constructor allowing to set the node attribute key containing index of organizations.- Parameters:
communityAttributeKey
- key attribute of organizations
-
SurpriseMeasure
Same asSurpriseMeasure(String)
but allowing to set the graph attribute that will contain the result of the computation.- Parameters:
communityAttributeKey
- community attribute keysurpriseAttributeKey
- surprise attribute key
-
-
Method Details
-
init
public void init(org.graphstream.graph.Graph graph)Description copied from interface:Algorithm
Initialization of the algorithm. This method has to be called before theAlgorithm.compute()
method to initialize or reset the algorithm according to the new given graph. -
compute
public void compute()Description copied from interface:Algorithm
Run the algorithm. TheAlgorithm.init(Graph)
method has to be called before computing.- Specified by:
compute
in interfaceAlgorithm
- See Also:
Algorithm.init(Graph)
-
defaultResult
-
setCommunityAttributeKey
-
getSurprise
public double getSurprise()Get the last computed surprise value contained in the graph.- Returns:
- surprise value
-
binomialCoefficient
public static double binomialCoefficient(double n, double r)Helper to compute the binomial coefficient.- Parameters:
n
- number of elements in setr
- number of elements- Returns:
- the binomial coefficient
-
hypergeometricDistribution
public static double hypergeometricDistribution(double x, double N, double n, double k)Helper to compute the hypergeometric distribution. See this page for more information about this function.- Parameters:
x
- xN
- Nn
- nk
- k- Returns:
- hypergeometric Distribution
-
cumulativeHypergeometricDistribution
public static double cumulativeHypergeometricDistribution(double xStart, double xEnd, double N, double n, double k)Helper to compute the cumulative hypergeometric distribution. See this page for more information about this function.- Parameters:
xStart
- xStartxEnd
- xEndN
- Nn
- nk
- k- Returns:
- Cumulative Hypergeometric Distribution
-