// DE.H
// John Ringland  8/19/95
// DE stands for Directed Edge

//	4/7/96	Fixed unitialized barr in istream >> operator.

#ifndef DE_H
#define DE_H

typedef unsigned int Name;
typedef int Boolean;
#include <assert.h>
//#include <iostream.h>
#include <iostream>
using namespace std;

class DE
{
   private:
	Name nam;
	Boolean barr;
//	Boolean perip;   			// An edge may be "peripheral".

	friend ostream& operator << ( ostream& out, const DE& d );
	friend istream& operator >> ( istream& in, DE& d );   
   public:
	DE()					// non-initializing constructor
	   : nam(0), barr(0)
	{ //  	assert(0); 			// This should never be called.
	  // Had to allow this because new LinList has 2 dummy nodes. 10/16/95
	}
   	DE(const DE& d)					// copy constructor
	   : nam(d.nam), barr(d.barr)
//	     , perip(d.perip)
	{}	
							//constructor
	DE(Name n, Boolean s)  
	   : nam(n), barr(s) 
//	     , perip(p)
	{}	       
       ~DE()						// destructor
	{}						// (nothing to do)

	DE& operator=(const DE& d);			// assignment

	Boolean operator==(const DE& d) const;		// equality

	Boolean operator!=(const DE& d) const;		// inequality

	DE bar() const				// return negative
	{	DE tmp(*this);
		tmp.barr=!tmp.barr;
		return tmp;
	}
//	Boolean peripheral() const		// is peripheral
//	{	return perip;  
//	}
	Name name() const
	{	return nam;
	}
	Boolean sameName(const DE& d) const
	{	return nam==d.nam;
	}
	Boolean sameSense(const DE& d) const
	{	return barr==d.barr;
	}
};

	ostream& operator << ( ostream& out, const DE& d )
	{	if(d.barr) out << "-";
		out << d.nam;
//		if(d.perip) out << "p";
		return out;
	}

	istream& operator >> ( istream& in, DE& d )
	{
		int i;
		in >> i;
		d.barr=0;
		if(i<0)	
		{	d.barr=1;
			i=-i;
		}
		d.nam = (Name)i;
		return in;
	}

	DE& DE::operator=(const DE& d)			// assignment
	{	if(this==&d) return *this;
		nam=d.nam;
		barr=d.barr;
//		perip=d.perip;
		return *this;
	}

	Boolean DE::operator==(const DE& d) const			// equality
	{	if(nam!=d.nam) return 0;
		if(barr!=d.barr) return 0;
//		if(perip!=d.perip) return 0;
		return 1;
	}

	Boolean DE::operator!=(const DE& d) const			// inequality
	{	if(nam!=d.nam) return 1;
		if(barr!=d.barr) return 1;
//		if(perip!=d.perip) return 1;
		return 0;
	}


#endif
