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

java.lang.Object
  extended by bcds.phison.gm.GraphMetricBase<V,E>
      extended by bcds.phison.gm.Diameter<V,E>
All Implemented Interfaces:
GraphMetric<V,E>, WithEnvParams
Direct Known Subclasses:
AvgPathLength, SymmetryRatio

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

Computes the network diameter, identifies the path that corresponds to that diameter and computes the average of the shortest paths. This implementations uses MinHop for finding the shortest paths. It is required that each link is present in its two directions, that is, that the graph is "undirected" in practice. If the graph is disconnected, a runtime exception is thrown.

By default, the link cost is 1, so that the shortest path is the one with the fewer hops. To use another link cost, a non-null value can be put in the environment parameter cost_map.

Author:
Juan Segovia S.

Constructor Summary
Diameter()
          Default constructor.
Diameter(SimGraph<V,E> g, Environ env)
          Creates a new instance and calls setup to complete the initialization.
 
Method Summary
 float getAvgShortestPath()
          Returns the average of the shortest paths, computed by run.
 float getAvgShortestPathStdev()
          Returns the standard deviation of the average of the shortest paths, computed by run.
 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.
 java.lang.Object[] getEnvParams()
          Returns the environment parameters used by this class.
 double getGraphMetric()
          Returns the network diameter.
 java.lang.String getLabel()
          Returns the string "Diameter".
 Path<V,E> getLongestPath()
          Returns the path that corresponds to the diameter, computed by run.
 boolean isApplicableTo(MetricTarget m)
          Returns true if m is MetricTarget.GRAPH.
 void run()
          Computes all the metrics offered by this class and store them for later retrieval.
 void setup(SimGraph<V,E> g, Environ env)
          Makes sure all links in the topology are bidirectional.
 
Methods inherited from class bcds.phison.gm.GraphMetricBase
dump, getEdgeMetric, getEnviron, 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, getName
 

Constructor Detail

Diameter

public Diameter()
Default constructor.


Diameter

public Diameter(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.

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)
Makes sure all links in the topology are bidirectional.

Specified by:
setup in interface GraphMetric<V,E>
Overrides:
setup in class GraphMetricBase<V,E>
Throws:
java.lang.IllegalArgumentException - if there a exists a link with only one direction.
java.lang.RuntimeException - if "cost_map" is not a map of edges to numbers.

run

public void run()
Computes all the metrics offered by this class and store them for later retrieval.

Specified by:
run in interface GraphMetric<V,E>
Overrides:
run in class GraphMetricBase<V,E>
Throws:
java.lang.IllegalArgumentException - if the graph is not fully connected.

getGraphMetric

public double getGraphMetric()
Returns the network diameter.

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

getLabel

public java.lang.String getLabel()
Returns the string "Diameter".

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>

getLongestPath

public Path<V,E> getLongestPath()
Returns the path that corresponds to the diameter, computed by run.


getAvgShortestPath

public float getAvgShortestPath()
Returns the average of the shortest paths, computed by run.


getAvgShortestPathStdev

public float getAvgShortestPathStdev()
Returns the standard deviation of the average of the shortest paths, computed by run.


getEnvParams

public java.lang.Object[] getEnvParams()
Returns the environment parameters used by this class. The following parameters are defined (the prefix is "Diameter."):

Specified by:
getEnvParams in interface WithEnvParams
Overrides:
getEnvParams in class GraphMetricBase<V,E>