Определение достижимости города в изменяемой системе двусторонних дорог
Курсовой проект - Компьютеры, программирование
Другие курсовые по предмету Компьютеры, программирование
gGrid3do(f,ColCount);(f,RowCount);i:=0toColCount-1dok:=0toRowCount-1do(F,Cells[i,k]);;(F);;TForm1.N10Click(Sender:TObject);">for i:=1 to n+1 do.Cells[i,0]:= inttostr(i);.Cells[0,i]:= inttostr(i);;i:=1 to n+1 do.Cells[i,0]:= inttostr(i);.Cells[0,i]:= inttostr(i);;i:=1 to n doj:=1 to n doStringGrid3.Cells[j,i]= then.cells[j,i]:=0;;i:=1 to n doj:=1 to n doStringGrid1.Cells[j,i]= then.cells[j,i]:=0;;.Click; // обновить картинку.Caption:= Разместить город +IntToStr(pos+1);;;;TForm1.Image1MouseDown(Sender: TObject; Button: TMouseButton; // по нажатию на имаже: TShiftState; X, Y: Integer);button 10 then button6.Click else button5.Click;// обновим изображение.Caption:= Разместить город +IntToStr(pos+1);;TForm1.Button8Click(Sender: TObject);: TextFile;, k: Integer;(not SaveDialog1.Execute()) then exit; // проверяем открылся ли диалог загрузки(f, SaveDialog1.FileName);(f);StringGrid3 do(f, ColCount);(f, RowCount);i := 0 to ColCount - 1 dok := 0 to RowCount - 1 do(F, Cells[i, k]);;(F);;TForm1.N10Click(Sender: TObject);
begin.Click; // вызов решения гамильтонова цикла
0then[i-1,j-1]:=1elsedost[i-1,j-1]:=0;">end;TForm1.Button11Click(Sender: TObject);i,j,k: integer;:array of array of integer;pos0 then[i-1,j-1]:=1 else dost[i-1,j-1]:=0;
for k:=0 to pos-1 do // ищем можно ли сократить путь через третью вершину К
for i:=0 to pos-1 doj:=0 to pos-1 do[i,j]:= dost[i,j] or (dost[i,k] and dost[k,j]) ;dost[ isv.Value-1, vv.Value-1]=0 then
label5.Caption:=Город НЕ достижим
posthenvv.Value:=pos;;TForm1.isvChange(Sender:TObject);isv.Value>posthenisv.Value:=pos;;TForm1.IzverChange(Sender:TObject);izver.Value>posthenizver.Value:=pos;;TForm1.N6Click(Sender:TObject);.show;;redrow_result_true;i,j:integer;pos=0thenexit;:=form1.stringgrid3.ColCount-1;.Image1.Canvas.Pen.Mode:=pmCopy;.Image1.Canvas.Brush.Color:=clWhite;.Image1.Canvas.Rectangle(0,0,form1.Image1.Width,form1.Image1.Height);//.Image1.Canvas.Pen.Width:=3;.Image1.Canvas.Pen.Color:=clGreen;i:=1tondo//j:=1tondostrtoint(form1.StringGrid3.Cells[i,j])>0then.Image1.Canvas.MoveTo(vers[i].x,vers[i].y);.Image1.Canvas.lineTo(vers[j].x,vers[j].y);">begin.Caption:=Город достижим;i:=1 to pos doj:=1 to pos do.Cells[j,i]:=inttostr(dost[i-1,j-1]);;;TForm1.StringGrid3KeyUp(Sender: TObject; var Key: Word;: TShiftState);;;TForm1.vvChange(Sender: TObject);vv.Value>pos then vv.Value:=pos;;TForm1.isvChange(Sender: TObject);isv.Value>pos then isv.Value:=pos;;TForm1.IzverChange(Sender: TObject);izver.Value>pos then izver.Value:=pos;;TForm1.N6Click(Sender: TObject);.show;;redrow_result_true;i,j:integer;pos =0 then exit;:=form1.stringgrid3.ColCount-1;.Image1.Canvas.Pen.Mode := pmCopy;.Image1.Canvas.Brush.Color := clWhite;.Image1.Canvas.Rectangle(0,0,form1.Image1.Width,form1.Image1.Height); // очистка канваса без мигания.Image1.Canvas.Pen.Width:=3;.Image1.Canvas.Pen.Color := clGreen;i:=1 to n do // рисуем ребраj:=1 to n dostrtoint(form1.StringGrid3.Cells[i,j])>0 then.Image1.Canvas.MoveTo(vers[i].x,vers[i].y);.Image1.Canvas.lineTo(vers[j].x,vers[j].y);
/// красная точка направления.Image1.Canvas.pen.Color := clRed;.Image1.Canvas.Brush.Color := clRed;.Image1.Canvas.ellipse(round(vers[j].x+(vers[i].x- vers[j].x)*0.9)-4,round(vers[j].y+(vers[i].y- vers[j].y)*0.9)-4,(vers[j].x+(vers[i].x-vers[j].x)*0.9)+4,round(vers[j].y+(vers[i].y- vers[j].y)*0.9)+4);.Image1.Canvas.ellipse(round(vers[j].x+(vers[i].x- vers[j].x)*0.93)-3,round(vers[j].y+(vers[i].y- vers[j].y)*0.93)-3,(vers[j].x+(vers[i].x- vers[j].x)*0.93)+3,round(vers[j].y+(vers[i].y- vers[j].y)*0.93)+3);.Image1.Canvas.ellipse(round(vers[j].x+(vers[i].x- vers[j].x)*0.95)-2,round(vers[j].y+(vers[i].y- vers[j].y)*0.95)-2,(vers[j].x+(vers[i].x- vers[j].x)*0.95)+2,round(vers[j].y+(vers[i].y- vers[j].y)*0.95)+2);.Image1.Canvas.ellipse(round(vers[j].x+(vers[i].x- vers[j].x)*0.97)-1,round(vers[j].y+(vers[i].y- vers[j].y)*0.97)-1,(vers[j].x+(vers[i].x- vers[j].x)*0.97)+1,round(vers[j].y+(vers[i].y- vers[j].y)*0.97)+1);.Image1.Canvas.Pen.Width:=3;.Image1.Canvas.Pen.Color := clGreen;.Image1.Canvas.Brush.Color := clWhite;.Image1.Canvas.pen.Style:= psSolid ;;.Image1.Canvas.Pen.Width:=1;.Image1.Canvas.Pen.Color := clBlack;
for i:=1 to n do// вершины - кружки с номером вершины
0then.Image1.Canvas.MoveTo(vers[i].x,vers[i].y);.Image1.Canvas.lineTo(vers[j].x,vers[j].y);">Form1.Image1.Canvas.Brush.Color:=RGB(234,228,36);.Image1.Canvas.Ellipse(vers[i].x-10,vers[i].y-10,vers[i].x+10,vers[i].y+10);.Image1.Canvas.TextOut(vers[i].x-3,vers[i].y-6,inttostr(i));;;redrow_result_false;i,j:integer;pos =0 then exit;:=form1.stringgrid3.ColCount-1;.Image1.Canvas.Pen.Mode := pmCopy;.Image1.Canvas.Brush.Color := clWhite;.Image1.Canvas.Rectangle(0,0,form1.Image1.Width,form1.Image1.Height); // очистка канваса без мигания.Image1.Canvas.Pen.Width:=3;.Image1.Canvas.Pen.Color := clYellow;i:=1 to n do // рисуем ребраj:=1 to n dostrtoint(form1.StringGrid3.Cells[i,j])>0 then.Image1.Canvas.MoveTo(vers[i].x,vers[i].y);.Image1.Canvas.lineTo(vers[j].x,vers[j].y);
/// красная точка направления.Image1.Canvas.pen.Color := clRed;.Image1.Canvas.Brush.Color := clRed;.Image1.Canvas.ellipse(round(vers[j].x+(vers[i].x- vers[j].x)*0.9)-4,round(vers[j].y+(vers[i].y- vers[j].y)*0.9)-4,(vers[j].x+(vers[i].x-vers[j].x)*0.9)+4,round(vers[j].y+(vers[i].y- vers[j].y)*0.9)+4);.Image1.Canvas.ellipse(round(vers[j].x+(vers[i].x- vers[j].x)*0.93)-3,round(vers[j].y+(vers[i].y- vers[j].y)*0.93)-3,(vers[j].x+(vers[i].x- vers[j].x)*0.93)+3,round(vers[j].y+(vers[i].y- vers[j].y)*0.93)+3);.Image1.Canvas.ellipse(round(vers[j].x+(vers[i].x- vers[j].x)*0.95)-2,round(vers[j].y+(vers[i].y- vers[j].y)*0.95)-2,(vers[j].x+(vers[i].x- vers[j].x)*0.95)+2,round(vers[j].y+(vers[i].y- vers[j].y)*0.95)+2);.Image1.Canvas.ellipse(round(vers[j].x+(vers[i].x- vers[j].x)*0.97)-1,round(vers[j].y+(vers[i].y- vers[j].y)*0.97)-1,(vers[j].x+(vers[i].x- vers[j].x)*0.97)+1,round(vers[j].y+(vers[i].y- vers[j].y)*0.97)+1);.Image1.Canvas.Pen.Width:=3;.Image1.Canvas.Pen.Color := clYellow;.Image1.Canvas.Brush.Color := clWhite;.Image1.Canvas.pen.Style:= psSolid ;;.Image1.Canvas.Pen.Width:=1;.Image1.Canvas.Pen.Color := clBlack;
for i:=1 to n do// вершины - кружки с номером вершины
0then:=true;.Label5.Caption:=;;:=Round((doroga-pos)/(5*pos));:=Round(vver/pos);(doroga0 then:=true;.Label5.Caption:=Все города достижимы;;:=Round((doroga-pos)/(5*pos));:=Round(vver/pos);(doroga<=3) and ((vver<5) or (vver=6) or (vver=10)) theni:=1 to pos doj:=1 to pos+1 dodost[izver-1,j-1]=0 then.StringGrid3.Cells[izver,j]:=1;.StringGrid3.Cells[j,izver]:=1;
Form1.Label5.Caption:=Все города достижимы;
result:=true;;;j:=1 to pos dodost[izver-1,j-1]=0 then.StringGrid3.Cells[izver,j]:=1;.StringGrid3.Cells[j,izver]:=1;
Form1.Label5.Caption:=Все города достижимы;
Matrix;;;begin:=false;.Label5.Caption:=Не все города достижимы;;;TForm1.Button12Click(Sender: TObject);i,j:integer;(Form1.izver.Value);result then redrow_result_true else redrow_result_false;;.Unit2; // модуль формы 2 О программе, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,, StdCtrls;= class(TForm): TLabel;Label1Click(Sender: TObject);
{ Private declarations }
{ Public declar