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

All Known Subinterfaces:
IColouredEdgeFactory<N,E>, ICompoundChildEdgeFactory<N,E>, ICompoundEdgeFactory<N,E>, IDirectedEdgeFactory<N,E>, IUndirectedEdgeFactory<N,E>
All Known Implementing Classes:
BaseChildCompoundEdgeFactory, BaseCompoundEdgeFactory, ChildCompoundEdgeFactory, CompoundEdgeFactory, EdgeFactory

public interface IBasicEdgeFactory<N extends IBasicNode<N,? extends IBasicEdge<N,?>>,E extends IBasicEdge<N,E>>


Method Summary
 boolean canCreateEdge()
          Tests is all the conditions have been met in the factory so that edge creation will succeed.
 E createEdge()
          Create a new edge and add it to the graph.
 IBasicPair<N,E> getCurrentNodePair()
          Returns the current node pair, or false if no nodes have been set.
 IBasicGraph<N,E> getGraph()
          Get the graph to which this factory acts upon.
 boolean isValidNodePair(N thisNode, N thatNode)
          Test if the node pair is valid.
 void setPair(N thisNode, N thatNode)
          Sets a pair of nodes with which to create a new edge.
 

Method Detail

getGraph

IBasicGraph<N,E> getGraph()
Get the graph to which this factory acts upon.

Returns:
The owning graph, cannot be null.

setPair

void setPair(N thisNode,
             N thatNode)
Sets a pair of nodes with which to create a new edge.

Parameters:
thisNode - a node in the edge pair, cannot be null.
thatNode - another node in the edge pair, cannot be null.
Throws:
java.lang.IllegalArgumentException - if isValidNodePair(thisNode, thatNode) == false.

isValidNodePair

boolean isValidNodePair(N thisNode,
                        N thatNode)
Test if the node pair is valid. Tests include, does the node pair belong to the same graph as that return by getGraph(), do both nodes belong to the same graph and are both nodes not null.

Parameters:
thisNode - a node that may be the end of an edge.
thatNode - another node that may be the end of an edge.
Returns:
true if the above conditions are met, false otherwise.

getCurrentNodePair

IBasicPair<N,E> getCurrentNodePair()
Returns the current node pair, or false if no nodes have been set.

Returns:
the current node pair or false if setPair(thisNode, thatNode) has not been called.

canCreateEdge

boolean canCreateEdge()
Tests is all the conditions have been met in the factory so that edge creation will succeed. AT the very least isValidNodePair(thisNode, thatNode) should be true.

Returns:
true if this is the case, false otherwise.

createEdge

E createEdge()
Create a new edge and add it to the graph.

Returns:
the newly created edge that is added to the graph