uk.ed.inf.graph.compound.base
Class BaseCompoundNode

java.lang.Object
  extended by uk.ed.inf.graph.compound.base.BaseCompoundNode
All Implemented Interfaces:
java.lang.Comparable<BaseCompoundNode>, IBasicNode<BaseCompoundNode,BaseCompoundEdge>, ICompoundNode<BaseCompoundNode,BaseCompoundEdge>, IDirectedNode<BaseCompoundNode,BaseCompoundEdge>, IRestorableGraphElement, ITreeNode<BaseCompoundNode>
Direct Known Subclasses:
ArchetypalCompoundNode

public abstract class BaseCompoundNode
extends java.lang.Object
implements ICompoundNode<BaseCompoundNode,BaseCompoundEdge>, IRestorableGraphElement


Constructor Summary
protected BaseCompoundNode()
           
 
Method Summary
(package private)  void addInEdge(BaseCompoundEdge edge)
           
(package private)  void addOutEdge(BaseCompoundEdge edge)
           
 java.util.Iterator<BaseCompoundNode> ancestorIterator()
          Iterator that traverses directly from this node up to the root node.
 java.util.Iterator<BaseCompoundNode> childIterator()
          Iterator over the immediate children of this node.
 int compareTo(BaseCompoundNode o)
          Compare this node to another node.
 java.util.Iterator<BaseCompoundNode> connectedNodeIterator()
          Provides an iterator that lists all nodes connected to this node via another edge.
protected  void createInEdgeSet(IDirectedEdgeSet<BaseCompoundNode,BaseCompoundEdge> edgeSet)
           
protected  void createOutEdgeSet(IDirectedEdgeSet<BaseCompoundNode,BaseCompoundEdge> edgeSet)
           
 java.util.Iterator<BaseCompoundEdge> edgeIterator()
          Provides an iterator that lists all edges associated with this node.
abstract  BaseChildCompoundGraph getChildCompoundGraph()
          Get subgraph of this compound node.
 int getDegree()
          Get the degree of the this node.
protected  IFilteredEdgeSet<BaseCompoundNode,BaseCompoundEdge> getEdgeInList()
           
protected  IFilteredEdgeSet<BaseCompoundNode,BaseCompoundEdge> getEdgeOutList()
           
 java.util.SortedSet<BaseCompoundEdge> getEdgesWith(BaseCompoundNode other)
          Gets the edges shared with the other node.
abstract  BaseCompoundGraph getGraph()
          Get the graph that owns this node.
 int getInDegree()
           
abstract  int getIndex()
          Get the index of this node.
 java.util.Iterator<BaseCompoundEdge> getInEdgeIterator()
          Gets all edges connecting this node
 java.util.SortedSet<BaseCompoundEdge> getInEdgesFrom(BaseCompoundNode outNode)
           
 java.util.Iterator<BaseCompoundNode> getInNodeIterator()
           
 int getOutDegree()
           
 java.util.Iterator<BaseCompoundEdge> getOutEdgeIterator()
          Gets all edges going out from this node.
 java.util.SortedSet<BaseCompoundEdge> getOutEdgesTo(BaseCompoundNode inNode)
           
 java.util.Iterator<BaseCompoundNode> getOutNodeIterator()
           
abstract  BaseCompoundNode getParent()
          The parent node cannot be null and should be the root node if the current node is the root node.
 BaseCompoundNode getRoot()
          Get the root node for the tree that this node belongs to.
 boolean hasEdgeWith(BaseCompoundNode other)
          Tests whether this node shares one or more edges with another node, irrespective of the direction of that edge.
 boolean hasInEdgeFrom(BaseCompoundNode outNode)
          Has at least one edge coming into this one from outNode
 boolean hasOutEdgeTo(BaseCompoundNode inNode)
          Has at least one edge going out from this node to inNode.
 boolean isAncestor(BaseCompoundNode testNode)
           
 boolean isChild(BaseCompoundNode childNode)
          Tests if childNode is a child of this node.
 boolean isDescendent(BaseCompoundNode testNode)
           
 boolean isParent(BaseCompoundNode parentNode)
          Is the given node the parent node of this one?
abstract  boolean isRemoved()
          Has the node been removed from the graph? Nodes are not removed from the graph's data structures, but flagged as deleted.
 java.util.Iterator<BaseCompoundNode> levelOrderIterator()
          Iterator that traverses down the tree in level-order, starting at this node.
 void markRemoved(boolean removed)
          Used to reset the removal status of a graph edge or node.
protected abstract  void removalAction(boolean removed)
          additional actions to be executed upon this node being marked as removed.
protected abstract  void setRemoved(boolean removed)
          This should be used to set the removal status variable only.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface uk.ed.inf.graph.basic.IBasicNode
equals, hashCode
 

Constructor Detail

BaseCompoundNode

protected BaseCompoundNode()
Method Detail

childIterator

public final java.util.Iterator<BaseCompoundNode> childIterator()
Description copied from interface: ITreeNode
Iterator over the immediate children of this node.

Specified by:
childIterator in interface ITreeNode<BaseCompoundNode>
Returns:
An iterator to this nodes children.

getParent

public abstract BaseCompoundNode getParent()
The parent node cannot be null and should be the root node if the current node is the root node. This follows the standard conversion for tree data structures.

Specified by:
getParent in interface ITreeNode<BaseCompoundNode>
Returns:
The parent node, cannot be null.

createInEdgeSet

protected final void createInEdgeSet(IDirectedEdgeSet<BaseCompoundNode,BaseCompoundEdge> edgeSet)

createOutEdgeSet

protected final void createOutEdgeSet(IDirectedEdgeSet<BaseCompoundNode,BaseCompoundEdge> edgeSet)

getEdgeInList

protected final IFilteredEdgeSet<BaseCompoundNode,BaseCompoundEdge> getEdgeInList()

getEdgeOutList

protected final IFilteredEdgeSet<BaseCompoundNode,BaseCompoundEdge> getEdgeOutList()

setRemoved

protected abstract void setRemoved(boolean removed)
This should be used to set the removal status variable only. No other actions# should be performed here. To perform an action on removal then use removalAction(boolean).

Parameters:
removed - the removal status: true means the nodes is removed.

getChildCompoundGraph

public abstract BaseChildCompoundGraph getChildCompoundGraph()
Description copied from interface: ICompoundNode
Get subgraph of this compound node. Note that this node is the root-node of the sub-Cigraph.

Specified by:
getChildCompoundGraph in interface ICompoundNode<BaseCompoundNode,BaseCompoundEdge>
Returns:

getInDegree

public final int getInDegree()
Specified by:
getInDegree in interface IDirectedNode<BaseCompoundNode,BaseCompoundEdge>

getInEdgesFrom

public final java.util.SortedSet<BaseCompoundEdge> getInEdgesFrom(BaseCompoundNode outNode)
Specified by:
getInEdgesFrom in interface IDirectedNode<BaseCompoundNode,BaseCompoundEdge>

getInEdgeIterator

public final java.util.Iterator<BaseCompoundEdge> getInEdgeIterator()
Description copied from interface: IDirectedNode
Gets all edges connecting this node

Specified by:
getInEdgeIterator in interface IDirectedNode<BaseCompoundNode,BaseCompoundEdge>
Returns:

getInNodeIterator

public final java.util.Iterator<BaseCompoundNode> getInNodeIterator()
Specified by:
getInNodeIterator in interface IDirectedNode<BaseCompoundNode,BaseCompoundEdge>

getOutDegree

public final int getOutDegree()
Specified by:
getOutDegree in interface IDirectedNode<BaseCompoundNode,BaseCompoundEdge>

getOutEdgeIterator

public final java.util.Iterator<BaseCompoundEdge> getOutEdgeIterator()
Description copied from interface: IDirectedNode
Gets all edges going out from this node.

Specified by:
getOutEdgeIterator in interface IDirectedNode<BaseCompoundNode,BaseCompoundEdge>
Returns:

getOutEdgesTo

public final java.util.SortedSet<BaseCompoundEdge> getOutEdgesTo(BaseCompoundNode inNode)
Specified by:
getOutEdgesTo in interface IDirectedNode<BaseCompoundNode,BaseCompoundEdge>

getOutNodeIterator

public final java.util.Iterator<BaseCompoundNode> getOutNodeIterator()
Specified by:
getOutNodeIterator in interface IDirectedNode<BaseCompoundNode,BaseCompoundEdge>

hasInEdgeFrom

public final boolean hasInEdgeFrom(BaseCompoundNode outNode)
Description copied from interface: IDirectedNode
Has at least one edge coming into this one from outNode

Specified by:
hasInEdgeFrom in interface IDirectedNode<BaseCompoundNode,BaseCompoundEdge>
Returns:

hasOutEdgeTo

public final boolean hasOutEdgeTo(BaseCompoundNode inNode)
Description copied from interface: IDirectedNode
Has at least one edge going out from this node to inNode.

Specified by:
hasOutEdgeTo in interface IDirectedNode<BaseCompoundNode,BaseCompoundEdge>
Returns:

connectedNodeIterator

public final java.util.Iterator<BaseCompoundNode> connectedNodeIterator()
Description copied from interface: IBasicNode
Provides an iterator that lists all nodes connected to this node via another edge. When self-edges are encountered a reference to this node will be returned. The iterator may return the same node more than once if this node has multiple edges to it.

Specified by:
connectedNodeIterator in interface IBasicNode<BaseCompoundNode,BaseCompoundEdge>
Returns:
the node iterator.

getDegree

public final int getDegree()
Description copied from interface: IBasicNode
Get the degree of the this node. That is the number of edges associated with it. Note that in graph theory self edges (edges that start and finish on the same node) add 2 to the degree of a node.

Specified by:
getDegree in interface IBasicNode<BaseCompoundNode,BaseCompoundEdge>
Returns:
The degree of the node.

edgeIterator

public final java.util.Iterator<BaseCompoundEdge> edgeIterator()
Description copied from interface: IBasicNode
Provides an iterator that lists all edges associated with this node. In a directed graph this iterator ignores the direction of the edge.

Specified by:
edgeIterator in interface IBasicNode<BaseCompoundNode,BaseCompoundEdge>
Returns:
the edge iterator.

getEdgesWith

public final java.util.SortedSet<BaseCompoundEdge> getEdgesWith(BaseCompoundNode other)
Description copied from interface: IBasicNode
Gets the edges shared with the other node.

Specified by:
getEdgesWith in interface IBasicNode<BaseCompoundNode,BaseCompoundEdge>
Parameters:
other - The other node to test. Cannot be null.
Returns:
A set of edges sorted by edge index, which

getGraph

public abstract BaseCompoundGraph getGraph()
Description copied from interface: IBasicNode
Get the graph that owns this node.

Specified by:
getGraph in interface IBasicNode<BaseCompoundNode,BaseCompoundEdge>
Returns:
The graph instance which cannot be null.

getIndex

public abstract int getIndex()
Description copied from interface: IBasicNode
Get the index of this node.

Specified by:
getIndex in interface IBasicNode<BaseCompoundNode,BaseCompoundEdge>
Specified by:
getIndex in interface ITreeNode<BaseCompoundNode>
Returns:
Returns a whole number (>=0).

isChild

public final boolean isChild(BaseCompoundNode childNode)
Description copied from interface: ITreeNode
Tests if childNode is a child of this node.

Specified by:
isChild in interface ITreeNode<BaseCompoundNode>
Parameters:
childNode - The node to test, can be null.
Returns:
true if it is a child of this node, false otherwise.

hasEdgeWith

public final boolean hasEdgeWith(BaseCompoundNode other)
Description copied from interface: IBasicNode
Tests whether this node shares one or more edges with another node, irrespective of the direction of that edge.

Specified by:
hasEdgeWith in interface IBasicNode<BaseCompoundNode,BaseCompoundEdge>
Parameters:
other - The other node to test. Can be null.
Returns:
True if and edge is shared, false otherwise.

addInEdge

final void addInEdge(BaseCompoundEdge edge)

addOutEdge

final void addOutEdge(BaseCompoundEdge edge)

compareTo

public final int compareTo(BaseCompoundNode o)
Description copied from interface: IBasicNode
Compare this node to another node. Comparison should be based on the comparison order of the node's index only. The owning graph should be ignored. It is the job of the graph library to ensure that only nodes belonging to the same graph are compared.

Specified by:
compareTo in interface java.lang.Comparable<BaseCompoundNode>
Specified by:
compareTo in interface IBasicNode<BaseCompoundNode,BaseCompoundEdge>
Parameters:
o - the other node to compare to.

isRemoved

public abstract boolean isRemoved()
Description copied from interface: IBasicNode
Has the node been removed from the graph? Nodes are not removed from the graph's data structures, but flagged as deleted.

Specified by:
isRemoved in interface IBasicNode<BaseCompoundNode,BaseCompoundEdge>
Returns:
true if removed, false otherwise.

markRemoved

public final void markRemoved(boolean removed)
Description copied from interface: IRestorableGraphElement
Used to reset the removal status of a graph edge or node.

Specified by:
markRemoved in interface IRestorableGraphElement

removalAction

protected abstract void removalAction(boolean removed)
additional actions to be executed upon this node being marked as removed.


isParent

public final boolean isParent(BaseCompoundNode parentNode)
Description copied from interface: ITreeNode
Is the given node the parent node of this one?

Specified by:
isParent in interface ITreeNode<BaseCompoundNode>
Parameters:
parentNode - The node to test as a parent. Can be null.
Returns:
true if it is the parent, false otherwise.

getRoot

public BaseCompoundNode getRoot()
Description copied from interface: ITreeNode
Get the root node for the tree that this node belongs to.

Specified by:
getRoot in interface ITreeNode<BaseCompoundNode>
Returns:
The root node, cannot be null.

ancestorIterator

public final java.util.Iterator<BaseCompoundNode> ancestorIterator()
Description copied from interface: ITreeNode
Iterator that traverses directly from this node up to the root node.

Specified by:
ancestorIterator in interface ITreeNode<BaseCompoundNode>
Returns:
a new iterator instance, which cannot be null.

levelOrderIterator

public final java.util.Iterator<BaseCompoundNode> levelOrderIterator()
Description copied from interface: ITreeNode
Iterator that traverses down the tree in level-order, starting at this node.

Specified by:
levelOrderIterator in interface ITreeNode<BaseCompoundNode>
Returns:
a new instance of the iterator, which cannot be null.

isAncestor

public boolean isAncestor(BaseCompoundNode testNode)
Specified by:
isAncestor in interface ICompoundNode<BaseCompoundNode,BaseCompoundEdge>

isDescendent

public boolean isDescendent(BaseCompoundNode testNode)
Specified by:
isDescendent in interface ICompoundNode<BaseCompoundNode,BaseCompoundEdge>