| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| Path |
|
| 2.5;2,5 |
| 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 06.01.2005 | |
| 20 | * | |
| 21 | */ | |
| 22 | package net.sourceforge.combean.samples.simplegraphs; | |
| 23 | ||
| 24 | /** | |
| 25 | * @author schickin | |
| 26 | * | |
| 27 | */ | |
| 28 | public class Path extends SimpleNumberGraph { | |
| 29 | ||
| 30 | /** | |
| 31 | * Construct a path of the given size. | |
| 32 | * | |
| 33 | * @param size the length of the path | |
| 34 | */ | |
| 35 | public Path(int size) { | |
| 36 | 108 | super(size); |
| 37 | 108 | } |
| 38 | ||
| 39 | /** | |
| 40 | * @see net.sourceforge.combean.samples.simplegraphs.NumberGraph#calcNextNode(int, int) | |
| 41 | */ | |
| 42 | protected int calcNextNode(int sourceNodeNum, int minNodeNum) { | |
| 43 | ||
| 44 | 399 | int result = NOSUCHNODE; |
| 45 | ||
| 46 | 399 | if (minNodeNum <= sourceNodeNum-1) { |
| 47 | 138 | result = sourceNodeNum-1; |
| 48 | } | |
| 49 | 261 | else if (minNodeNum <= sourceNodeNum+1) { |
| 50 | 153 | result = sourceNodeNum+1; |
| 51 | } | |
| 52 | ||
| 53 | 399 | if (result >= getNumNodes()) { |
| 54 | 33 | result = NOSUCHNODE; |
| 55 | } | |
| 56 | ||
| 57 | 399 | return result; |
| 58 | } | |
| 59 | ||
| 60 | } |