Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
AbstractSCCImpl |
|
| 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 24.03.2005 | |
20 | * | |
21 | */ | |
22 | package net.sourceforge.combean.graph.alg.partition; | |
23 | ||
24 | import net.sourceforge.combean.graph.alg.AbstractGraphAlg; | |
25 | import net.sourceforge.combean.graph.containers.NodeNumberingAdvisor; | |
26 | import net.sourceforge.combean.interfaces.graph.alg.partition.NodePartitionVisitor; | |
27 | import net.sourceforge.combean.interfaces.graph.alg.partition.StronglyConnectedComponentsAlg; | |
28 | import net.sourceforge.combean.interfaces.graph.containers.NodeNumbering; | |
29 | ||
30 | /** | |
31 | * A convenience class for implementing SCC algorithms. | |
32 | * | |
33 | * @author schickin | |
34 | * | |
35 | */ | |
36 | public abstract class AbstractSCCImpl extends AbstractGraphAlg | |
37 | implements StronglyConnectedComponentsAlg { | |
38 | ||
39 | 24 | private NodePartitionVisitor partitionVisitor = null; |
40 | ||
41 | /** | |
42 | * constructor | |
43 | */ | |
44 | public AbstractSCCImpl() { | |
45 | 24 | super(); |
46 | 24 | } |
47 | ||
48 | /* (non-Javadoc) | |
49 | * @see net.sourceforge.combean.interfaces.graph.alg.partition.PartitioningAlg#setVisitor(net.sourceforge.combean.interfaces.graph.alg.partition.NodePartitionVisitor) | |
50 | */ | |
51 | public void setVisitor(NodePartitionVisitor partitionVisitor) { | |
52 | 24 | this.partitionVisitor = partitionVisitor; |
53 | 24 | } |
54 | ||
55 | /* (non-Javadoc) | |
56 | * @see net.sourceforge.combean.interfaces.graph.alg.partition.PartitioningAlg#getVisitor() | |
57 | */ | |
58 | public NodePartitionVisitor getVisitor() { | |
59 | 138 | return this.partitionVisitor; |
60 | } | |
61 | ||
62 | /** | |
63 | * Set a NodeNumbering as Visitor for the strongly connected components. | |
64 | * The NodeNumbering will be filled with the number of the SCCs, | |
65 | * starting with 0. | |
66 | * | |
67 | * @return the NodeNumbering to be used as Visitor | |
68 | */ | |
69 | public final NodeNumbering setNodeNumberingAsVisitor() { | |
70 | 24 | NodeNumbering numbering = |
71 | NodeNumberingAdvisor.getFastestNodeNumbering(getGraph()); | |
72 | 24 | setVisitor(new NodeNumberingAsPartitionVisitor(numbering)); |
73 | ||
74 | 24 | return numbering; |
75 | } | |
76 | } |