slib.sglib.algo.graph.traversal.classical
Class BFS

java.lang.Object
  extended by slib.sglib.algo.graph.traversal.classical.BFS
All Implemented Interfaces:
GraphTraversal

public class BFS
extends Object
implements GraphTraversal

Class used to perform traversal on a graph using Breadth First Search (BFS). Algorithm start from a set of vertices and can be tuned to only consider particular types of relationships. Important: The graph is not expected to be modified during the traversal. Traversal is made on the fly i.e. iteratively next calls to the next methods. more about BFS

Author:
Sebastien Harispe

Constructor Summary
BFS(slib.sglib.model.graph.G g, Set<org.openrdf.model.URI> sources, slib.sglib.model.graph.utils.WalkConstraint wc)
          Creates an instance of BFS used to perform a Bread First Search Traversal over the graph.
BFS(slib.sglib.model.graph.G g, org.openrdf.model.URI source, slib.sglib.model.graph.utils.WalkConstraint wc)
          Creates an instance of BFS used to perform a Bread First Search Traversal over the graph.
 
Method Summary
 boolean hasNext()
          Check if the traversal is finished.
 org.openrdf.model.URI next()
          Access to the next vertex reached by the BFS.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BFS

public BFS(slib.sglib.model.graph.G g,
           Set<org.openrdf.model.URI> sources,
           slib.sglib.model.graph.utils.WalkConstraint wc)
Creates an instance of BFS used to perform a Bread First Search Traversal over the graph. The first elements of the iteration will be the sources. The graph is not expected to be modified during the traversal.

Parameters:
g - the graph to consider
sources - the set of vertices considered as sources of the traversal i.e. from which the traversal start
wc - the constraint applied to the walk

BFS

public BFS(slib.sglib.model.graph.G g,
           org.openrdf.model.URI source,
           slib.sglib.model.graph.utils.WalkConstraint wc)
Creates an instance of BFS used to perform a Bread First Search Traversal over the graph. The first element of the iteration will be the source of the BFS The graph is not expected to be modified during the traversal.

Parameters:
g - the graph to consider
source - the source of the traversal i.e. from which the traversal start
wc - the constraint applied to the walk
Method Detail

hasNext

public boolean hasNext()
Check if the traversal is finished.

Specified by:
hasNext in interface GraphTraversal
Returns:
is the BFS finished

next

public org.openrdf.model.URI next()
Access to the next vertex reached by the BFS.

Specified by:
next in interface GraphTraversal
Returns:
the next vertex.


Copyright © 2013. All Rights Reserved.