Coverage Report - net.sourceforge.combean.adapters.drasys.graph.DRAGraphUtils
 
Classes in this File Line Coverage Branch Coverage Complexity
DRAGraphUtils
69%
11/16
100%
6/6
1,6
 
 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 19.03.2005
 20  
  *
 21  
  */
 22  
 package net.sourceforge.combean.adapters.drasys.graph;
 23  
 
 24  
 import drasys.or.graph.AddEdgeI;
 25  
 import drasys.or.graph.AddVertexI;
 26  
 import drasys.or.graph.DuplicateEdgeException;
 27  
 import drasys.or.graph.DuplicateVertexException;
 28  
 import drasys.or.graph.GraphI;
 29  
 import drasys.or.graph.VertexNotFoundException;
 30  
 
 31  
 /**
 32  
  * @author schickin
 33  
  *
 34  
  */
 35  0
 public class DRAGraphUtils {
 36  
     
 37  
     public static void addNumberedVertices(AddVertexI g, int from, int to)
 38  
     throws DuplicateVertexException {
 39  189
         for (int i = from; i <= to; i++) {
 40  150
             g.addVertex(new Integer(i));
 41  
         }
 42  39
     }
 43  
     
 44  
     public static void addNumberedPath(AddEdgeI g, int[] path,
 45  
             boolean isDirected)
 46  
     throws DuplicateEdgeException, VertexNotFoundException {
 47  21
         for (int i = 0; i < path.length-1; i++) {
 48  15
             g.addEdge(new Integer(path[i]), new Integer(path[i+1]),
 49  
                     null, isDirected);
 50  
         }
 51  6
     }
 52  
 
 53  
     public static void addNumberedPath(AddEdgeI g, int from, int to,
 54  
             boolean isDirected)
 55  
     throws DuplicateEdgeException, VertexNotFoundException {
 56  3
         int[] path = new int[to-from+1];
 57  12
         for (int i = from; i <= to; i++) {
 58  9
             path[i-from] = i;
 59  
         }
 60  3
         addNumberedPath(g, path, isDirected);
 61  3
     }
 62  
     
 63  
     public static void addNumberedCycle(AddEdgeI g, int from, int to,
 64  
             boolean isDirected)
 65  
     throws DuplicateEdgeException, VertexNotFoundException {
 66  0
         addNumberedPath(g, from, to, isDirected);
 67  0
         g.addEdge(new Integer(to), new Integer(from), null, isDirected);
 68  0
     }
 69  
     
 70  
     public static DRAGraphVertexAsNode getVertexByNumber(GraphI g, int vertexNum) {
 71  0
         return new DRAGraphVertexAsNode(g.getVertex(new Integer(vertexNum)));
 72  
     }
 73  
 }