///////////////////////////////////////////////////////////////////////////////
//                   ALL STUDENTS COMPLETE THESE SECTIONS
// Title:            Satisfiability Test
// Files:            ABMatrix.java, CdbTuple.java, Dialog1.java, Frame1.java,
//                   JTableHeaderToolTips.java, Mytest.java, RowNumberHeader.java
// Semester:         Spring 2007
//
// Author:           Hang Yue, yuehang366@gmail.com
// CS Login:         hyue
// Lecturer's Name:  Dr.Peter Revesz
// Lab Section:      (your lab section number)
//
//                   PAIR PROGRAMMERS COMPLETE THIS SECTION
// Pair Partner:     (name of your pair programming partner)
// CS Login:         (partner's login name)
// Lecturer's Name:  (name of your partner's lecturer)
// Lab Section:      (your partner's lab section number)
//
//                   STUDENTS WHO GET HELP FROM ANYONE OTHER THAN THEIR PARTNER
// Credits:          Scot Anderson
//////////////////////////// 80 columns wide //////////////////////////////////
package satisfiablitytest;

import java.io.Serializable;

public class CdbTuple implements Serializable {
	
	
	/**
	 * for serialization
	 */
	private static final long serialVersionUID = -8537171694674323049L;

	/**
	 * Represents an addition bound matrix
	 */
	private ABMatrix abm;
	
	/**
	 * names is a list of variable names associated with the rows and columns
	 */
	//private String[] names;
	private int n;
	/**
	 * The do nothing constructor, you will probably want to write a do 
	 * something constructor.
	 */
	public CdbTuple()
	{
		abm = null;
		//names = null;
		n=0;
	}
	
	public CdbTuple(ABMatrix mat, int m, String []names )
	{
		abm = mat;
	   //this.names = names;
		n=m;
	}
	/**
	 * test satisfiability's method
	 */
    public boolean satisfiable() 
    {
        int m =0;
        
        while(m<Math.log10(n+1))
        { m++;
        for(int k=0;k<n;k++)
        {   
          for(int i=0;i<n;i++)
          {
              for(int j=0;j<n;j++)
              {
                 abm.matrix[i][j]= Math.max(abm.matrix[i][j], abm.matrix[i][k]+abm.matrix[k][j]);
              } 
            }
          }    
        }
        
        boolean flag=true;
        
        for (int i=0;i<n;i++)
        {
            if (abm.matrix[i][i]>0)
            { 
                flag=false;
            }
        }
        return flag;
    } 
}
