Определение достижимости города в изменяемой системе двусторонних дорог
Курсовой проект - Компьютеры, программирование
Другие курсовые по предмету Компьютеры, программирование
;">beginpos =0 then exit;:=stringgrid3.ColCount-1;.Canvas.Pen.Mode := pmCopy;.Canvas.Brush.Color := clWhite;.Canvas.Rectangle(0,0,Image1.Width,Image1.Height); // очистка канваса без мигания.Canvas.Pen.Width:=1;i:=1 to n do // рисуем дугиj:=1 to n dostrtoint(StringGrid3.Cells[i,j])>0 then.Canvas.MoveTo(vers[i].x,vers[i].y);.Canvas.lineTo(vers[j].x,vers[j].y);
/// красная точка направления.Canvas.pen.Color := clRed;
Image1.Canvas.Brush.Color := clRed;.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);.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);.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);.Canvas.ellipse(round(vers[j].x+(vers[i].x- vers[j].x)*0.97)-1,round(vers[].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);.Canvas.Pen.Color := clBlack;.Canvas.Brush.Color := clWhite;.Canvas.pen.Style:= psSolid ;;i:=1 to n do
begin // вершины - кружки с номером вершины
Image1.Canvas.Brush.Color:=RGB(234,228,36);.Canvas.Ellipse(vers[i].x-10,vers[i].y-10,vers[i].x+10,vers[i].y+10);.Canvas.TextOut(vers[i].x-3,vers[i].y-6,inttostr(i));;;TForm1.FormCreate(Sender: TObject);:=0;:=0;:=false;;TForm1.Button2Click(Sender: TObject);:=false;:=-100;:=-100;.Canvas.Pen.Mode := pmNotXor;:= True;;TForm1.Image1MouseMove(Sender: TObject; Shift: TShiftState; X,: Integer);ver then.Canvas.Ellipse(xx-10,yy-10,xx+10,yy+10);:=x;:=y;.Canvas.Ellipse(x-10,y-10,x+10,y+10);;reb2 then.Canvas.MoveTo(xb,yb);.Canvas.LineTo(xx,yy);:=x;:=y;.Canvas.MoveTo(xb,yb);.Canvas.LineTo(x,y);:=x;:=y;;;TForm1.Image1MouseUp(Sender: TObject; Button: TMouseButton;: TShiftState; X, Y: Integer);j,k,i,i2,xx,yy:integer;del_ver then// удаление вершины
//найти удаляемую вершину:=findver(x,y,10); //удалить все ребра которые входят и выходят их этой вершины
ver:= false;:= false;:=false;_ver:=false;
=kthenvers[i]:=vers[i+1];">if k=0 then exit;i:=1 to StringGrid3.ColCount-1 doi>=k then vers[i]:=vers[i+1];
// будем копировать на единицу назад столбцы, если они стоят правее удаляемой вершины
=kthenStringGrid3.Cells[i,j]:=StringGrid3.cells[i,j+1];j:=1toStringGrid3.RowCount-1doi:=1toStringGrid3.RowCount-1doi>=kthenStringGrid3.Cells[i,j]:=StringGrid3.cells[i+1,j];:=pos-1;.Value:=edit1.Value-1;.cells[0,0]:=*;;.Canvas.Pen.Mode:=pmCopy;.Caption:=+IntToStr(pos+1);;verthen(pos);[pos].x:=x;[pos].y:=y;">for i:=1 to StringGrid3.RowCount-1 doj:=1 to StringGrid3.RowCount-1 doj>=k then StringGrid3.Cells[i,j]:=StringGrid3.cells[i,j+1];j:=1 to StringGrid3.RowCount-1 doi:=1 to StringGrid3.RowCount-1 doi>=k then StringGrid3.Cells[i,j]:=StringGrid3.cells[i+1,j];:=pos-1;.Value:=edit1.Value-1;.cells[0,0]:=*;;.Canvas.Pen.Mode := pmCopy;.Caption:= Разместить город +IntToStr(pos+1);;ver then(pos);[pos].x:=x;[pos].y:=y;
xx:=-100;yy:=-100;[pos].num:=pos;
1then.ColCount:=StringGrid3.ColCount+1;.RowCount:=StringGrid3.RowCount+1;.Value:=pos;;i:=1toedit1.value+1do">ver:=False;.Caption:= Разместить город +IntToStr(pos+1);pos>1 then.ColCount:=StringGrid3.ColCount+1;.RowCount:=StringGrid3.RowCount+1;.Value :=pos;;i:=1 to edit1.value+1 do
begin // рисуем новые номера вершин после изм. количества вершин
StringGrid3.Cells[i,0]:= inttostr(i);.Cells[0,i]:= inttostr(i);;i:=1 to edit1.value doi2:=1 to edit1.value doStringGrid3.Cells[i2,i]= then.cells[i2,i]:=0;
end;;;// перерисуем что получилось после добавления вершины
end;reb2 then begin:=false;:=false;:=0;:=0;:=findver(x,y,10);
If i <>0 then// если указали все верно из одного кружка вершины в другой, то добавим в матрицу смежности запись
0then(n);.Cells[pos2,0]:=inttostr(i);">StringGrid3.Cells[findver(x,y,10),findver(xb,yb,10)]:=1;.Cells[findver(xb,yb,10),findver(x,y,10)]:=1;.cells[0,0]:=*;;;;;;reb then:=x;:=y;:=x;:=y;:=True;.Canvas.MoveTo(0,0);.Canvas.LineTo(x,y);:=findver(x,y,10);i <>0 then(n);.Cells[pos2,0]:=inttostr(i);
i:=findver(x,y,10); // найти к какой вершине мы сейчас добавляем ребро;;:=false; // неудачная попытка добавить ребро
0)or(ximage1.Width)) do:=image1.Width-random(image1.Width*2);:=image1.Height-random(image1.Height*2);:=ns+ 300+ trunc(cos(i*step+ms+ugol/100)*100);:=ms+ 150+ trunc(sin(i*step+ns+ugol/100)*100);;[i].x:=x; vers[i].y:=y;;;;TForm1.Button5Click(Sender: TObject);
var x,y:Integer;:Integer;
step:real;:=2*3.14/ edit1.value;i:=1 to edit1.value do[i].x:= 300+ trunc(cos(i*step+ugol/100)*100);[i].y:= 150+ trunc(sin(i*step+ugol/100)*100);;;;TForm1.Button4Click(Sender: TObject);_ver:=true;;TForm1.Button10Click(Sender: TObject);i,j:Integer;
// очистка грида:=edit1.Value;:=edit1.Value;i:=1 to n doj:=1 to n do.cells[j,i]:=0;.Click;;TForm1.N5Click(Sender: TObject);(0);;TForm1.N2Click(Sender: TObject);
begin.Click; // вызов открытия из меню
end;TForm1.N3Click(Sender: TObject);
begin.click; // вызов сохранения их меню
end;TForm1.N4Click(Sender: TObject); // новый графi,j:integer;.click; // вначале очистка грида
edit1.Value:=1; // убираем лишние строки и столбцы
label5.Caption:= ;.click; // обновляем картинку.Caption:= Разместить город +IntToStr(pos+1);i:=0 to pos-1 doj:=0 to pos-1 do.Cells[i,j]:=0;.Cells[i,j]:=0;;;TForm1.StringGrid3KeyPress(Sender: TObject; var Key: Char);(Sender as TStringGrid).col=(Sender as TStringGrid).row // нельзя ставить на главное диагоналиkey := Chr(0);Key of
#8,1,0:; // цифры и клавиша key := Chr(0); // остальные символы запрещены
end;;TForm1.Edit1Change(Sender: TObject);i,j : integer;
StringGrid3.ColCount:=edit1.Value+1;// при изменении спинбокса нужно перерисовать матрицу.RowCount:=edit1.Value+1;.ColCount:=edit1.Value+1;// при изменении спинбокса нужно перерисовать матрицу
StringGrid1.RowCount:=edit1.Value+1;:=edit1.Value;
pos:=edit1.Value;
// надписи о номерах
mbLeftthen//.Popup(Mouse.CursorPos.X,Mouse.CursorPos.y);//;TForm1.N7Click(Sender:TObject);.Click;;TForm1.N8Click(Sender:TObject);.Click;;TForm1.N9Click(Sender:TObject);.Click;;TForm1.Button6Click(Sender:TObject);i:integer;i:=1toedit1.valuedo[i].x:=0;vers[i].y:=0;;.Click;;TForm1.Button7Click(Sender:TObject);:TextFile;,i,k:Integer;:String;(notOpenDialog1.Execute())thenexit;(f,OpenDialog1.FileName);(f);StringGrid3do(f,iTmp);:=iTmp;(f,iTmp);:=iTmp;.Value:=ColCount-1;i:=0toColCount-1dok:=0toRowCount-1do(f,strTemp);[i,k]:=strTemp;;.Caption:=;;(f);StringGrid3.ColCount>10thenbutton6.Clickelsebutton5.Click;//.Caption:=+IntToStr(pos+1);;TForm1.Button8Click(Sender:TObject);:TextFile;,k:Integer;(notSaveDialog1.Execute())thenexit;//(f,SaveDialog1.FileName);(f);Strin