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

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

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

Computes the average two-terminal reliability coefficient of a graph. This coefficient is defined as f/t where:
- f is the number of node-pairs (u,v) for which there is a path from u to v,
- t is the total number of possible paths when the graph is connected.


Constructor Summary
AvgTwoTermReliability()
          Default constructor.
AvgTwoTermReliability(SimGraph<V,E> g, Environ env)
          Creates a new instance.
 
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 the Avg. 2-term. reliability.
 java.lang.String getLabel()
          Returns "Avg. 2-term. reliability".
 boolean isApplicableTo(MetricTarget m)
          Returns true if m is MetricTarget.GRAPH.
 void run()
          Computes the average two-terminal reliability.
 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, getGraphMetricStdev, getName, getNodeMetric
 
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, getGraphMetricStdev, getNodeMetric
 
Methods inherited from interface bcds.phison.WithEnvParams
getEnviron, getEnvParams, getName
 

Constructor Detail

AvgTwoTermReliability

public AvgTwoTermReliability()
Default constructor. To complete the initialization, setup(SimGraph, Environ) must be called.


AvgTwoTermReliability

public AvgTwoTermReliability(SimGraph<V,E> g,
                             Environ env)
Creates a new instance. Calls setup(bcds.phison.SimGraph, bcds.tools.Environ) to complete the inialization.

Method Detail

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>

isApplicableTo

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

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

run

public void run()
Computes the average two-terminal reliability. The computation is as follows:
   sum = 0
   for each strongly_connected_component C in g:
       sum += |C| * (|C|-1)
   end
   return sum / (|V| * (|V|-1))
 
Note that the numerator, the denominator or both above may be zero.

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

getGraphMetric

public double getGraphMetric()
Returns the Avg. 2-term. reliability.

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

getLabel

public java.lang.String getLabel()
Returns "Avg. 2-term. reliability".

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>