00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #include <Vertex.h>
00038
00039 Vertex::Vertex(int tag, int ref, double weight, int color)
00040 :TaggedObject(tag), myRef(ref), myWeight(weight), myColor(color),
00041 myDegree(0), myTmp(0), myAdjacency(0,8)
00042 {
00043
00044 }
00045
00046 Vertex::~Vertex()
00047 {
00048
00049 }
00050
00051 void
00052 Vertex::setWeight(double newWeight)
00053 {
00054 myWeight = newWeight;
00055 }
00056
00057 void
00058 Vertex::setColor(int newColor)
00059 {
00060 myColor = newColor;
00061 }
00062
00063 void
00064 Vertex::setTmp(int newTmp)
00065 {
00066 myTmp = newTmp;
00067 }
00068
00069 int
00070 Vertex::getRef(void) const
00071 {
00072 return myRef;
00073 }
00074
00075 double
00076 Vertex::getWeight(void) const
00077 {
00078 return myWeight;
00079 }
00080
00081 int
00082 Vertex::getColor(void) const
00083 {
00084 return myColor;
00085 }
00086
00087 int
00088 Vertex::getTmp(void) const
00089 {
00090 return myTmp;
00091 }
00092
00093 int
00094 Vertex::addEdge(int otherTag)
00095 {
00096
00097 if (otherTag == this->getTag())
00098 return 0;
00099
00100
00101 if (myAdjacency.getLocation(otherTag) < 0) {
00102 myAdjacency[myDegree] = otherTag;
00103 myDegree++;
00104 return 0;
00105 }
00106 else
00107 return 1;
00108 }
00109
00110
00111 int
00112 Vertex::getDegree(void) const
00113 {
00114 return myDegree;
00115 }
00116
00117 const ID &
00118 Vertex::getAdjacency(void) const
00119 {
00120 return myAdjacency;
00121 }
00122
00123 void
00124 Vertex::Print(ostream &s, int flag)
00125 {
00126 s << this->getTag() << " " ;
00127 s << myRef << " ";
00128 if (flag == 1)
00129 s << myWeight << " " ;
00130 else if (flag ==2)
00131 s << myColor << " " ;
00132 else if (flag == 3)
00133 s << myWeight << " " << myColor << " " ;
00134
00135 s << "ADJACENCY: " << myAdjacency;
00136 }
00137
00138