org.hypergraphdb.algorithms
Class HGBreadthFirstTraversal

java.lang.Object
  extended by org.hypergraphdb.algorithms.HGBreadthFirstTraversal
All Implemented Interfaces:
java.util.Iterator<Pair<HGHandle,HGHandle>>, HGTraversal

public class HGBreadthFirstTraversal
extends java.lang.Object
implements HGTraversal

Implements a depth-first search of a graph. As a reminder, breadth-first will visit all atoms in an adjency list before exploring their adjacent atoms in turn.

Author:
Borislav Iordanov

Constructor Summary
HGBreadthFirstTraversal(HGHandle startAtom, HGALGenerator adjListGenerator)
           
 
Method Summary
 HGHandle getStartAtom()
           
 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.
 void remove()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HGBreadthFirstTraversal

public HGBreadthFirstTraversal(HGHandle startAtom,
                               HGALGenerator adjListGenerator)
Method Detail

getStartAtom

public HGHandle getStartAtom()

remove

public void remove()
Specified by:
remove in interface java.util.Iterator<Pair<HGHandle,HGHandle>>

hasNext

public boolean hasNext()
Description copied from interface: HGTraversal

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

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

isVisited

public boolean isVisited(HGHandle handle)
Description copied from interface: HGTraversal

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.

Specified by:
isVisited in interface HGTraversal
Parameters:
handle - The handle of the atom.

next

public Pair<HGHandle,HGHandle> next()
Description copied from interface: HGTraversal

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>>
Specified by:
next in interface HGTraversal