org.biojavax.bio.phylo.tree
Class DefaultRootedTree

java.lang.Object
  extended by org.biojavax.bio.phylo.tree.DefaultRootedTree
All Implemented Interfaces:
RootedTree, Tree

public class DefaultRootedTree
extends Object
implements RootedTree

Version:
$Id: DefaultRootedTree.java,v 1.1 2006/12/13 17:25:59 tobias Exp $

created on 12.12.2006 14:44:10

Author:
Tobias Thierer

Constructor Summary
DefaultRootedTree()
          Constructs an empty rooted tree
DefaultRootedTree(RootedTreeNode root)
          Constructs a rooted tree with the given root node.
 
Method Summary
 void addBranch(Branch branch)
          Adds a branch to the tree.
 Tree asUnrooted()
           
 Collection getNodes()
           
 RootedTreeNode getRoot()
           
 boolean isEmpty()
           
 boolean isRoot(RootedTreeNode node)
           
 Iterator iterator()
          An iterator over the nodes of this tree.
 Iterator postOrderIterator()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultRootedTree

public DefaultRootedTree()
Constructs an empty rooted tree


DefaultRootedTree

public DefaultRootedTree(RootedTreeNode root)
Constructs a rooted tree with the given root node.

Parameters:
root - root node of the tree to construct. If this node already has children, these automatically become part of the tree, but they aren't copied. If root is another tree's root, this will just create a new view on the other tree, i.e. a new tree that shares all nodes with the old one.
Method Detail

isRoot

public boolean isRoot(RootedTreeNode node)
Specified by:
isRoot in interface RootedTree

getNodes

public Collection getNodes()
Specified by:
getNodes in interface RootedTree

getRoot

public RootedTreeNode getRoot()
Specified by:
getRoot in interface RootedTree
Returns:
The root node, or null if the tree is empty

asUnrooted

public Tree asUnrooted()
Specified by:
asUnrooted in interface RootedTree
Returns:
An unrooted view onto this tree. The unrooted view shares all nodes with this tree.

postOrderIterator

public final Iterator postOrderIterator()
Specified by:
postOrderIterator in interface RootedTree

iterator

public Iterator iterator()
Description copied from interface: Tree
An iterator over the nodes of this tree.

Specified by:
iterator in interface Tree
Returns:
An iterator over this tree's nodes. The default implementation returns postOrderIterator()

addBranch

public void addBranch(Branch branch)
Description copied from interface: Tree
Adds a branch to the tree. branch.getNodeA() must already be in this tree; branch.getNodeB() must not yet be in this tree, but it may already be in another tree.

Specified by:
addBranch in interface Tree

isEmpty

public final boolean isEmpty()
Specified by:
isEmpty in interface Tree