edu.stanford.nlp.trees
Class TreeGraph

java.lang.Object
  extended by edu.stanford.nlp.trees.TreeGraph
Direct Known Subclasses:
GrammaticalStructure

public class TreeGraph
extends Object

A TreeGraph is a tree with additional directed, labeled arcs between arbitrary pairs of nodes. (So, it's a graph with a tree skeleton.) This class is a container for the complete treegraph structure, and does not inherit from Tree. Individual nodes in the treegraph are represented by TreeGraphNodes, which do inherit from Tree, and the additional labeled arcs are represented in the TreeGraphNodes.

Author:
Bill MacCartney
See Also:
TreeGraphNode

Field Summary
protected  TreeGraphNode root
          The root node of this treegraph.
 
Constructor Summary
TreeGraph(Tree t)
          Construct a new TreeGraph having the same tree structure and label values as an existing tree (but no shared storage).
 
Method Summary
 void addNodeToIndexMap(int index, TreeGraphNode node)
          Store a mapping from an arbitrary integer index to a node in this treegraph.
 TreeGraphNode getNodeByIndex(int index)
          Return the node in the this treegraph corresponding to the specified integer index.
static void main(String[] args)
          Just for testing.
 TreeGraphNode root()
          Return the root node of this treegraph.
 String toString()
          Return a String representing this treegraph.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

root

protected TreeGraphNode root
The root node of this treegraph.

Constructor Detail

TreeGraph

public TreeGraph(Tree t)
Construct a new TreeGraph having the same tree structure and label values as an existing tree (but no shared storage). This constructor also assigns integer indices to all the nodes, beginning with 0 and using a preorder tree traversal.

Parameters:
t - the tree to copy
Method Detail

root

public TreeGraphNode root()
Return the root node of this treegraph.

Returns:
the root node of this treegraph

addNodeToIndexMap

public void addNodeToIndexMap(int index,
                              TreeGraphNode node)
Store a mapping from an arbitrary integer index to a node in this treegraph. Normally a client shouldn't need to use this, as the nodes are automatically indexed by the TreeGraph constructor.

Parameters:
index - the arbitrary integer index
node - the TreeGraphNode to be indexed

getNodeByIndex

public TreeGraphNode getNodeByIndex(int index)
Return the node in the this treegraph corresponding to the specified integer index.

Parameters:
index - the integer index of the node you want
Returns:
the TreeGraphNode having the specified index (or null if such does not exist)

toString

public String toString()
Return a String representing this treegraph. By default, the nodes of the treegraph are printed in Lispy (parenthesized) format, with one node per line, indented according to depth.

Overrides:
toString in class Object
Returns:
a String representation of this treegraph

main

public static void main(String[] args)
Just for testing.



Stanford NLP Group