bcds.phison.gm
Class ClusteringCoeff<V,E>

java.lang.Object
  extended by bcds.phison.gm.GraphMetricBase<V,E>
      extended by bcds.phison.gm.ClusteringCoeff<V,E>
All Implemented Interfaces:
GraphMetric<V,E>, WithEnvParams

public class ClusteringCoeff<V,E>
extends GraphMetricBase<V,E>
implements GraphMetric<V,E>

Computes the (local) clustering coefficient of each node in a graph. The clustering coefficient of a node v is:
- 0 if node_degree(v) == 0.
- 1 if node_degree(v) == 1.
- the fraction of v's neighbours that are also neighbours of each other if node_degree(v) > 1.

It is required that each link is present in its two directions, that is, that the graph is "undirected" in practice.

The clustering coefficient of the whole graph is the average of the local coefficients.

Author:
Juan Segovia S.

Constructor Summary
ClusteringCoeff()
          Default constructor.
ClusteringCoeff(SimGraph<V,E> g, Environ env)
          Creates a new instance and calls setup to complete the initialization.
 
Method Summary
 java.lang.String getDescription()
          Returns a string describing the metric, for example, article where it has been published, URL where to find reference implementation, etc.
 double getGraphMetric()
          Returns clustering coefficient of the graph.
 double getGraphMetricStdev()
          Returns the standard deviation of the clustering coefficient.
 java.lang.String getLabel()
          Returns "Clustering coefficient".
 java.util.Map<V,java.lang.Double> getNodeMetric()
          Returns the map holding the clustering coefficient of each node.
 boolean isApplicableTo(MetricTarget m)
          Returns true if m is MetricTarget.GRAPH or NODE.
 void run()
          Computes and stores internally the local clustering coefficient of each node.
 void setup(SimGraph<V,E> g, Environ env)
          Saves the parameters for future use.
 
Methods inherited from class bcds.phison.gm.GraphMetricBase
dump, getEdgeMetric, getEnviron, getEnvParams, getGraph, getName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface bcds.phison.gm.GraphMetric
dump, getEdgeMetric
 
Methods inherited from interface bcds.phison.WithEnvParams
getEnviron, getEnvParams, getName
 

Constructor Detail

ClusteringCoeff

public ClusteringCoeff()
Default constructor.


ClusteringCoeff

public ClusteringCoeff(SimGraph<V,E> g,
                       Environ env)
Creates a new instance and calls setup to complete the initialization.

Method Detail

isApplicableTo

public boolean isApplicableTo(MetricTarget m)
Returns true if m is MetricTarget.GRAPH or NODE.

Specified by:
isApplicableTo in interface GraphMetric<V,E>
Overrides:
isApplicableTo in class GraphMetricBase<V,E>

setup

public void setup(SimGraph<V,E> g,
                  Environ env)
Description copied from class: GraphMetricBase
Saves the parameters for future use. The parameter g must not be null. If env is null, a new empty environment is created. Default values are incorporated by calling getEnvParams and the types of already-present values are adapted, if possible.

Specified by:
setup in interface GraphMetric<V,E>
Overrides:
setup in class GraphMetricBase<V,E>

run

public void run()
Computes and stores internally the local clustering coefficient of each node.

Specified by:
run in interface GraphMetric<V,E>
Overrides:
run in class GraphMetricBase<V,E>
Throws:
java.lang.IllegalArgumentException - if there is a link running only in one direction.

getGraphMetric

public double getGraphMetric()
Returns clustering coefficient of the graph. If run has not been called, returns NaN.

Specified by:
getGraphMetric in interface GraphMetric<V,E>
Overrides:
getGraphMetric in class GraphMetricBase<V,E>

getGraphMetricStdev

public double getGraphMetricStdev()
Returns the standard deviation of the clustering coefficient.

Specified by:
getGraphMetricStdev in interface GraphMetric<V,E>
Overrides:
getGraphMetricStdev in class GraphMetricBase<V,E>

getNodeMetric

public java.util.Map<V,java.lang.Double> getNodeMetric()
Returns the map holding the clustering coefficient of each node.

Specified by:
getNodeMetric in interface GraphMetric<V,E>
Overrides:
getNodeMetric in class GraphMetricBase<V,E>

getLabel

public java.lang.String getLabel()
Returns "Clustering coefficient".

Specified by:
getLabel in interface GraphMetric<V,E>

getDescription

public java.lang.String getDescription()
Description copied from interface: GraphMetric
Returns a string describing the metric, for example, article where it has been published, URL where to find reference implementation, etc.

Specified by:
getDescription in interface GraphMetric<V,E>