netkit.util
Class HistogramCategorical

java.lang.Object
  extended by netkit.util.Histogram
      extended by netkit.util.HistogramCategorical

public final class HistogramCategorical
extends Histogram

This class represents a histogram on Node field values which have CATEGORICAL type. The histogram keeps track of unique values and a running of how many times each value appeared.

Author:
Kaveh R. Ghazi
See Also:
AttributeCategorical, Node

Field Summary
 
Fields inherited from class netkit.util.Histogram
cMap
 
Constructor Summary
HistogramCategorical(double[] values, AttributeCategorical attribute)
          This constructor is a convenience for accepting all values without any minimum occurance.
HistogramCategorical(double[] values, AttributeCategorical attribute, int minOccurance)
          This constructor creates a histogram object given an array of values and an attribute type.
HistogramCategorical(Edge[] edges, AttributeCategorical attribute)
          This constructor is a convenience for accepting all edge values without any minimum occurance.
HistogramCategorical(Edge[] edges, AttributeCategorical attribute, int minOccurance)
          This constructor creates a histogram object given an array of edges and an attribute from which to get the values.
HistogramCategorical(Node[] nodes, AttributeCategorical attribute)
          This constructor is a convenience for accepting all node values without any minimum occurance.
HistogramCategorical(Node[] nodes, AttributeCategorical attribute, int minOccurance)
          This constructor creates a histogram object given an array of nodes and an attribute from which to get the values.
 
Method Summary
 AttributeCategorical getAttribute()
          Gets the attribute associated with this histogram.
 double getCount(java.lang.String token)
          Gets the number of times a particular categorical token appears in this histogram.
 
Methods inherited from class netkit.util.Histogram
getCount, getDistribution, getMode, getSet, getTotalCount, main
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HistogramCategorical

public HistogramCategorical(double[] values,
                            AttributeCategorical attribute)
This constructor is a convenience for accepting all values without any minimum occurance.

Parameters:
values - the array of double values for this object.
attribute - the attribute describing the field type.

HistogramCategorical

public HistogramCategorical(double[] values,
                            AttributeCategorical attribute,
                            int minOccurance)
This constructor creates a histogram object given an array of values and an attribute type. It also checks that values appear at least minOccurance times before including them.

Parameters:
values - the array of double values for this object.
attribute - the attribute describing the field type.
minOccurance - the minimum number of times a value must occur before being kept in this histogram.
Throws:
java.lang.RuntimeException - if minOccurance is less than 1.

HistogramCategorical

public HistogramCategorical(Edge[] edges,
                            AttributeCategorical attribute)
This constructor is a convenience for accepting all edge values without any minimum occurance.

Parameters:
edges - the array of Edges from which to get values.
attribute - the attribute describing which field in the Node to get values from.

HistogramCategorical

public HistogramCategorical(Node[] nodes,
                            AttributeCategorical attribute)
This constructor is a convenience for accepting all node values without any minimum occurance.

Parameters:
nodes - the array of Nodes from which to get values.
attribute - the attribute describing which field in the Node to get values from.

HistogramCategorical

public HistogramCategorical(Node[] nodes,
                            AttributeCategorical attribute,
                            int minOccurance)
This constructor creates a histogram object given an array of nodes and an attribute from which to get the values. It also checks that values appear at least minOccurance times before including them.

Parameters:
nodes - the array of Nodes from which to get values.
attribute - the attribute describing the field in the Node to get values from.
minOccurance - the minimum number of times a value must occur before being kept in this histogram.
Throws:
java.lang.RuntimeException - if minOccurance is less than 1.

HistogramCategorical

public HistogramCategorical(Edge[] edges,
                            AttributeCategorical attribute,
                            int minOccurance)
This constructor creates a histogram object given an array of edges and an attribute from which to get the values. Each edge counts the destination-node's attribute edge-weight times. It also checks that values appear at least minOccurance times before including them.

Parameters:
edges - the array of Edges from which to get values.
attribute - the attribute describing the field in the Node to get values from.
minOccurance - the minimum number of times a value must occur before being kept in this histogram.
Throws:
java.lang.RuntimeException - if minOccurance is less than 1.
Method Detail

getAttribute

public AttributeCategorical getAttribute()
Gets the attribute associated with this histogram.

Returns:
the attribute associated with this histogram.

getCount

public double getCount(java.lang.String token)
Gets the number of times a particular categorical token appears in this histogram.

Parameters:
token - the token to lookup in the histogram.
Returns:
the number of times a particular categorical token appears in this histogram.
Throws:
java.lang.RuntimeException - if the token isn't valid for this histogram's attribute.
java.lang.NullPointerException - if the token value doesn't exist in this histogram.