|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectedu.upc.dama.dex.algorithms.Traversal
edu.upc.dama.dex.algorithms.TraversalDFS
public class TraversalDFS
This class can be used to traverse the graph using the depth-first search algorithm (DFS). searching a tree, tree structure, or graph. One starts at the root (selecting some node as the root in the graph case) and explores as far as possible along each branch before backtracking.
Concretely, it consists in traversing the graph by starting at a source node and exploring as far (depth) as possible along each branch before backtracking.
It is possible to set some restrictions after constructing a new instance of this class and before running it in order to limit the results. Those restrictions are:
Traversal.addEdge(int edgetype, short navigation) for adding one edge
type and its navigation and Traversal.addAllEdges(short navigation)
for adding all edge types and their navigation.
Traversal.addNode(int nodetype)
for adding one node type and Traversal.addAllNodes() for adding all
node types.
Navigation
There are three kinds of edge navigation:
Algorithm.NAVIGATION_FORWARD: Allows to forward traverse edges.
Algorithm.NAVIGATION_BACKWARD: Allows to backward traverse edges.
Algorithm.NAVIGATION_UNDIRECTED: Allows to traverse edges in both directions.
TraversalDFS.next() is called. The execution
stops when the last node is reached or when the user decides not to continue
calling the TraversalDFS.next() method.
Please, see edu.upc.dama.dex.algorithms for further information related
to how to use this class.
NOTE: It is required to indicate the set of edge types and the set of node types before running this algorithm.
| Field Summary |
|---|
| Fields inherited from interface edu.upc.dama.dex.algorithms.Algorithm |
|---|
NAVIGATION_BACKWARD, NAVIGATION_FORWARD, NAVIGATION_UNDIRECTED |
| Constructor Summary | |
|---|---|
TraversalDFS(Graph graph,
long source)
Creates a new instance of Traversal. |
|
| Method Summary | |
|---|---|
void |
close()
Closes the instance. |
boolean |
hasNext()
Returns whether there are more nodes to traverse in the graph. |
java.lang.Long |
next()
Returns the next node and advances the iterator. |
| Methods inherited from class edu.upc.dama.dex.algorithms.Traversal |
|---|
addAllEdges, addAllNodes, addEdge, addNode |
| 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 |
|---|
remove |
| Constructor Detail |
|---|
public TraversalDFS(Graph graph,
long source)
Traversal. After creating
this instance is required to indicate the set of edge types and the set
of node types which will be navigated through while traversing the graph.
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 |
|---|
public void close()
TraversalOnce executed, the instance becomes invalid.
close in class Traversalpublic boolean hasNext()
public java.lang.Long next()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||