public abstract class GraphProcessor
extends java.lang.Object
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 and Description |
---|
GraphProcessor() |
Modifier and Type | Method and Description |
---|---|
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.
|
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[])
.