if (x=x2) and (y=y2) then begin
for k:=1 to i do
if (sqr(X-data[k].x1)+sqr(Y-data[k].y1)<=100) then
begin
canvas.arc(data[k].x1,data[k].y1-30,data[k].x1+50,data[k].y1+30,
data[k].x1+5,data[k].y1+2,data[k].x1,data[k].y1);
break;end;
end
else
//--------------------------
for k:=1 to i do
if (sqr(X-data[k].x1)+sqr(Y-data[k].y1)<=100) then
begin
for k1:=1 to i do
if (sqr(x2-data[k1].x1)+sqr(y2-data[k1].y1)<=100) then begin
canvas.MoveTo(data[k1].x1,data[k1].y1);x2:=0;y2:=0;break;end;
canvas.Lineto(data[k].x1,data[k].y1);
matr[k1,k]:=1;matr[k,k1]:=1;
matr_edit[k1,k]:=1;matr_edit[k,k1]:=1;
matr[k,k]:=0;matr_edit[k,k]:=0;
Combobox1.visible:=true;
Label1.Visible:=true;
end;
end;
//*************************************************
procedure TForm1.FormActivate(Sender: TObject);
var j:integer;
begin
for i:=1 to 20 do
for j:=1 to 20 do
matr[i,j]:=0;
i:=0; x2:=0;y2:=0;
b1:=false;b2:=false; b4:=true;
combobox1.Items.Append('(None)');
Combobox1.visible:=false;
Label1.Visible:=false;
end;
//**provereaet esli vershina imeet kratnye riobra*********
function TForm1.Proverka(ind: byte): boolean;
var sum,i1,i2: byte;
begin
sum:=0;
for i1:=1 to i do
sum:=sum+matr[ind,i1];
if ((sum mod 2) =0) then
Proverka:=true else Proverka:=false;
end;
//*****delete vershinu********************************
procedure TForm1.Newselect(ind: byte);
var
ARect: TRect;
i1,i2:integer;
begin
with Image2.Canvas do
begin
CopyMode :=Whiteness;
ARect := Rect(0, 0, Image2.Width, Image2.Height);
CopyRect(ARect, Image2.Canvas, ARect);
CopyMode := cmSrcCopy;
//***************************
for i1:=1 to i do
for i2:=1 to i do
matr_edit[i1,i2]:=matr[i1,i2];
if proverka(ind) then
for i2:=1 to i do
begin
matr_edit[ind,i2]:=0;
matr_edit[i2,ind]:=0;
end;
if (proverka(ind)) then
begin
image2.Canvas.Brush.Color := clRed;
image2.canvas.pen.color:=clblack;
for i1:=1 to i do
for i2:=1 to i do
if matr_edit[i1,i2]=1 then
begin
image2.canvas.Ellipse(data[i1].x1-10,data[i1].y1-10,
data[i1].x1+10,data[i1].y1+10);
image2.canvas.TextOut(data[i1].x1-3,data[i1].y1-6,inttostr(i1));
image2.canvas.MoveTo(data[i1].x1,data[i1].y1);
image2.canvas.Lineto(data[i2].x1,data[i2].y1);
end;
end; end;end;
//----------------------------------------------------------
procedure TForm1.Graph;
var i1,i2:integer;
ARect: TRect;
begin
with Image2.Canvas do
begin
CopyMode :=Whiteness;
ARect := Rect(0, 0, Image2.Width, Image2.Height);
CopyRect(ARect, Image2.Canvas, ARect);
CopyMode := cmSrcCopy;
image2.Canvas.Brush.Color := clRed;
image2.canvas.pen.color:=clblack;
for i1:=1 to i do
for i2:=1 to i do
if matr[i1,i2]=1 then
begin
image2.canvas.Ellipse(data[i1].x1-10,data[i1].y1-10,
data[i1].x1+10,data[i1].y1+10);
image2.canvas.TextOut(data[i1].x1-3,data[i1].y1-6,inttostr(i1));
image2.canvas.MoveTo(data[i1].x1,data[i1].y1);
image2.canvas.Lineto(data[i2].x1,data[i2].y1);
end; end; end;
//****soedineam dve sosednie vershiny***********************
procedure TForm1.Duga(ind:byte);
var
v,i2,a1,d1,a2,d2,a,b: integer;
R:double;
s_1:array[1..2] of integer;
begin
v:=1;
if proverka(ind) then
for i2:=1 to i do
begin
if ((matr[ind,i2]=1) and (ind<>i2)) then
begin
s_1[v]:=i2;inc(v);
end;
if v=3 then
begin
a2:=data[s_1[1]].x1;d2:=data[s_1[1]].y1;
a1:=data[s_1[2]].x1;d1:=data[s_1[2]].y1;
a:=round((sqr(a1)+sqr(d1)-sqr(a2)-sqr(d2))/(2*(a1+d1-a2-d2)));
b:=a;
R:=sqrt(sqr(a2-a)+sqr(d2-b));
image2.canvas.pen.color:=clblue;
image2.Canvas.arc(round(a-R),round(a-R),round(a+R),round(a+R),a1,d1,a2,d2);
v:=1;
end;
end;end;
//*******vybor vershin************************************
procedure TForm1.ComboBox1Change(Sender: TObject);
begin
if combobox1.ItemIndex = 0 then
Graph
else
begin
newselect(combobox1.ItemIndex);
duga(combobox1.ItemIndex); end;
end;
end.