09.05.2013 Views

Algoritmos Heurísticos de Cobertura de Arcos

Algoritmos Heurísticos de Cobertura de Arcos

Algoritmos Heurísticos de Cobertura de Arcos

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

If ((M=0) Or (MMA+ME)) Then<br />

begin<br />

Falha:= True;<br />

ShowMessage('Falha na leitura do Arquivo. Verifique se o arquivo contém um grafo, ou uma solução <strong>de</strong><br />

MCPP');<br />

Exit;<br />

end;<br />

CalculaCompArco;<br />

For II:=1 To M Do<br />

Begin<br />

ArcoArtificial:=false;<br />

Readln(Re<strong>de</strong>,a,Link,Noi,I,J,Nof,I1,J1,d);<br />

If Link=0<br />

then CriaAresta(J*CompArco,I*CompArco,J1*CompArco,I1*CompArco,PaintBox1);<br />

If (II=M) and (Noi=FimRota) and (Nof=InicioRota)<br />

then ArcoArtificial:=true;<br />

If (Link=1) and (ArcoArtificial=false)<br />

then CriaArco(J*CompArco,I*CompArco,J1*CompArco,I1*CompArco,PaintBox1);<br />

End;<br />

For I:=1 To NL Do<br />

For J:=1 To NC Do<br />

CriaNo(J*CompArco,I*CompArco,PaintBox1);<br />

CloseFile(Re<strong>de</strong>);<br />

end;<br />

Procedure OrientaAresta(var f1,f2:Integer;x1,y1,x2,y2:Integer;PaintBox1:TPaintBox);<br />

// Orienta uma aresta no sentido que é percorrido na solução <strong>de</strong> NegCircuit<br />

// f1 e f2 são a frequencia <strong>de</strong> travessia da aresta num sentido e no outro<br />

// Se f1>0, a aresta será orientada <strong>de</strong> inicio para o fim<br />

// Se f1=0, a aresta será orientada no sentido contrário<br />

var xs,ys,xt,yt,temp: Integer;<br />

begin<br />

If f1=0<br />

then begin<br />

temp:=x1;<br />

x1:=x2;<br />

x2:=temp;<br />

temp:=y1;<br />

y1:=y2;<br />

y2:=temp;<br />

f2:=f2-1;<br />

end<br />

else f1:=f1-1;<br />

PaintBox1.Canvas.Pen.Width:=PenaDiag*2;<br />

PaintBox1.Canvas.Pen.Color:=8400000;<br />

If (x1 = x2) or (y1 = y2)<br />

Then PaintBox1.Canvas.Pen.Width:=PenaNormal*2;<br />

xs:=Round((x2-x1)*0.85)+x1;<br />

xt:=Round((x2-x1)*0.95)+x1;<br />

ys:=Round((y2-y1)*0.85)+y1;<br />

yt:=Round((y2-y1)*0.95)+y1;<br />

If (x1 = x2) or (y1 = y2) then<br />

begin<br />

xs:=Round((x2-x1)*0.80)+x1;<br />

ys:=Round((y2-y1)*0.80)+y1;<br />

xt:=Round((x2-x1)*0.90)+x1;<br />

yt:=Round((y2-y1)*0.90)+y1;<br />

end;<br />

PaintBox1.Canvas.MoveTo(xs,ys);<br />

PaintBox1.Canvas.LineTo(xt,yt);<br />

end;<br />

Procedure CriaCopia(Var f1,f2: Integer; x1,y1,x2,y2:Integer;PaintBox1:TPaintBox);<br />

// Traça uma cópia <strong>de</strong> um link com as coor<strong>de</strong>nadas inicio e fim dadas<br />

// f1 e f2 são a frequencia <strong>de</strong> travessia do links num sentido e no outro<br />

163

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!