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

Type Parameters:
N - The node class to be used. It must implement INode.
E - The edge class to be used. It must implement IEdge.
All Superinterfaces:
java.util.Collection<E>, java.lang.Iterable<E>, java.util.Set<E>
All Known Subinterfaces:
IDirectedEdgeSet<N,E>, IFilteredEdgeSet<N,E>
All Known Implementing Classes:
DirectedEdgeSet, EdgeSet, FilteredEdgeSet

public interface IEdgeSet<N extends IBasicNode<N,? extends IBasicEdge<N,?>>,E extends IBasicEdge<N,E>>
extends java.util.Set<E>

A set designed to provide convenient access to edges. This interface will typically be implemented and used as a data structure with the graph library classes themselves rather than by clients of the library. The set does not ensure that the edges all belong to the same graph (although this is recommended and the client should ensure this), it only requires that the edge indexes are unique, based on equals() and their comparitor.

Author:
smoodie

Method Summary
 boolean contains(int edgeIdx)
          Does an edge with this index exist in the set.
 boolean contains(N thisNode, N thatNode)
          Does the edge set contain at least one edge with these nodes.
 E get(int edgeIdx)
          Get the edge with the given index.
 java.util.SortedSet<E> get(N thisNode, N thatNode)
          Get the edges that match the given node connectivity.
 java.util.SortedSet<E> getEdgesWith(N thisNode, N otherNode)
          Gets the edges that contain this node as one of its ends.
 boolean hasEdgesWith(N thisNode, N otherNode)
          Does this edge set contain one or more edges associated with this node?
 
Methods inherited from interface java.util.Set
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray
 

Method Detail

contains

boolean contains(N thisNode,
                 N thatNode)
Does the edge set contain at least one edge with these nodes. This assumes a direction to the nodes so if the edges are undirected the method must be called for both orientations of the edge.

Parameters:
thisNode - a node the edge may be connected to.
thatNode - another node the edge may be connected to.
Returns:
True if one or more edges has this connectivity, false otherwise.

get

java.util.SortedSet<E> get(N thisNode,
                           N thatNode)
Get the edges that match the given node connectivity. The connectivity is undirected.

Parameters:
thisNode - a node the edge may be connected to. Cannot be null.
thatNode - another node the edge may be connected to. Cannot be null.
Returns:
The set of edges containing this connectivity. Note that the set is guaranteed to contain at least one edge.
Throws:
java.lang.NullPointerException - if the parameters are null.
java.lang.IllegalArgumentException - if contains(N thisNode, N thatNode) == false

hasEdgesWith

boolean hasEdgesWith(N thisNode,
                     N otherNode)
Does this edge set contain one or more edges associated with this node?

Parameters:
thisNode - The node that is the point of reference.
otherNode - The node to be tested. Can be null.
Returns:
True if one or more edges conatin the node, false otherwise.

getEdgesWith

java.util.SortedSet<E> getEdgesWith(N thisNode,
                                    N otherNode)
Gets the edges that contain this node as one of its ends.

Parameters:
thisNode - the node that is the point of reference.
otherNode - The node associated with the edges. Cannot be null.
Returns:
The set of edges containing the matched nodes. The set will contain at least one node.
Throws:
java.lang.NullPointerException - of node is null.
java.lang.IllegalArgumentException - if hasEdgesWith(node) == false.

contains

boolean contains(int edgeIdx)
Does an edge with this index exist in the set.

Parameters:
edgeIdx - The edge index.
Returns:
True if an edge matching this index was found, false otherwise.

get

E get(int edgeIdx)
Get the edge with the given index.

Parameters:
edgeIdx - The index of the edge to be obtained.
Returns:
The edge with this index. Will not be null.
Throws:
java.lang.IllegalArgumentException - if contains(edgeIdx) == false