Coverage Report - net.sourceforge.combean.test.graph.alg.spath.AbstractGraphWithEdgeWeightsFixture
 
Classes in this File Line Coverage Branch Coverage Complexity
AbstractGraphWithEdgeWeightsFixture
100%
20/20
N/A
0
 
 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 11.04.2005
 20  
  *
 21  
  */
 22  
 package net.sourceforge.combean.test.graph.alg.spath;
 23  
 
 24  
 import junit.framework.TestCase;
 25  
 import net.sourceforge.combean.graph.containers.MapAsEdgeMap;
 26  
 import net.sourceforge.combean.interfaces.graph.Node;
 27  
 import net.sourceforge.combean.interfaces.graph.alg.spath.SingleSourceShortestPathAlg;
 28  
 import net.sourceforge.combean.interfaces.graph.containers.EdgeMap;
 29  
 import net.sourceforge.combean.interfaces.graph.containers.FixedEdgeMap;
 30  
 import net.sourceforge.combean.interfaces.graph.prop.ConstructableNumberedGraphProp;
 31  
 import net.sourceforge.combean.interfaces.graph.prop.NeighborhoodGraphProp;
 32  
 import net.sourceforge.combean.test.helpers.factories.GraphFixtureFactory;
 33  
 
 34  
 /**
 35  
  * @author schickin
 36  
  *
 37  
  */
 38  
 public abstract class AbstractGraphWithEdgeWeightsFixture
 39  
 extends TestCase {
 40  
 
 41  84
     protected Node startNode = null;
 42  84
     protected Node targetNode = null;
 43  84
     protected NeighborhoodGraphProp g = null;
 44  84
     protected FixedEdgeMap<Double> edgeWeights = null;
 45  
 
 46  84
     protected ConstructableNumberedGraphProp constructG = null;
 47  
 
 48  
     /**
 49  
      * Constructor.
 50  
      */
 51  
     public AbstractGraphWithEdgeWeightsFixture(
 52  
             int numNodes, int[][] edgesWithWeights) {
 53  84
         super();
 54  
         
 55  84
         constructGraph(numNodes, edgesWithWeights);
 56  84
     }
 57  
 
 58  
     private final void constructGraph(int numNodes, int[][] edgesWithWeights) {
 59  84
         EdgeMap<Double> tmpEdgeMap = new MapAsEdgeMap<Double>();
 60  84
         this.constructG =
 61  
             GraphFixtureFactory.createGraphWithEdgeWeights(numNodes,
 62  
                     edgesWithWeights, tmpEdgeMap);
 63  84
         this.edgeWeights = tmpEdgeMap;
 64  
 
 65  84
         this.startNode = this.constructG.getNode(0);
 66  84
         this.targetNode = this.constructG.getNode(numNodes-1);
 67  
 
 68  84
         this.g = (NeighborhoodGraphProp) this.constructG;
 69  84
     }
 70  
 
 71  
     protected final void runShortestPathAlg(
 72  
             SingleSourceShortestPathAlg<Double> alg) {
 73  21
         alg.setGraph(this.g);
 74  21
         alg.setSource(this.startNode);
 75  21
         alg.setEdgeWeightMap(this.edgeWeights);
 76  
         
 77  21
         alg.run();
 78  21
     }
 79  
 }