mauda.plugin.fibheap
Class FibNodeDS

java.lang.Object
  extended by mauda.plugin.fibheap.FibNodeDS

public class FibNodeDS
extends java.lang.Object

Author:
Markus Krebs Code

Constructor Summary
FibNodeDS(int key)
          Creates a new node with the specified key.
 
Method Summary
 void addChild(FibNodeDS newChild)
          Links another node N to this one.
 java.lang.Object clone()
           
 void cut(FibNodeDS target)
          Cuts this node off its parent and joins with target
 void delete()
          Deletes this node from the root list.
 FibNodeDS getChildNode()
           
 int getDepth()
           
 int getKey()
           
 FibNodeDS getLeftSibling()
           
 FibNodeDS getParentNode()
          Returns the (logical) parent FibNode of this node.
 int getRank()
           
 FibNodeDS getRightSibling()
           
 FibNodeDS getRoot()
           
 FibNodeDS getSibling()
          Used for child-sibling format of trees.
 int getTreeDepth()
           
 int getTreeSize()
           
 int getTreeWidth()
           
 boolean hasChildren()
           
 boolean isMarked()
           
 boolean isRoot()
           
 void join(FibNodeDS other, boolean spaceNeeded)
          Joins another node list to the sibling list of this one.
 void mark()
          Marks this node.
 void setKey(int k)
          Sets the key of this node to the specified value.
 void unmark()
          Un-marks (removes mark from) this node.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FibNodeDS

public FibNodeDS(int key)
Creates a new node with the specified key. The node has no parent or child and is the only node in its list of siblings.

Parameters:
key - the key for this node
Method Detail

getParentNode

public FibNodeDS getParentNode()
Returns the (logical) parent FibNode of this node. Might differ from getParent(), which returns the (physical) parent Composite.

Returns:
the parent of this node (or null, if this node is a root).

getChildNode

public FibNodeDS getChildNode()
Returns:
the leftmost child of this node (or null, if there is no child).

getSibling

public FibNodeDS getSibling()
Used for child-sibling format of trees.

Returns:
this node's (right) sibling (=null if there is no sibling!)

getRightSibling

public FibNodeDS getRightSibling()
Returns:
this node's right sibling (=this node if there is no sibling)

getLeftSibling

public FibNodeDS getLeftSibling()
Returns:
this node's right sibling (= this node if there is no sibling)

getRank

public int getRank()
Returns:
the rank (= number of children) of this node.

getKey

public int getKey()
Returns:
the key of this node

setKey

public void setKey(int k)
Sets the key of this node to the specified value.

Parameters:
k - the new key

isRoot

public boolean isRoot()
Returns:
TRUE iff this node is part of the rootlist

hasChildren

public boolean hasChildren()
Returns:
TRUE iff this node has at least one child

isMarked

public boolean isMarked()
Returns:
TRUE iff this node is marked (=has lost a child since last linked to another node)

mark

public void mark()
Marks this node.


unmark

public void unmark()
Un-marks (removes mark from) this node.


addChild

public void addChild(FibNodeDS newChild)
Links another node N to this one. Inserts N as the rightmost child of this node.

Parameters:
newChild - the node to be added

cut

public void cut(FibNodeDS target)
Cuts this node off its parent and joins with target

Parameters:
target - the node where this one is attached

join

public void join(FibNodeDS other,
                 boolean spaceNeeded)
Joins another node list to the sibling list of this one. Inserts the other node and its siblings right next to this node. All parents and children remain.

Parameters:
other - node of the list to join
spaceNeeded - true if additional space is needed

delete

public void delete()
Deletes this node from the root list.


getTreeWidth

public int getTreeWidth()
Returns:
width of the (sub)tree rooted in this node

getTreeDepth

public int getTreeDepth()
Returns:
the depth of this (sub)tree (from this node to bottom)

getTreeSize

public int getTreeSize()
Returns:
the size (=number of nodes) in this (sub)tree

getDepth

public int getDepth()
Returns:
the depth of this node in its tree (=distance from root to this node)

getRoot

public FibNodeDS getRoot()
Returns:
the root of the tree this node is part of

clone

public java.lang.Object clone()
Overrides:
clone in class java.lang.Object