netkit.classifiers.aggregators
Class AggregatorImp

java.lang.Object
  extended by netkit.classifiers.aggregators.AggregatorImp
All Implemented Interfaces:
Aggregator
Direct Known Subclasses:
AggregatorByValueImp, Max, Mean, Min, Mode

public abstract class AggregatorImp
extends java.lang.Object
implements Aggregator

This should be the parent for any Aggregator class. It sets up the basic structure for an Aggregator and defines most of the needed API. The only thing needed to be implemented by any subclass is the getValue(Node, Estimate) method.

Author:
Sofus A. Macskassy (sofmac@gmail.com)
See Also:
Attribute, Attributes, Node

Field Summary
protected  SharedNodeInfo aggregateCache
           
protected  int attribIdx
           
protected  Attribute attribute
           
protected  EdgeType edgeType
           
protected  java.lang.String name
           
protected  Type type
           
 
Constructor Summary
  AggregatorImp(java.lang.String aggName, EdgeType edgeType, Attribute attribute, Type type)
          Creates an aggregator that is not by value (it calls the more specific constructor with a 'value' of Double.NaN).
protected AggregatorImp(java.lang.String aggName, EdgeType edgeType, Attribute attribute, Type type, double value)
          Helper constructor for AggregatorByValueImp - an aggregator for a specific attribute value.
 
Method Summary
 Attribute getAttribute()
          What is the attribute that is being aggregated
protected  int getAttributeIndex(java.lang.String nodeType)
          Get the index of the attribute in the instance vector array--we need to go through a node to get at this information.
 EdgeType getEdgeType()
          What is the relation that should be used to get at the neighbors of an instance
 java.lang.String getName()
          Gets the name of the field represented by this object.
protected  SharedNodeInfo getNodeInfo(Node node)
          This is cached aggregation information about the node as is relevant to the relationship that this aggregator uses.
 Type getType()
          Gets the Type of the value stored in this object.
 double getValue(Node n)
          Aggregate around the given node in the graph and return the result.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface netkit.classifiers.aggregators.Aggregator
getValue
 

Field Detail

name

protected final java.lang.String name

aggregateCache

protected SharedNodeInfo aggregateCache

attribute

protected final Attribute attribute

type

protected final Type type

edgeType

protected final EdgeType edgeType

attribIdx

protected int attribIdx
Constructor Detail

AggregatorImp

protected AggregatorImp(java.lang.String aggName,
                        EdgeType edgeType,
                        Attribute attribute,
                        Type type,
                        double value)
Helper constructor for AggregatorByValueImp - an aggregator for a specific attribute value. We need this here to correctly set the name of the Aggregator. If this is not aggregating by a specific value, then call it with a 'value' of Double.NaN. The name of this virtual attribute is created by appending the aggName, edgeType, and attribute name. If the 'value' is not NaN, then append the value. If the attribute is categorical, then this will be the token represented by the double. It will otherwise by the double value (cast as an integer if the attribute type is DISCRETE).

Parameters:
aggName - The prefix name of this aggregated attribute. Normally the name of the aggregator (e.g., 'min' or 'max')
edgeType - The name of the edge type to traverse to get at the neighboring nodes
attribute - The attribute of the neighbor nodes to aggregate over
type - The attribute type of this aggregator
value - The value of the attribute to aggregate on (e.g., the double representing 'red'). Use Double.NaN if it is not aggregating by value.
See Also:
netkit.classifiers.aggregators.AggregatorImp#AggregatorImp(String, String, netkit.graph.Attribute, netkit.graph.Type), java.lang.Double.NaN

AggregatorImp

public AggregatorImp(java.lang.String aggName,
                     EdgeType edgeType,
                     Attribute attribute,
                     Type type)
Creates an aggregator that is not by value (it calls the more specific constructor with a 'value' of Double.NaN). The name of this virtual attribute is created by appending aggName, edgeType, and attribute name.

Parameters:
aggName - The prefix name of this aggregated attribute. Normally the name of the aggregator (e.g., 'min' or 'max')
edgeType - The name of the edge type to traverse to get at the neighboring nodes
attribute - The attribute of the neighbor nodes to aggregate over
type - The attribute type of this aggregator
See Also:
netkit.classifiers.aggregators.AggregatorImp#AggregatorImp(String, String, netkit.graph.Attribute, netkit.graph.Type, double)
Method Detail

getName

public final java.lang.String getName()
Description copied from interface: Aggregator
Gets the name of the field represented by this object.

Specified by:
getName in interface Aggregator
Returns:
The name of this aggregated attribute

getAttributeIndex

protected final int getAttributeIndex(java.lang.String nodeType)
Get the index of the attribute in the instance vector array--we need to go through a node to get at this information. This information tells us where in the instance vector array to get the attribute value for the attribute that is to be aggregated on.

Parameters:
nodeType - The type of the node through which we can access the attribute array information
Returns:
the index of the attribute in the instance vector array

getAttribute

public final Attribute getAttribute()
What is the attribute that is being aggregated

Specified by:
getAttribute in interface Aggregator
Returns:
the attribute that is being aggregated

getType

public final Type getType()
Gets the Type of the value stored in this object.

Specified by:
getType in interface Aggregator
Returns:
the Type of the value stored in this object.

getEdgeType

public final EdgeType getEdgeType()
What is the relation that should be used to get at the neighbors of an instance

Specified by:
getEdgeType in interface Aggregator
Returns:
the relation that should be used to get at the neighbors of an instance

getNodeInfo

protected final SharedNodeInfo getNodeInfo(Node node)
This is cached aggregation information about the node as is relevant to the relationship that this aggregator uses.

Parameters:
node - The node whose cached aggregated information is needed.
Returns:

getValue

public final double getValue(Node n)
Aggregate around the given node in the graph and return the result.

Specified by:
getValue in interface Aggregator
Parameters:
n - The node around which to aggregate
Returns:

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object