| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| TraversalVisitor |
|
| 1.0;1 |
| 1 | /* | |
| 2 | This file is part of Combean. | |
| 3 | ||
| 4 | Combean is free software; you can redistribute it and/or modify | |
| 5 | it under the terms of the GNU General Public License as published by | |
| 6 | the Free Software Foundation; either version 2 of the License, or | |
| 7 | (at your option) any later version. | |
| 8 | ||
| 9 | Combean is distributed in the hope that it will be useful, | |
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 12 | GNU General Public License for more details. | |
| 13 | ||
| 14 | You should have received a copy of the GNU General Public License | |
| 15 | along with Combean; if not, write to the Free Software | |
| 16 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
| 17 | */ | |
| 18 | /* | |
| 19 | * Created on 08.01.2005 | |
| 20 | * | |
| 21 | */ | |
| 22 | package net.sourceforge.combean.interfaces.graph.alg.traverse; | |
| 23 | ||
| 24 | import net.sourceforge.combean.interfaces.graph.Edge; | |
| 25 | import net.sourceforge.combean.interfaces.graph.Graph; | |
| 26 | import net.sourceforge.combean.interfaces.graph.Node; | |
| 27 | import net.sourceforge.combean.interfaces.graph.alg.GraphAlgorithm; | |
| 28 | ||
| 29 | /** | |
| 30 | * Helper object for graph traversal algorithms. | |
| 31 | * @see GraphAlgorithm | |
| 32 | * | |
| 33 | * @author schickin | |
| 34 | * | |
| 35 | */ | |
| 36 | public interface TraversalVisitor { | |
| 37 | ||
| 38 | /** | |
| 39 | * Signal if the traversal can be terminated. | |
| 40 | * Note that this is only a suggestion to the traversal algorithm. | |
| 41 | * | |
| 42 | * @return true if termination is possible. | |
| 43 | */ | |
| 44 | public boolean readyToTerminate(); | |
| 45 | ||
| 46 | /** | |
| 47 | * A node has been detected for the first time. | |
| 48 | * | |
| 49 | * @param e the edge through which the node has been detected. | |
| 50 | * @param from the other node from where the new node has been detected. | |
| 51 | */ | |
| 52 | public void openNeighbor(Edge e, Node from); | |
| 53 | ||
| 54 | /** | |
| 55 | * A node has been redetected | |
| 56 | * | |
| 57 | * @param e the edge through which the node has been detected. | |
| 58 | * @param from the other node from where the node has been detected. | |
| 59 | */ | |
| 60 | public void reopenNeighbor(Edge e, Node from); | |
| 61 | ||
| 62 | /** | |
| 63 | * The traversal algorithms begins to explore the neighborhood of a node. | |
| 64 | * | |
| 65 | * @param v the node which is being visited. | |
| 66 | */ | |
| 67 | public void visitNode(Node v); | |
| 68 | ||
| 69 | /** | |
| 70 | * The traversal algorithms starts visiting a component of the graph. | |
| 71 | * This is also called (exactly once) when the traversal starts from a | |
| 72 | * local start node. | |
| 73 | * | |
| 74 | * @param v an arbitrary node in the component. | |
| 75 | */ | |
| 76 | public void visitComponent(Node v); | |
| 77 | ||
| 78 | /** | |
| 79 | * The traversal algorithm has finished visiting a component of the graph. | |
| 80 | * This is also called (exactly once) when the traversal starts from a | |
| 81 | * local start node. | |
| 82 | * | |
| 83 | * @param v an arbitrary node in the component. | |
| 84 | */ | |
| 85 | public void leaveComponent(Node v); | |
| 86 | ||
| 87 | /** | |
| 88 | * This method is called immediately before the traversal algorithm starts | |
| 89 | * if all components of g shall be traversed. | |
| 90 | * | |
| 91 | * @param g the graph which will be traversed. | |
| 92 | */ | |
| 93 | public void init(Graph g); | |
| 94 | ||
| 95 | /** | |
| 96 | * This method is called immediately before the traversal algorithm starts | |
| 97 | * if a component of g shall be traversed from a local start node. | |
| 98 | * | |
| 99 | * @param g the graph which will be traversed. | |
| 100 | * @param startNode the local start node. | |
| 101 | */ | |
| 102 | public void initLocal(Graph g, Node startNode); | |
| 103 | ||
| 104 | /** | |
| 105 | * This method is called when the traversal is terminated. | |
| 106 | */ | |
| 107 | public void finish(); | |
| 108 | } |