/*****************************************************************************

  CSE 235 - Discrete Mathematics
   Spring 2007
   relation.cpp -- relation class implementation file, see relation.h for details

   Some methods have been implemented for you, most have not, you MUST
   implement ALL methods.

*************************************************************************/

#include "relation.h"

//------------------------------------------------------------------------
relation::relation()
{
}

//------------------------------------------------------------------------
relation::relation(int n) 
{
}

//------------------------------------------------------------------------
relation::~relation() 
{
}

//------------------------------------------------------------------------
void relation::init_relation(int n) 
{
}

//------------------------------------------------------------------------
relation::relation(const relation &S) 
{
}

//------------------------------------------------------------------------
relation& relation::operator =(const relation &S) 
{
    if(this!=&S)
    {
        /*
          Note, you cannot simply call the relation(S) constructor 
          since S is constant in this function.  Instead we have
          to copy all aspects of S directly.  
        */

    }
    return *this;
}

//------------------------------------------------------------------------
int relation::SetSize() const
{
  return 0;
}

//------------------------------------------------------------------------
bool relation::isReflexive() const
{
  return false;
}

//------------------------------------------------------------------------
bool relation::isSymmetric() const
{
  return false;
}

//------------------------------------------------------------------------
bool relation::isAsymmetric() const
{
  return false;
}

//------------------------------------------------------------------------
bool relation::isAntisymmetric() const
{
  return false;
}

//------------------------------------------------------------------------
bool relation::isTransitive() const
{
  return false;
}
    
//------------------------------------------------------------------------
bool relation::isPartialOrder() const
{
  return false;
}

//------------------------------------------------------------------------
bool relation::isEquivalenceRelation() const
{
  return false;
}

//-----------------------------------------------------------------------
// Note that we index 0 <= i,j <= n - 1
bool relation::isRelated(int i, int j) const
{
  return false;
}

//-----------------------------------------------------------------------
// Note that we index 0 <= i,j <= n - 1
void relation::AddRelation(int i, int j)
{
  return;
}
    
//-----------------------------------------------------------------------
void relation::DeleteRelation(int i, int j)
{
  return;
}

//------------------------------------------------------------------------
// This function has been implemented for you                
// this function uses row-major form, you may change it if you wish, but
// it looks pretty already.
void relation::Print()
{
  cout << endl;
  if(SetSize() == 0)
  {
    cout << "[empty]" << endl;
    return;
  }
  for(int i=0; i < SetSize(); i++)
  {
    cout << "[ ";
    for(int j=0; j < SetSize(); j++)
    {
      cout << isRelated(i,j) << " ";
    }
    cout << "]" << endl;
  }
  return;
}

//------------------------------------------------------------------------
// This function has been implemented for you                
istream& operator >>(istream &in, relation &R) 
{          
  int n;
  int temp_1;
  int temp_2;

  in >> n;
  R.init_relation(n);  //empties any pervious relation, allocates enough
                        //memory

  for (int i = 0; i < R.SetSize(); i++)
  {
    in >> temp_1;
    //now we read the rest of the line
    while (in.peek() != '\n' && !in.eof())
    {
      in >> temp_2;
      R.AddRelation(temp_1, temp_2);
    }
  }
    
  return in;
}

//---------------------------------------------------------------
// This function has been implemented for you           |
void relation::read(char *thefile) 
{ 
    ifstream infile(thefile);
    infile>>*this;
    infile.close();
}

//---------------------------------------------------------------
ostream& operator <<(ostream &out, const relation &R)      
{
   return out; // this should be the last thing in
               // this method.  Just leave it here.
}

//---------------------------------------------------------------
// This is already implemented for you--but you         |
// need to implement "<<" for it to work            |
void relation::write(char *thefile) const 
{
    ofstream out(thefile);
    out<<*this;
    out.close();
}

relation * ReflexiveClosure(relation *A)
{
  *R = new relation(0);
  return R;
}

relation * SymmetricClosure(relation *A)
{
  *R = new relation(0);
  return R;
}

relation * TransitiveClosure(relation *A)
{
  *R = new relation(0);
  return R;
}

relation * Union(relation *A, relation *B)
{
  *R = new relation(0);
  return R;
}

relation * Intersection(relation *A, relation *B)
{
  *R = new relation(0);
  return R;
}
