org.hypergraphdb.algorithms
Interface HGTraversal

All Superinterfaces:
java.util.Iterator<Pair<HGHandle,HGHandle>>
All Known Implementing Classes:
HGBreadthFirstTraversal, HGDepthFirstTraversal

public interface HGTraversal
extends java.util.Iterator<Pair<HGHandle,HGHandle>>

This interface represents a generic graph traversal. Concrete traversals, reflecting variations in the order of visiting and of the filtering of the nodes are implemented to suit various graph related algorithms.

Traversal can be used either in the implementation graph algorithms, such as finding the shortest path between two atoms, or as the underlying result sets of certain queries. Because of this commonality, traversals are driven "by the outside", instead of doing the actual work of visiting through a callback mechanism. Nevertheless, concrete traversals may expose some form of callbacks for various events during the traversal, or expose the internal state of the process.

Because of their result set like nature, HGTraversal instances must be closed once the work is completed or in case of an exception. While not all traversal will necessarily maintain open cursors, it is always safer to make sure that they have been properly closed. Once a HGTraversal is closed, it can no longer be used.

It should be quite possible to implement the traversals as bidirectional (i.e. with hasPrev and prev methods defined) should a real need arise.

Author:
Borislav Iordanov

Method Summary
 boolean hasNext()
          Return true if there are remaining atoms to be visited and false otherwise.
 boolean isVisited(HGHandle handle)
          Return true if the given atom was already visited and false otherwise.
 Pair<HGHandle,HGHandle> next()
          Return a pair consisting of the link pointing to the next atom in the traversal as well as the atom itself.
 
Methods inherited from interface java.util.Iterator
remove
 

Method Detail

hasNext

boolean hasNext()

Return true if there are remaining atoms to be visited and false otherwise.

Specified by:
hasNext in interface java.util.Iterator<Pair<HGHandle,HGHandle>>

next

Pair<HGHandle,HGHandle> next()

Return a pair consisting of the link pointing to the next atom in the traversal as well as the atom itself. That is, return a Pair<handle to link, handle to target atom>.

Specified by:
next in interface java.util.Iterator<Pair<HGHandle,HGHandle>>

isVisited

boolean isVisited(HGHandle handle)

Return true if the given atom was already visited and false otherwise.

An atom is considered visited as soon as it is returned by a call to the next method, and not before.

Parameters:
handle - The handle of the atom.