Package classycle.graph
Class GraphProcessor
java.lang.Object
classycle.graph.GraphProcessor
- Direct Known Subclasses:
LongestWalkProcessor
,PackageProcessor
,StrongComponentProcessor
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.
- Author:
- Franz-Josef Elmer
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
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
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.
-
Constructor Details
-
GraphProcessor
public GraphProcessor()
-
-
Method Details
-
deepSearchFirst
Performs a deep search first of the specified graph. First, processing will be initialized and all vertices of the graph will be reset. Then for all unvisited vertices the method process(Vertex) will be invoked. At last, processing will be finished.- Parameters:
graph
- A directed graph.
-
process
Processes the specified vertex. -
initializeProcessing
Initializes processing. Will be called in methoddeepSearchFirst(classycle.graph.Vertex[])
. -
processBefore
Processes the specified vertex before its outgoing arcs are processed.- Parameters:
vertex
- Vertex to be processed.
-
processArc
Processes the arc specified by tail and head vertices.- Parameters:
tail
- Tail vertex of the arc.head
- Head vertex of the arc.
-
processAfter
Processes the specified vertex after its arcs have been processed.- Parameters:
vertex
- Vertex to be processed.
-
finishProcessing
Finishes processing. Will be called in methoddeepSearchFirst(classycle.graph.Vertex[])
.
-