| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| PartitionsTraversalVisitor |
|
| 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 26.03.2005 | |
| 20 | * | |
| 21 | */ | |
| 22 | package net.sourceforge.combean.graph.alg.partition; | |
| 23 | ||
| 24 | import net.sourceforge.combean.graph.alg.traversal.IdleTraversalVisitor; | |
| 25 | import net.sourceforge.combean.interfaces.graph.Graph; | |
| 26 | import net.sourceforge.combean.interfaces.graph.Node; | |
| 27 | import net.sourceforge.combean.interfaces.graph.alg.partition.NodePartitionVisitor; | |
| 28 | ||
| 29 | /** | |
| 30 | * This class wraps a NodePartitionsVisitor inside a traversal visitor. | |
| 31 | * Every components that is encountered during the traversal is reported | |
| 32 | * from the traversal visitor to the node partition visitor. | |
| 33 | * | |
| 34 | * @see PartitionsTraversalVisitor | |
| 35 | * @see net.sourceforge.combean.interfaces.graph.alg.traverse.TraversalVisitor | |
| 36 | * | |
| 37 | * @author schickin | |
| 38 | * | |
| 39 | */ | |
| 40 | public class PartitionsTraversalVisitor extends IdleTraversalVisitor { | |
| 41 | ||
| 42 | 12 | private NodePartitionVisitor partitionVis = null; |
| 43 | ||
| 44 | /** | |
| 45 | * | |
| 46 | */ | |
| 47 | public PartitionsTraversalVisitor(NodePartitionVisitor partitionVis) { | |
| 48 | 12 | super(); |
| 49 | ||
| 50 | 12 | this.partitionVis = partitionVis; |
| 51 | 12 | } |
| 52 | ||
| 53 | /* (non-Javadoc) | |
| 54 | * @see net.sourceforge.combean.interfaces.graph.alg.traverse.TraversalVisitor#init(net.sourceforge.combean.interfaces.graph.Graph) | |
| 55 | */ | |
| 56 | public void init(Graph g) { | |
| 57 | 12 | this.partitionVis.init(g); |
| 58 | 12 | } |
| 59 | ||
| 60 | /* (non-Javadoc) | |
| 61 | * @see net.sourceforge.combean.interfaces.graph.alg.traverse.TraversalVisitor#leaveComponent(net.sourceforge.combean.interfaces.graph.Node) | |
| 62 | */ | |
| 63 | public void leaveComponent(Node v) { | |
| 64 | 30 | this.partitionVis.endPartition(); |
| 65 | 30 | } |
| 66 | ||
| 67 | /* (non-Javadoc) | |
| 68 | * @see net.sourceforge.combean.interfaces.graph.alg.traverse.TraversalVisitor#visitComponent(net.sourceforge.combean.interfaces.graph.Node) | |
| 69 | */ | |
| 70 | public void visitComponent(Node v) { | |
| 71 | 30 | this.partitionVis.startPartition(); |
| 72 | 30 | } |
| 73 | ||
| 74 | /* (non-Javadoc) | |
| 75 | * @see net.sourceforge.combean.interfaces.graph.alg.traverse.TraversalVisitor#visitNode(net.sourceforge.combean.interfaces.graph.Node) | |
| 76 | */ | |
| 77 | public void visitNode(Node v) { | |
| 78 | 78 | this.partitionVis.addNode(v); |
| 79 | 78 | } |
| 80 | ||
| 81 | /* (non-Javadoc) | |
| 82 | * @see net.sourceforge.combean.interfaces.graph.alg.traverse.TraversalVisitor#finish() | |
| 83 | */ | |
| 84 | public void finish() { | |
| 85 | 0 | this.partitionVis.finish(); |
| 86 | 0 | } |
| 87 | } |