edu.upc.dama.dex.algorithms
Class Traversal

java.lang.Object
  extended by edu.upc.dama.dex.algorithms.Traversal
All Implemented Interfaces:
Algorithm, java.util.Iterator
Direct Known Subclasses:
TraversalBFS, TraversalDFS

public abstract class Traversal
extends java.lang.Object
implements java.util.Iterator, Algorithm

Any class implementing this abstract class can be used to traverse a graph.

Author:
Sparsity Technologies

Field Summary
 
Fields inherited from interface edu.upc.dama.dex.algorithms.Algorithm
NAVIGATION_BACKWARD, NAVIGATION_FORWARD, NAVIGATION_UNDIRECTED
 
Constructor Summary
Traversal(Graph graph, long source)
          Creates a new instance of Traversal.
 
Method Summary
 void addAllEdges(short navigation)
          Adds all the edge types contained in the graph and their navigation in order to restrict the set of edge types allowed and their direction while traversing the graph.
 void addAllNodes()
          Adds all the node types contained in the graph to restrict the set of allowed node types.
 void addEdge(int edgetype, short navigation)
          Adds an edge type and its navigation in order to restrict the set of edge types allowed and their direction while traversing the graph.
 void addNode(int nodetype)
          Adds a node type in order to restrict the set of allowed node types while traversing the graph.
abstract  void close()
          Closes the instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Iterator
hasNext, next, remove
 

Constructor Detail

Traversal

public Traversal(Graph graph,
                 long source)
Creates a new instance of Traversal.

Parameters:
graph - Graph on which the traversal will be run.
source - The node identifier which identifies the source node at which the algorithm execution will start.
Method Detail

addEdge

public void addEdge(int edgetype,
                    short navigation)
Adds an edge type and its navigation in order to restrict the set of edge types allowed and their direction while traversing the graph. It is possible to add as many edge types as all the different edge types contained in the graph.

Parameters:
edgetype - The edge type to restrict the set of edges allowed while traversing the graph during the execution of the algorithm.
navigation - The direction that has to be followed while traversing each edge of the given edge type during the execution of the algorithm. It must be Algorithm.NAVIGATION_BACKWARD, Algorithm.NAVIGATION_FORWARD or Algorithm.NAVIGATION_UNDIRECTED.

addAllEdges

public void addAllEdges(short navigation)
Adds all the edge types contained in the graph and their navigation in order to restrict the set of edge types allowed and their direction while traversing the graph.

Parameters:
navigation - The direction that has to be followed while traversing each edge during the execution of the algorithm. It must be Algorithm.NAVIGATION_BACKWARD, Algorithm.NAVIGATION_FORWARD or Algorithm.NAVIGATION_UNDIRECTED.

addNode

public void addNode(int nodetype)
Adds a node type in order to restrict the set of allowed node types while traversing the graph. It is possible to add as many node types as all the different node types contained in the graph.

Parameters:
nodetype - The node type to restrict the set of nodes allowed while traversing the graph during the execution of the algorithm.

addAllNodes

public void addAllNodes()
Adds all the node types contained in the graph to restrict the set of allowed node types.


close

public abstract void close()
Closes the instance.

Once executed, the instance becomes invalid.