00001
00002
00003
00004
00005
00006
#include "Edge.hpp"
00007 Edge::Edge(
Node src,
Node dst,
float weight){
00008
p =
new Edge_Base(src, dst, weight);
00009 }
00010 Edge::Edge(
const Edge& edge){
00011
p = edge.
p;
00012 ++
p->
use;
00013 }
00014 Edge&
Edge::operator=(
const Edge& rhs){
00015 rhs.
p->
use++;
00016
if(--
p->
use == 0){
00017
delete p;
00018 }
00019
p = rhs.
p;
00020
return *
this;
00021 }
00022 Edge::~Edge(){
00023
if(--
p->
use == 0){
00024
delete p;
00025 }
00026 }
00027 Node Edge::getSRC()const{
00028
return p->
getSRC();
00029 }
00030 Node Edge::getDST()const{
00031
return p->
getDST();
00032 }
00033
00034 double Edge::getWeight()const{
00035
return p->
getWeight();
00036 }
00037 void Edge::setCoord(
int _x0,
int _y0,
int _x1,
int _y1){
00038
p->
setCoord(_x0, _y0, _x1, _y1);
00039 }
00040 int Edge::getX0()const{
00041
return p->
getX0();
00042 }
00043 int Edge::getY0()const{
00044
return p->
getY0();
00045 }
00046 int Edge::getX1()const{
00047
return p->
getX1();
00048 }
00049 int Edge::getY1()const{
00050
return p->
getY1();
00051 }
00052 string
Edge::toString()const{
00053
return p->
toString();
00054 }
00055
00056
00057
00058 Edge_Base::Edge_Base(
Node _src,
Node _dst,
float _weight):
00059 use(1),
00060 src(_src),
00061 dst(_dst),
00062 weight(_weight),
00063 x0(-1),
00064 y0(-1),
00065 x1(-1),
00066 y1(-1){}
00067 Node Edge_Base::getSRC()const{
00068
return src;
00069 }
00070 Node Edge_Base::getDST()const{
00071
return dst;
00072 }
00073 float Edge_Base::getWeight()const{
00074
return weight;
00075 }
00076 void Edge_Base::setCoord(
int _x0,
int _y0,
int _x1,
int _y1){
00077
x0 = _x0;
00078
y0 = _y0;
00079
x1 = _x1;
00080
y1 = _y1;
00081 }
00082 int Edge_Base::getX0()const{
00083
return x0;
00084 }
00085 int Edge_Base::getY0()const{
00086
return y0;
00087 }
00088 int Edge_Base::getX1()const{
00089
return x1;
00090 }
00091 int Edge_Base::getY1()const{
00092
return y1;
00093 }
00094
00095 string
Edge_Base::toString()
const{
00096 std::ostringstream o;
00097 o <<
src.
toString(0,
false) <<
"\n";
00098 o <<
dst.
toString(0,
false) <<
"\n" <<
weight <<
"]";
00099
return o.str();
00100 }
00101
00102
00103
00104
00105
00106
00107
00108
00109 bool compareEdge(
const Edge a,
const Edge b){
00110
return a.
getWeight() < b.
getWeight();
00111 }