org.hypergraphdb.algorithms
Class HGDepthFirstTraversal

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

public class HGDepthFirstTraversal
extends java.lang.Object
implements HGTraversal

Implements a depth-first search of a graph. As a reminder, depth-first will visit atoms adjacent to the current before visiting its siblings.

Author:
Borislav Iordanov

Constructor Summary
HGDepthFirstTraversal(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

HGDepthFirstTraversal

public HGDepthFirstTraversal(HGHandle startAtom,
                             HGALGenerator adjListGenerator)
Method Detail

getStartAtom

public HGHandle getStartAtom()

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

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

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.

remove

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