|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface GraphIterator
Defines an algorithm in which to traverse the components of a graph.
A graph iterator operates by repeatedly returing graph components to the
caller. The order in which to return the components is specific to the
iterator. However, most iterators follow the following conventions:
Stage | Visited Node | Branch Set | Next Set | Comment |
---|---|---|---|---|
0 | {A} | Initial stage, iteration starts explicitly from A | ||
1 | A | {B,F} | {F,B} | Related nodes added to Next Set in LIFO order. |
2 | F | {A,B} | {B,B} | A already visited so not added to Next Set B not yet visited so added to queue. |
3 | B | {A,C,D,E,F} | {B,E,D,C} | A,F already visited so not added to Next Set |
4 | B | {E,D,C} | B already visited so ignore and move to next stage | |
5 | E | {B} | {D,C} | |
6 | D | {B,C} | {C,C} | |
7 | C | {B,D} | {C} | |
8 | C | { } | C already visited so ignore and move to next stage | |
9 | { } | Next set empty, iteration complete. |
Stage | Visited Node | Branch Set | Next Set | Comment |
---|---|---|---|---|
0 | {A} | Initial stage, iteration starts explicitly from A | ||
1 | A | {B,F} | {F,B} | Related nodes added to Next Set in LIFO order. |
2 | F | {A,B} | {B,B} | A already visited so not added to Next Set B not yet visited so added to queue. |
3 | B | {A,C,D,E,F} | {B} | Branch Killed. No nodes added to Next Set |
4 | B | { } | B already visited so ignore and move to next stage | |
9 | { } | Next set empty, iteration complete. |
GraphWalker
,
GraphTraversal
modules/extension/graph (gt-graph.jar)
Method Summary | |
---|---|
void |
cont(Graphable current,
GraphTraversal traversal)
Signals to the iterator that iteration should continue from the current component in the traversal. |
GraphTraversal |
getTraversal()
Returns the traversal for the iterator. |
void |
init(Graph graph,
GraphTraversal traversal)
Signals to the itereator that iteration is about to begin. |
void |
killBranch(Graphable current,
GraphTraversal traversal)
Signals the iterator to kill the branch at the current component. |
Graphable |
next(GraphTraversal traversal)
Returns the next graph component in the iteration. |
void |
setTraversal(GraphTraversal traversal)
Sets the traversal for the iterator. |
Method Detail |
---|
void setTraversal(GraphTraversal traversal)
traversal
- The traversal requesting components from the iterator.GraphTraversal getTraversal()
void init(Graph graph, GraphTraversal traversal)
graph
- The graph being whose components are being iterated over.Graphable next(GraphTraversal traversal)
void cont(Graphable current, GraphTraversal traversal)
current
- The current component of the traversal.void killBranch(Graphable current, GraphTraversal traversal)
current
- The current component of the traversal.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |