id3
Class RootedCatGraph

java.lang.Object
  |
  +--id3.CatGraph
        |
        +--id3.RootedCatGraph
Direct Known Subclasses:
DecisionTree

public class RootedCatGraph
extends CatGraph

RootedCatGraph instances have a specific root node. All nodes in RootedCatGraphs should be reachable from the root.


Fields inherited from class id3.CatGraph
cGraph, defaultDistDisp, distDispHelp, logOptions
 
Constructor Summary
RootedCatGraph(boolean isGraphSparse)
          Constructor.
RootedCatGraph(CGraph grph, boolean isGraphSparse)
          Constructor.
 
Method Summary
 void display(boolean hasNodeLosses, boolean hasLossMatrix, java.io.Writer stream, DisplayPref dp)
          Displays the root, as well as CatGraph.display().
 Node get_root()
          If the root has been set, returns the root.
 Node get_root(boolean abortOnNoRoot)
          If the root has been set, returns the root.
 int num_nontrivial_leaves()
          The number of non-trivial leaves in the CatGraph.
 int num_nontrivial_leaves(Node fromRoot)
          The number of non-trivial leaves in the CatGraph.
 int num_nontrivial_nodes()
          The number of non-trivial nodes in the CatGraph.
 int num_nontrivial_nodes(Node fromRoot)
          The number of non-trivial nodes in the CatGraph.
 void set_root(Node node)
          Sets the root of the RootedCatGraph.
 void set_used_attr(boolean[] usedAttr)
          Sets the attributes used.
 boolean trivial_edge(Edge e)
          Check if an edge is trivial.
 
Methods inherited from class id3.CatGraph
check_node_in_graph, connect, convertToDotFormat, create_node, get_categorizer, get_graph, get_log_level, get_log_options, get_log_stream, is_sparse, num_attr, num_children, num_leaves, num_nodes, process_DotGraph_display, process_DotPostscript_display, set_log_level, set_log_options, set_log_prefixes, set_log_stream
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RootedCatGraph

public RootedCatGraph(boolean isGraphSparse)
Constructor. Initializes root to NULL.
Parameters:
isGraphSparse - TRUE if the graph is sparse.

RootedCatGraph

public RootedCatGraph(CGraph grph,
                      boolean isGraphSparse)
Constructor.
Parameters:
grph - The graph to be assigned to this RootedCatGraph.
isGraphSparse - TRUE if the graph is sparse.
Method Detail

num_nontrivial_nodes

public int num_nontrivial_nodes()
The number of non-trivial nodes in the CatGraph. Trivial nodes are those that both have no instances, and have unknown edges leading to them.
Returns:
The number of non-trivial nodes.

num_nontrivial_nodes

public int num_nontrivial_nodes(Node fromRoot)
The number of non-trivial nodes in the CatGraph. Trivial nodes are those that both have no instances, and have unknown edges leading to them.
Parameters:
fromRoot - The node to use as the root in searching for nodes.
Returns:
The number of non-trivial nodes.

num_nontrivial_leaves

public int num_nontrivial_leaves()
The number of non-trivial leaves in the CatGraph. Trivial nodes are those that both have no instances, and have unknown edges leading to them.
Returns:
The number of non-trivial leaves.

num_nontrivial_leaves

public int num_nontrivial_leaves(Node fromRoot)
The number of non-trivial leaves in the CatGraph. Trivial nodes are those that both have no instances, and have unknown edges leading to them.
Parameters:
fromRoot - The node to use as root in searching for leaves.
Returns:
The number of non-trivial leaves.

trivial_edge

public boolean trivial_edge(Edge e)
Check if an edge is trivial. A trivial edge has an unknown label and leads to a node with no instances.
Parameters:
e - The edge to be checked.
Returns:
TRUE if the edge is trivial, FALSE otherwise.

set_root

public void set_root(Node node)
Sets the root of the RootedCatGraph.
Parameters:
node - The new root node.

get_root

public Node get_root()
If the root has been set, returns the root.
Returns:
The root node of this RootedCatGraph.

get_root

public Node get_root(boolean abortOnNoRoot)
If the root has been set, returns the root. If abortOnNULL is FALSE returns NULL if root has not been set. Otherwise aborts when root is not set.
Parameters:
abortOnNoRoot - TRUE if aborting should occur when there is no root, FALSE if the method returns null if there is no root node set.
Returns:
The root node or null if the root is not set.

set_used_attr

public void set_used_attr(boolean[] usedAttr)
Sets the attributes used.
Parameters:
usedAttr - An array indicating used attributes. Used attributes are indicated with TRUE values in their index numbers. Unused attributes are indicated with FALSE values.

display

public void display(boolean hasNodeLosses,
                    boolean hasLossMatrix,
                    java.io.Writer stream,
                    DisplayPref dp)
Displays the root, as well as CatGraph.display().
Overrides:
display in class CatGraph
Parameters:
hasNodeLosses - TRUE if node loss values have been set.
hasLossMatrix - TRUE if loss matrix has been set.
stream - The Writer to be displayed to.
dp - The display preferences.