Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## edu.stanford.nlp.trees
Class TreeGraph

    java.lang.Object
      edu.stanford.nlp.trees.TreeGraph

All Implemented Interfaces:
  Serializable

Direct Known Subclasses:
  GrammaticalStructure

    public class TreeGraph

extends Object
implements Serializable

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 ``TreeGraphNode`s`, which do inherit from `Tree`, and the additional labeled arcs are represented in the `TreeGraphNode`s.

Author:
  Bill MacCartney
See Also:
  `TreeGraphNode`, Serialized Form

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).
`TreeGraph(TreeGraphNode root)`

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.
`Collection<TreeGraphNode>` | `getNodes()`
`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

### TreeGraph

    public TreeGraph(TreeGraphNode root)

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)

### getNodes

    public Collection<TreeGraphNode> getNodes()

### 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.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Stanford NLP Group