edu.vt.marian.search
Class LinkSuperclassManager

java.lang.Object
  |
  +--edu.vt.marian.search.LinkSuperclassManager

public class LinkSuperclassManager
extends java.lang.Object
implements LinkClassManager

Class manager for a link class that functions only as the union of disjoint subclasses. This is the only sort of superclass manager supported by MARIAN v.2.1.

The algorithm for each method is the same: create a MergeSequencer for merging results. (We use a MergeSequencer rather than a PriQueuSequencer because class hierarchies are designed by humans and thus each superclass is only expected to combine a handful of subclasses.) Call each subclass manager in turn, and feed the results into the Sequencer. Calls for statistics work the same way, but use totals and averages in place of Sequencers.

See Also:
ClassManager, LinkClassManager, MergeSequencer

Field Summary
protected  edu.vt.marian.common.ClassID classID
          The class of links that this can manage.
protected  edu.vt.marian.common.Debug debug
           
protected  java.util.Vector subclassMgrs
          Vector of LinkClassManagers for the (disjoint) subclasses.
 
Constructor Summary
LinkSuperclassManager(edu.vt.marian.common.ClassID linkClID, java.util.Vector subclassManagers, edu.vt.marian.common.Debug d)
          Create a LinkClassManager for a particular superclass of disjoint (link) subclasses.
 
Method Summary
 double avgSinkDegree()
          Return the average number of links in this class that impinge on a sinknode currently (== numLinks / numSinks).
 double avgSourceDegree()
          Return the average number of links in this class that impinge on a source node currently (== numLinks / numSources).
 long classSize()
          Return the number of class instances currently in the factory.
 WtdObjSet keyNodeToTargetSet(edu.vt.marian.common.WtdObj key, int dir)
          Take a single node on one end of this link to all the nodes at the other end.
 WtdObjSet keySetToTargetSet(WtdObjSet keySet, int dir)
          Take a weighted object set of nodes on one end of the links in this class to all the nodes at the other end.
 WtdObjSet match(edu.vt.marian.common.LinkDesc description)
          Create (or find in the local cache) a set of matches to description.
 long numLinks()
          Return the number of class instances currently in the factory.
 long numSinks()
          Return the number of unique sink nodes currently in the factory.
 long numSources()
          Return the number of unique source nodes currently in the factory.
 WtdObjSet sinksToSources(WtdObjSet sinkSet)
          Syntactic sugar on keySetToTargetSet().
 WtdObjSet sinkToSources(edu.vt.marian.common.WtdObj sinkNode)
          Syntactic sugar on keyNodeToTargetSet().
 WtdObjSet sourcesToSinks(WtdObjSet sourceSet)
          Syntactic sugar on keySetToTargetSet().
 WtdObjSet sourceToSinks(edu.vt.marian.common.WtdObj sourceNode)
          Syntactic sugar on keyNodeToTargetSet().
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

debug

protected edu.vt.marian.common.Debug debug

classID

protected edu.vt.marian.common.ClassID classID
The class of links that this can manage.

subclassMgrs

protected java.util.Vector subclassMgrs
Vector of LinkClassManagers for the (disjoint) subclasses.
Constructor Detail

LinkSuperclassManager

public LinkSuperclassManager(edu.vt.marian.common.ClassID linkClID,
                             java.util.Vector subclassManagers,
                             edu.vt.marian.common.Debug d)
Create a LinkClassManager for a particular superclass of disjoint (link) subclasses.
Method Detail

match

public WtdObjSet match(edu.vt.marian.common.LinkDesc description)
Create (or find in the local cache) a set of matches to description.
Specified by:
match in interface LinkClassManager
Parameters:
description - An abstract description of the links we're looking for: specifically, the link class (presumably this.classID), the direction, and a description of what is on one end.
Returns:
a WtdObjSet of nodes on the other end.

keyNodeToTargetSet

public WtdObjSet keyNodeToTargetSet(edu.vt.marian.common.WtdObj key,
                                    int dir)
Take a single node on one end of this link to all the nodes at the other end.
Specified by:
keyNodeToTargetSet in interface LinkClassManager
Parameters:
key - The node as a WtdObj.
dir - Whether key functions as source or sink.
Returns:
The set of all nodes linked to key by instances of this link class, weighted by link weights (if any) and key.wt().

keySetToTargetSet

public WtdObjSet keySetToTargetSet(WtdObjSet keySet,
                                   int dir)
Take a weighted object set of nodes on one end of the links in this class to all the nodes at the other end.

NOTE: Where two nodes in keySet are both linked to the same "target" node, some function must be applied to compute the node's weight in the combined set. The default for links is max(), but any implementing LinkClassManager class may use any function that suits its semantics.

Specified by:
keySetToTargetSet in interface LinkClassManager
Parameters:
key - the node as a WtdObj.
dir - Whether key functions as source or sink.
Returns:
The set of all nodes linked to any node in keySet by instances of this link class, weighted by link weights (if any) and key.wt().

sourceToSinks

public WtdObjSet sourceToSinks(edu.vt.marian.common.WtdObj sourceNode)
Syntactic sugar on keyNodeToTargetSet().
Specified by:
sourceToSinks in interface LinkClassManager

sourcesToSinks

public WtdObjSet sourcesToSinks(WtdObjSet sourceSet)
Syntactic sugar on keySetToTargetSet().
Specified by:
sourcesToSinks in interface LinkClassManager

sinkToSources

public WtdObjSet sinkToSources(edu.vt.marian.common.WtdObj sinkNode)
Syntactic sugar on keyNodeToTargetSet().
Specified by:
sinkToSources in interface LinkClassManager

sinksToSources

public WtdObjSet sinksToSources(WtdObjSet sinkSet)
Syntactic sugar on keySetToTargetSet().
Specified by:
sinksToSources in interface LinkClassManager

numLinks

public long numLinks()
Return the number of class instances currently in the factory. Syntactic sugar on super.classSize().
Specified by:
numLinks in interface LinkClassManager

numSources

public long numSources()
Return the number of unique source nodes currently in the factory.
Specified by:
numSources in interface LinkClassManager

numSinks

public long numSinks()
Return the number of unique sink nodes currently in the factory.
Specified by:
numSinks in interface LinkClassManager

avgSourceDegree

public double avgSourceDegree()
Return the average number of links in this class that impinge on a source node currently (== numLinks / numSources).
Specified by:
avgSourceDegree in interface LinkClassManager

avgSinkDegree

public double avgSinkDegree()
Return the average number of links in this class that impinge on a sinknode currently (== numLinks / numSinks).
Specified by:
avgSinkDegree in interface LinkClassManager

classSize

public long classSize()
Return the number of class instances currently in the factory.