edu.ucla.belief.dtree
Class Dtree

Object
  extended by Dtree

public class Dtree
extends Object

This class represents dtree objects.

Author:
David Allen

Nested Class Summary
static class Dtree.Create
          Each instantiation of this class represents a way of generating dtrees.
static class Dtree.DtreeComparatorHeightLowToHigh
          This comparator will first sort based on height, then on hashCode, and then try a few different things before returning 0.
static class Dtree.DtreeCreationException
           
 
Field Summary
 CreationMethod myCreationMethod
           
 
Constructor Summary
Dtree(DirectedGraph dag, Dtree.Create createAlgo)
          Create a Dtree using the createAlgo algorithm and the DirectedGraph dag.
Dtree(DtreeNode inRoot)
          Create a Dtree with inRoot as the root of the tree.
Dtree(Map varToFamily, Dtree.Create createAlgo)
          Create a Dtree using the createAlgo algorithm.
 
Method Summary
static Collection colOfColOfFVarsToColDtreeNodes(Map varToFamily, Collection ret)
          Convert a Collection of Collections of FiniteVariables (Collection of Families or UndirectedEdges) to a Collection of DtreeNodes.
static Map convertDAGtoMap(DirectedGraph dag, Map varToFamily)
          Convert a DirectedGraph to a Map from a FiniteVariable to a collection of FiniteVariables (its family, & itself).
 int getClusterSize()
           
 int getContextSize()
           
 int getCutsetSize()
           
 void getElimOrder(ArrayList ord)
           
 int getHeight()
           
static String getTagName()
           
static Collection getVars(Collection A)
          Get all the vars contained within a collection of DtreeNodes.
static Collection getVars(Collection A, Collection ret)
          Get all the vars contained within a collection of DtreeNodes.
 int getWidth()
          Same as getClusterSize - 1.
 void populate()
           
 DtreeNode root()
           
static Dtree selectBestDtree(Dtree n1, Dtree n2)
          Will determine which dtree is better and return it.
 String toString()
           
 void unpopulate()
           
 void write(File ofile)
           
 void write(Writer out)
           
 void write(Writer out, CharArrayWriter outtmp)
           
 void writeToDOTFile(Writer out)
          Writes this Dtree to a DOT file.
 void writeToVCGFile(Writer out)
          Writes this Dtree to a VCG file.
 
Methods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

myCreationMethod

public CreationMethod myCreationMethod
Constructor Detail

Dtree

public Dtree(DtreeNode inRoot)
Create a Dtree with inRoot as the root of the tree. (i.e. no copying is done)

Throws:
Dtree.DtreeCreationException - if inRoot is null.

Dtree

public Dtree(DirectedGraph dag,
             Dtree.Create createAlgo)
Create a Dtree using the createAlgo algorithm and the DirectedGraph dag.

Parameters:
dag - A DirectedGraph to create the Dtree from.
createAlgo - The algorithm to use.
Throws:
Dtree.DtreeCreationException - if could not create a Dtree.

Dtree

public Dtree(Map varToFamily,
             Dtree.Create createAlgo)
Create a Dtree using the createAlgo algorithm.

Parameters:
varToFamily - A Map of a FiniteVariable to a Collection of FiniteVariables (Its Family, including itself). (These Collections will be used and modified, so pass copies of anything that cannot be changed.)
createAlgo - The algorithm to use.
Throws:
Dtree.DtreeCreationException - if could not create a Dtree.
Method Detail

toString

public String toString()
Overrides:
toString in class Object
Since:
022703

root

public DtreeNode root()

getCutsetSize

public int getCutsetSize()

getContextSize

public int getContextSize()

getClusterSize

public int getClusterSize()

getWidth

public int getWidth()
Same as getClusterSize - 1.


getHeight

public int getHeight()

getElimOrder

public void getElimOrder(ArrayList ord)

populate

public void populate()

unpopulate

public void unpopulate()

getVars

public static Collection getVars(Collection A)
Get all the vars contained within a collection of DtreeNodes.


getVars

public static Collection getVars(Collection A,
                                 Collection ret)
Get all the vars contained within a collection of DtreeNodes.


getTagName

public static String getTagName()

write

public void write(File ofile)
           throws IOException
Throws:
IOException
Since:
121302

write

public void write(Writer out)
           throws IOException
Throws:
IOException
Since:
022703

write

public void write(Writer out,
                  CharArrayWriter outtmp)
           throws IOException
Throws:
IOException
Since:
022703

writeToVCGFile

public void writeToVCGFile(Writer out)
                    throws IOException
Writes this Dtree to a VCG file.

Parameters:
out - The file to write the object to.
Throws:
IOException - if there is a file error.

writeToDOTFile

public void writeToDOTFile(Writer out)
                    throws IOException
Writes this Dtree to a DOT file.

Parameters:
out - The file to write the object to.
Throws:
IOException - if there is a file error.

selectBestDtree

public static Dtree selectBestDtree(Dtree n1,
                                    Dtree n2)
Will determine which dtree is better and return it.


convertDAGtoMap

public static Map convertDAGtoMap(DirectedGraph dag,
                                  Map varToFamily)
Convert a DirectedGraph to a Map from a FiniteVariable to a collection of FiniteVariables (its family, & itself).

Parameters:
varToFamily - The Map which will be returned (if null, a new HashMap will be created and returned with the result).

colOfColOfFVarsToColDtreeNodes

public static Collection colOfColOfFVarsToColDtreeNodes(Map varToFamily,
                                                        Collection ret)
Convert a Collection of Collections of FiniteVariables (Collection of Families or UndirectedEdges) to a Collection of DtreeNodes.

Parameters:
varToFamily - A Map of a FiniteVariable to a Collection of FiniteVariables (Its Family, including itself). (These Collections will be used and modified, so pass copies of anything that cannot be changed.)
ret - The Collection to add the DtreeNodes to and return (can be null in which case a new Collection will be created).


Copyright 2010 UCLA Automated Reasoning Group