|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectclassycle.graph.GraphProcessor
public abstract class GraphProcessor
Abstract class for all algorithms based on deep search first.
This class is designed in accordance with the Template Method pattern.
The basic algorithm (implemented in the method
process(classycle.graph.Vertex)
) reads:
vertex.visit(); processBefore(vertex); for (int i = 0, n = vertex.getNumberOfOutgoingArcs(); i < n; i++) { processArc(vertex, vertex.getHeadVertex(i)); } processAfter(vertex);The methods
initializeProcessing()
,
processBefore()
,
processArc()
, and
processAfter()
have to be implemented
by concrete classes.
The class will be used by creating an instance and invoking
deepSearchFirst()
one or several times.
Either the graph will be
modified or some result objects are created which can be obtained
by special methods defined in concrete subclasses. Note, that
a GraphProcessor is not thread-safe.
Constructor Summary | |
---|---|
GraphProcessor()
|
Method Summary | |
---|---|
void |
deepSearchFirst(Vertex[] graph)
Performs a deep search first of the specified graph. |
protected abstract void |
finishProcessing(Vertex[] graph)
Finishes processing. |
protected abstract void |
initializeProcessing(Vertex[] graph)
Initializes processing. |
protected void |
process(Vertex vertex)
Processes the specified vertex. |
protected abstract void |
processAfter(Vertex vertex)
Processes the specified vertex after its arcs have been processed. |
protected abstract void |
processArc(Vertex tail,
Vertex head)
Processes the arc specified by tail and head vertices. |
protected abstract void |
processBefore(Vertex vertex)
Processes the specified vertex before its outgoing arcs are processed. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public GraphProcessor()
Method Detail |
---|
public void deepSearchFirst(Vertex[] graph)
graph
- A directed graph.protected void process(Vertex vertex)
protected abstract void initializeProcessing(Vertex[] graph)
deepSearchFirst(classycle.graph.Vertex[])
.
protected abstract void processBefore(Vertex vertex)
vertex
- Vertex to be processed.protected abstract void processArc(Vertex tail, Vertex head)
tail
- Tail vertex of the arc.head
- Head vertex of the arc.protected abstract void processAfter(Vertex vertex)
vertex
- Vertex to be processed.protected abstract void finishProcessing(Vertex[] graph)
deepSearchFirst(classycle.graph.Vertex[])
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |