uk.ed.inf.graph.basic
Interface IBasicNode<N extends IBasicNode<N,? extends IBasicEdge<N,?>>,E extends IBasicEdge<N,E>>

Type Parameters:
N - The node type that must implement this interface.
E - The edge type that must implement the IEdge class.
All Superinterfaces:
java.lang.Comparable<N>
All Known Subinterfaces:
ICompoundNode<N,E>, IDirectedNode<N,E>, IUndirectedNode<N,E>
All Known Implementing Classes:
ArchetypalCompoundNode, BaseCompoundNode, CompoundNode, Node

public interface IBasicNode<N extends IBasicNode<N,? extends IBasicEdge<N,?>>,E extends IBasicEdge<N,E>>
extends java.lang.Comparable<N>

A basic graph node useable by all graphs.

Author:
smoodie

Method Summary
 int compareTo(N other)
          Compare this node to another node.
 java.util.Iterator<N> connectedNodeIterator()
          Provides an iterator that lists all nodes connected to this node via another edge.
 java.util.Iterator<E> edgeIterator()
          Provides an iterator that lists all edges associated with this node.
 boolean equals(java.lang.Object other)
          Is the other node equal to this one.
 int getDegree()
          Get the degree of the this node.
 java.util.SortedSet<E> getEdgesWith(N other)
          Gets the edges shared with the other node.
 IBasicGraph<N,E> getGraph()
          Get the graph that owns this node.
 int getIndex()
          Get the index of this node.
 boolean hasEdgeWith(N other)
          Tests whether this node shares one or more edges with another node, irrespective of the direction of that edge.
 int hashCode()
          Get the hash code for this node.
 boolean isRemoved()
          Has the node been removed from the graph? Nodes are not removed from the graph's data structures, but flagged as deleted.
 

Method Detail

getGraph

IBasicGraph<N,E> getGraph()
Get the graph that owns this node.

Returns:
The graph instance which cannot be null.

getIndex

int getIndex()
Get the index of this node.

Returns:
Returns a whole number (>=0).

hasEdgeWith

boolean hasEdgeWith(N other)
Tests whether this node shares one or more edges with another node, irrespective of the direction of that edge.

Parameters:
other - The other node to test. Can be null.
Returns:
True if and edge is shared, false otherwise.

getEdgesWith

java.util.SortedSet<E> getEdgesWith(N other)
Gets the edges shared with the other node.

Parameters:
other - The other node to test. Cannot be null.
Returns:
A set of edges sorted by edge index, which

getDegree

int getDegree()
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.

Returns:
The degree of the node.

edgeIterator

java.util.Iterator<E> edgeIterator()
Provides an iterator that lists all edges associated with this node. In a directed graph this iterator ignores the direction of the edge.

Returns:
the edge iterator.

connectedNodeIterator

java.util.Iterator<N> connectedNodeIterator()
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.

Returns:
the node iterator.

isRemoved

boolean isRemoved()
Has the node been removed from the graph? Nodes are not removed from the graph's data structures, but flagged as deleted.

Returns:
true if removed, false otherwise.

equals

boolean equals(java.lang.Object other)
Is the other node equal to this one. Should obey the standard contract for equals, and in addition a node should be regarded as equal if its owning graph and index are identical.

Overrides:
equals in class java.lang.Object
Parameters:
other - the other object to be tested.
Returns:
true if equals by the standard contract and if the owning graph and index are identical. false otherwise.

hashCode

int hashCode()
Get the hash code for this node. Should be consistent with equals.

Overrides:
hashCode in class java.lang.Object
Returns:
The hash code for this node.

compareTo

int compareTo(N other)
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<N extends IBasicNode<N,? extends IBasicEdge<N,?>>>
Parameters:
other - the other node to compare to.