Coverage Report - net.sourceforge.combean.graph.alg.traversal.NodeCountVisitor
 
Classes in this File Line Coverage Branch Coverage Complexity
NodeCountVisitor
100%
10/10
N/A
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  
  * A simple TraversalVisitor which counts the number of visited nodes.
 20  
  * 
 21  
  * Created on 14.01.2005
 22  
  *
 23  
  */
 24  
 package net.sourceforge.combean.graph.alg.traversal;
 25  
 
 26  
 import net.sourceforge.combean.interfaces.graph.Graph;
 27  
 import net.sourceforge.combean.interfaces.graph.Node;
 28  
 
 29  
 /**
 30  
  * @author schickin
 31  
  *
 32  
  */
 33  
 public class NodeCountVisitor extends IdleTraversalVisitor {
 34  
         
 35  24
         private long nodeCount = 0;
 36  
 
 37  
         /**
 38  
          * 
 39  
          */
 40  
         public NodeCountVisitor() {
 41  24
                 super();
 42  24
         }
 43  
         
 44  
         /**
 45  
          * Get the number of visited nodes.
 46  
          * 
 47  
          * @return Returns the nodeCount.
 48  
          */
 49  
         public final long getNodeCount() {
 50  30
                 return this.nodeCount;
 51  
         }
 52  
         
 53  
         /**
 54  
          * @see net.sourceforge.combean.interfaces.graph.alg.traverse.TraversalVisitor#visitNode(net.sourceforge.combean.interfaces.graph.Node)
 55  
          */
 56  
         public void visitNode(Node v) {
 57  144
                 this.nodeCount++;
 58  144
         }
 59  
         
 60  
         /**
 61  
          * @see net.sourceforge.combean.interfaces.graph.alg.traverse.TraversalVisitor#init(net.sourceforge.combean.interfaces.graph.Graph)
 62  
          */
 63  
         public void init(Graph g) {
 64  12
                 this.nodeCount = 0;
 65  12
         }
 66  
 
 67  
         /**
 68  
          * @see net.sourceforge.combean.interfaces.graph.alg.traverse.TraversalVisitor#initLocal(net.sourceforge.combean.interfaces.graph.Graph, net.sourceforge.combean.interfaces.graph.Node)
 69  
          */
 70  
         public void initLocal(Graph g, Node startNode) {
 71  18
                 this.nodeCount = 0;
 72  18
         }
 73  
 }