1 package jp.sourceforge.stigmata.birthmarks.osb.hungarian;
\r
4 * ハンガリアン法で,2次元配列の特定個所に引く線を表すクラス.
\r
6 * @author Haruaki Tamada
\r
8 public class Line implements Comparable<Line>{
\r
9 public static enum Direction{
\r
15 private int crossCount;
\r
16 private Direction direction = Direction.ROW;
\r
20 * @param index 行もしくは列の番号を表す..
\r
21 * @param count その行もしくは列に含まれる0の数.
\r
22 * @param crossCount その行,もしくは列に既に引かれている線の数.
\r
23 * @param direction 方向.
\r
25 public Line(int index, int count, int crossCount, Direction direction){
\r
28 this.crossCount = crossCount;
\r
29 this.direction = direction;
\r
33 * 位置を返す.行か,列かは,{@link #getDirection() <code>getDirection()</code>}メソッドで決定される.
\r
35 public int getIndex(){
\r
42 public int getCount(){
\r
49 public Direction getDirection(){
\r
55 * 0の数で比較する.ただし,0の数が同数であれば,交わっている線の数でも比較する.
\r
56 * 0が多いほど,また,交わっている線が多いほど大きいとする.
\r
59 public int compareTo(Line line){
\r
60 if(getCount() < line.getCount()){
\r
63 else if(getCount() > line.getCount()){
\r
67 if(crossCount < line.crossCount){
\r
70 if(crossCount > line.crossCount){
\r
78 * このオブジェクトの文字列表現を返す.
\r
80 public String toString(){
\r
81 return String.format("[index: %d, count: %d(%d) (%s)]", getIndex(), getCount(), crossCount, getDirection());
\r